stm32f10x_tim.h 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134
  1. /**
  2. ******************************************************************************
  3. * @file stm32f10x_tim.h
  4. * @author MCD Application Team
  5. * @version V3.3.0
  6. * @date 04/16/2010
  7. * @brief This file contains all the functions prototypes for the TIM firmware
  8. * library.
  9. ******************************************************************************
  10. * @copy
  11. *
  12. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  13. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  14. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  15. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  16. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  17. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  18. *
  19. * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __STM32F10x_TIM_H
  23. #define __STM32F10x_TIM_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f10x.h"
  29. /** @addtogroup STM32F10x_StdPeriph_Driver
  30. * @{
  31. */
  32. /** @addtogroup TIM
  33. * @{
  34. */
  35. /** @defgroup TIM_Exported_Types
  36. * @{
  37. */
  38. /**
  39. * @brief TIM Time Base Init structure definition
  40. * @note This sturcture is used with all TIMx except for TIM6 and TIM7.
  41. */
  42. typedef struct
  43. {
  44. uint16_t TIM_Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
  45. This parameter can be a number between 0x0000 and 0xFFFF */
  46. uint16_t TIM_CounterMode; /*!< Specifies the counter mode.
  47. This parameter can be a value of @ref TIM_Counter_Mode */
  48. uint16_t TIM_Period; /*!< Specifies the period value to be loaded into the active
  49. Auto-Reload Register at the next update event.
  50. This parameter must be a number between 0x0000 and 0xFFFF. */
  51. uint16_t TIM_ClockDivision; /*!< Specifies the clock division.
  52. This parameter can be a value of @ref TIM_Clock_Division_CKD */
  53. uint8_t TIM_RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter
  54. reaches zero, an update event is generated and counting restarts
  55. from the RCR value (N).
  56. This means in PWM mode that (N+1) corresponds to:
  57. - the number of PWM periods in edge-aligned mode
  58. - the number of half PWM period in center-aligned mode
  59. This parameter must be a number between 0x00 and 0xFF.
  60. @note This parameter is valid only for TIM1 and TIM8. */
  61. } TIM_TimeBaseInitTypeDef;
  62. /**
  63. * @brief TIM Output Compare Init structure definition
  64. */
  65. typedef struct
  66. {
  67. uint16_t TIM_OCMode; /*!< Specifies the TIM mode.
  68. This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */
  69. uint16_t TIM_OutputState; /*!< Specifies the TIM Output Compare state.
  70. This parameter can be a value of @ref TIM_Output_Compare_state */
  71. uint16_t TIM_OutputNState; /*!< Specifies the TIM complementary Output Compare state.
  72. This parameter can be a value of @ref TIM_Output_Compare_N_state
  73. @note This parameter is valid only for TIM1 and TIM8. */
  74. uint16_t TIM_Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  75. This parameter can be a number between 0x0000 and 0xFFFF */
  76. uint16_t TIM_OCPolarity; /*!< Specifies the output polarity.
  77. This parameter can be a value of @ref TIM_Output_Compare_Polarity */
  78. uint16_t TIM_OCNPolarity; /*!< Specifies the complementary output polarity.
  79. This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
  80. @note This parameter is valid only for TIM1 and TIM8. */
  81. uint16_t TIM_OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  82. This parameter can be a value of @ref TIM_Output_Compare_Idle_State
  83. @note This parameter is valid only for TIM1 and TIM8. */
  84. uint16_t TIM_OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  85. This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
  86. @note This parameter is valid only for TIM1 and TIM8. */
  87. } TIM_OCInitTypeDef;
  88. /**
  89. * @brief TIM Input Capture Init structure definition
  90. */
  91. typedef struct
  92. {
  93. uint16_t TIM_Channel; /*!< Specifies the TIM channel.
  94. This parameter can be a value of @ref TIM_Channel */
  95. uint16_t TIM_ICPolarity; /*!< Specifies the active edge of the input signal.
  96. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  97. uint16_t TIM_ICSelection; /*!< Specifies the input.
  98. This parameter can be a value of @ref TIM_Input_Capture_Selection */
  99. uint16_t TIM_ICPrescaler; /*!< Specifies the Input Capture Prescaler.
  100. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  101. uint16_t TIM_ICFilter; /*!< Specifies the input capture filter.
  102. This parameter can be a number between 0x0 and 0xF */
  103. } TIM_ICInitTypeDef;
  104. /**
  105. * @brief BDTR structure definition
  106. * @note This sturcture is used only with TIM1 and TIM8.
  107. */
  108. typedef struct
  109. {
  110. uint16_t TIM_OSSRState; /*!< Specifies the Off-State selection used in Run mode.
  111. This parameter can be a value of @ref OSSR_Off_State_Selection_for_Run_mode_state */
  112. uint16_t TIM_OSSIState; /*!< Specifies the Off-State used in Idle state.
  113. This parameter can be a value of @ref OSSI_Off_State_Selection_for_Idle_mode_state */
  114. uint16_t TIM_LOCKLevel; /*!< Specifies the LOCK level parameters.
  115. This parameter can be a value of @ref Lock_level */
  116. uint16_t TIM_DeadTime; /*!< Specifies the delay time between the switching-off and the
  117. switching-on of the outputs.
  118. This parameter can be a number between 0x00 and 0xFF */
  119. uint16_t TIM_Break; /*!< Specifies whether the TIM Break input is enabled or not.
  120. This parameter can be a value of @ref Break_Input_enable_disable */
  121. uint16_t TIM_BreakPolarity; /*!< Specifies the TIM Break Input pin polarity.
  122. This parameter can be a value of @ref Break_Polarity */
  123. uint16_t TIM_AutomaticOutput; /*!< Specifies whether the TIM Automatic Output feature is enabled or not.
  124. This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */
  125. } TIM_BDTRInitTypeDef;
  126. /** @defgroup TIM_Exported_constants
  127. * @{
  128. */
  129. #define IS_TIM_ALL_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  130. ((PERIPH) == TIM2) || \
  131. ((PERIPH) == TIM3) || \
  132. ((PERIPH) == TIM4) || \
  133. ((PERIPH) == TIM5) || \
  134. ((PERIPH) == TIM6) || \
  135. ((PERIPH) == TIM7) || \
  136. ((PERIPH) == TIM8) || \
  137. ((PERIPH) == TIM9) || \
  138. ((PERIPH) == TIM10)|| \
  139. ((PERIPH) == TIM11)|| \
  140. ((PERIPH) == TIM12)|| \
  141. ((PERIPH) == TIM13)|| \
  142. ((PERIPH) == TIM14)|| \
  143. ((PERIPH) == TIM15)|| \
  144. ((PERIPH) == TIM16)|| \
  145. ((PERIPH) == TIM17))
  146. /* LIST1: TIM 1 and 8 */
  147. #define IS_TIM_LIST1_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  148. ((PERIPH) == TIM8))
  149. /* LIST2: TIM 1, 8, 15 16 and 17 */
  150. #define IS_TIM_LIST2_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  151. ((PERIPH) == TIM8) || \
  152. ((PERIPH) == TIM15)|| \
  153. ((PERIPH) == TIM16)|| \
  154. ((PERIPH) == TIM17))
  155. /* LIST3: TIM 1, 2, 3, 4, 5 and 8 */
  156. #define IS_TIM_LIST3_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  157. ((PERIPH) == TIM2) || \
  158. ((PERIPH) == TIM3) || \
  159. ((PERIPH) == TIM4) || \
  160. ((PERIPH) == TIM5) || \
  161. ((PERIPH) == TIM8))
  162. /* LIST4: TIM 1, 2, 3, 4, 5, 8, 15, 16 and 17 */
  163. #define IS_TIM_LIST4_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  164. ((PERIPH) == TIM2) || \
  165. ((PERIPH) == TIM3) || \
  166. ((PERIPH) == TIM4) || \
  167. ((PERIPH) == TIM5) || \
  168. ((PERIPH) == TIM8) || \
  169. ((PERIPH) == TIM15)|| \
  170. ((PERIPH) == TIM16)|| \
  171. ((PERIPH) == TIM17))
  172. /* LIST5: TIM 1, 2, 3, 4, 5, 8 and 15 */
  173. #define IS_TIM_LIST5_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  174. ((PERIPH) == TIM2) || \
  175. ((PERIPH) == TIM3) || \
  176. ((PERIPH) == TIM4) || \
  177. ((PERIPH) == TIM5) || \
  178. ((PERIPH) == TIM8) || \
  179. ((PERIPH) == TIM15))
  180. /* LIST6: TIM 1, 2, 3, 4, 5, 8, 9, 12 and 15 */
  181. #define IS_TIM_LIST6_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  182. ((PERIPH) == TIM2) || \
  183. ((PERIPH) == TIM3) || \
  184. ((PERIPH) == TIM4) || \
  185. ((PERIPH) == TIM5) || \
  186. ((PERIPH) == TIM8) || \
  187. ((PERIPH) == TIM9) || \
  188. ((PERIPH) == TIM12)|| \
  189. ((PERIPH) == TIM15))
  190. /* LIST7: TIM 1, 2, 3, 4, 5, 6, 7, 8, 9, 12 and 15 */
  191. #define IS_TIM_LIST7_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  192. ((PERIPH) == TIM2) || \
  193. ((PERIPH) == TIM3) || \
  194. ((PERIPH) == TIM4) || \
  195. ((PERIPH) == TIM5) || \
  196. ((PERIPH) == TIM6) || \
  197. ((PERIPH) == TIM7) || \
  198. ((PERIPH) == TIM8) || \
  199. ((PERIPH) == TIM9) || \
  200. ((PERIPH) == TIM12)|| \
  201. ((PERIPH) == TIM15))
  202. /* LIST8: TIM 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16 and 17 */
  203. #define IS_TIM_LIST8_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  204. ((PERIPH) == TIM2) || \
  205. ((PERIPH) == TIM3) || \
  206. ((PERIPH) == TIM4) || \
  207. ((PERIPH) == TIM5) || \
  208. ((PERIPH) == TIM8) || \
  209. ((PERIPH) == TIM9) || \
  210. ((PERIPH) == TIM10)|| \
  211. ((PERIPH) == TIM11)|| \
  212. ((PERIPH) == TIM12)|| \
  213. ((PERIPH) == TIM13)|| \
  214. ((PERIPH) == TIM14)|| \
  215. ((PERIPH) == TIM15)|| \
  216. ((PERIPH) == TIM16)|| \
  217. ((PERIPH) == TIM17))
  218. /* LIST9: TIM 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, and 17 */
  219. #define IS_TIM_LIST9_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
  220. ((PERIPH) == TIM2) || \
  221. ((PERIPH) == TIM3) || \
  222. ((PERIPH) == TIM4) || \
  223. ((PERIPH) == TIM5) || \
  224. ((PERIPH) == TIM6) || \
  225. ((PERIPH) == TIM7) || \
  226. ((PERIPH) == TIM8) || \
  227. ((PERIPH) == TIM15)|| \
  228. ((PERIPH) == TIM16)|| \
  229. ((PERIPH) == TIM17))
  230. /**
  231. * @}
  232. */
  233. /** @defgroup TIM_Output_Compare_and_PWM_modes
  234. * @{
  235. */
  236. #define TIM_OCMode_Timing ((uint16_t)0x0000)
  237. #define TIM_OCMode_Active ((uint16_t)0x0010)
  238. #define TIM_OCMode_Inactive ((uint16_t)0x0020)
  239. #define TIM_OCMode_Toggle ((uint16_t)0x0030)
  240. #define TIM_OCMode_PWM1 ((uint16_t)0x0060)
  241. #define TIM_OCMode_PWM2 ((uint16_t)0x0070)
  242. #define IS_TIM_OC_MODE(MODE) (((MODE) == TIM_OCMode_Timing) || \
  243. ((MODE) == TIM_OCMode_Active) || \
  244. ((MODE) == TIM_OCMode_Inactive) || \
  245. ((MODE) == TIM_OCMode_Toggle)|| \
  246. ((MODE) == TIM_OCMode_PWM1) || \
  247. ((MODE) == TIM_OCMode_PWM2))
  248. #define IS_TIM_OCM(MODE) (((MODE) == TIM_OCMode_Timing) || \
  249. ((MODE) == TIM_OCMode_Active) || \
  250. ((MODE) == TIM_OCMode_Inactive) || \
  251. ((MODE) == TIM_OCMode_Toggle)|| \
  252. ((MODE) == TIM_OCMode_PWM1) || \
  253. ((MODE) == TIM_OCMode_PWM2) || \
  254. ((MODE) == TIM_ForcedAction_Active) || \
  255. ((MODE) == TIM_ForcedAction_InActive))
  256. /**
  257. * @}
  258. */
  259. /** @defgroup TIM_One_Pulse_Mode
  260. * @{
  261. */
  262. #define TIM_OPMode_Single ((uint16_t)0x0008)
  263. #define TIM_OPMode_Repetitive ((uint16_t)0x0000)
  264. #define IS_TIM_OPM_MODE(MODE) (((MODE) == TIM_OPMode_Single) || \
  265. ((MODE) == TIM_OPMode_Repetitive))
  266. /**
  267. * @}
  268. */
  269. /** @defgroup TIM_Channel
  270. * @{
  271. */
  272. #define TIM_Channel_1 ((uint16_t)0x0000)
  273. #define TIM_Channel_2 ((uint16_t)0x0004)
  274. #define TIM_Channel_3 ((uint16_t)0x0008)
  275. #define TIM_Channel_4 ((uint16_t)0x000C)
  276. #define IS_TIM_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
  277. ((CHANNEL) == TIM_Channel_2) || \
  278. ((CHANNEL) == TIM_Channel_3) || \
  279. ((CHANNEL) == TIM_Channel_4))
  280. #define IS_TIM_PWMI_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
  281. ((CHANNEL) == TIM_Channel_2))
  282. #define IS_TIM_COMPLEMENTARY_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
  283. ((CHANNEL) == TIM_Channel_2) || \
  284. ((CHANNEL) == TIM_Channel_3))
  285. /**
  286. * @}
  287. */
  288. /** @defgroup TIM_Clock_Division_CKD
  289. * @{
  290. */
  291. #define TIM_CKD_DIV1 ((uint16_t)0x0000)
  292. #define TIM_CKD_DIV2 ((uint16_t)0x0100)
  293. #define TIM_CKD_DIV4 ((uint16_t)0x0200)
  294. #define IS_TIM_CKD_DIV(DIV) (((DIV) == TIM_CKD_DIV1) || \
  295. ((DIV) == TIM_CKD_DIV2) || \
  296. ((DIV) == TIM_CKD_DIV4))
  297. /**
  298. * @}
  299. */
  300. /** @defgroup TIM_Counter_Mode
  301. * @{
  302. */
  303. #define TIM_CounterMode_Up ((uint16_t)0x0000)
  304. #define TIM_CounterMode_Down ((uint16_t)0x0010)
  305. #define TIM_CounterMode_CenterAligned1 ((uint16_t)0x0020)
  306. #define TIM_CounterMode_CenterAligned2 ((uint16_t)0x0040)
  307. #define TIM_CounterMode_CenterAligned3 ((uint16_t)0x0060)
  308. #define IS_TIM_COUNTER_MODE(MODE) (((MODE) == TIM_CounterMode_Up) || \
  309. ((MODE) == TIM_CounterMode_Down) || \
  310. ((MODE) == TIM_CounterMode_CenterAligned1) || \
  311. ((MODE) == TIM_CounterMode_CenterAligned2) || \
  312. ((MODE) == TIM_CounterMode_CenterAligned3))
  313. /**
  314. * @}
  315. */
  316. /** @defgroup TIM_Output_Compare_Polarity
  317. * @{
  318. */
  319. #define TIM_OCPolarity_High ((uint16_t)0x0000)
  320. #define TIM_OCPolarity_Low ((uint16_t)0x0002)
  321. #define IS_TIM_OC_POLARITY(POLARITY) (((POLARITY) == TIM_OCPolarity_High) || \
  322. ((POLARITY) == TIM_OCPolarity_Low))
  323. /**
  324. * @}
  325. */
  326. /** @defgroup TIM_Output_Compare_N_Polarity
  327. * @{
  328. */
  329. #define TIM_OCNPolarity_High ((uint16_t)0x0000)
  330. #define TIM_OCNPolarity_Low ((uint16_t)0x0008)
  331. #define IS_TIM_OCN_POLARITY(POLARITY) (((POLARITY) == TIM_OCNPolarity_High) || \
  332. ((POLARITY) == TIM_OCNPolarity_Low))
  333. /**
  334. * @}
  335. */
  336. /** @defgroup TIM_Output_Compare_state
  337. * @{
  338. */
  339. #define TIM_OutputState_Disable ((uint16_t)0x0000)
  340. #define TIM_OutputState_Enable ((uint16_t)0x0001)
  341. #define IS_TIM_OUTPUT_STATE(STATE) (((STATE) == TIM_OutputState_Disable) || \
  342. ((STATE) == TIM_OutputState_Enable))
  343. /**
  344. * @}
  345. */
  346. /** @defgroup TIM_Output_Compare_N_state
  347. * @{
  348. */
  349. #define TIM_OutputNState_Disable ((uint16_t)0x0000)
  350. #define TIM_OutputNState_Enable ((uint16_t)0x0004)
  351. #define IS_TIM_OUTPUTN_STATE(STATE) (((STATE) == TIM_OutputNState_Disable) || \
  352. ((STATE) == TIM_OutputNState_Enable))
  353. /**
  354. * @}
  355. */
  356. /** @defgroup TIM_Capture_Compare_state
  357. * @{
  358. */
  359. #define TIM_CCx_Enable ((uint16_t)0x0001)
  360. #define TIM_CCx_Disable ((uint16_t)0x0000)
  361. #define IS_TIM_CCX(CCX) (((CCX) == TIM_CCx_Enable) || \
  362. ((CCX) == TIM_CCx_Disable))
  363. /**
  364. * @}
  365. */
  366. /** @defgroup TIM_Capture_Compare_N_state
  367. * @{
  368. */
  369. #define TIM_CCxN_Enable ((uint16_t)0x0004)
  370. #define TIM_CCxN_Disable ((uint16_t)0x0000)
  371. #define IS_TIM_CCXN(CCXN) (((CCXN) == TIM_CCxN_Enable) || \
  372. ((CCXN) == TIM_CCxN_Disable))
  373. /**
  374. * @}
  375. */
  376. /** @defgroup Break_Input_enable_disable
  377. * @{
  378. */
  379. #define TIM_Break_Enable ((uint16_t)0x1000)
  380. #define TIM_Break_Disable ((uint16_t)0x0000)
  381. #define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_Break_Enable) || \
  382. ((STATE) == TIM_Break_Disable))
  383. /**
  384. * @}
  385. */
  386. /** @defgroup Break_Polarity
  387. * @{
  388. */
  389. #define TIM_BreakPolarity_Low ((uint16_t)0x0000)
  390. #define TIM_BreakPolarity_High ((uint16_t)0x2000)
  391. #define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BreakPolarity_Low) || \
  392. ((POLARITY) == TIM_BreakPolarity_High))
  393. /**
  394. * @}
  395. */
  396. /** @defgroup TIM_AOE_Bit_Set_Reset
  397. * @{
  398. */
  399. #define TIM_AutomaticOutput_Enable ((uint16_t)0x4000)
  400. #define TIM_AutomaticOutput_Disable ((uint16_t)0x0000)
  401. #define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AutomaticOutput_Enable) || \
  402. ((STATE) == TIM_AutomaticOutput_Disable))
  403. /**
  404. * @}
  405. */
  406. /** @defgroup Lock_level
  407. * @{
  408. */
  409. #define TIM_LOCKLevel_OFF ((uint16_t)0x0000)
  410. #define TIM_LOCKLevel_1 ((uint16_t)0x0100)
  411. #define TIM_LOCKLevel_2 ((uint16_t)0x0200)
  412. #define TIM_LOCKLevel_3 ((uint16_t)0x0300)
  413. #define IS_TIM_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM_LOCKLevel_OFF) || \
  414. ((LEVEL) == TIM_LOCKLevel_1) || \
  415. ((LEVEL) == TIM_LOCKLevel_2) || \
  416. ((LEVEL) == TIM_LOCKLevel_3))
  417. /**
  418. * @}
  419. */
  420. /** @defgroup OSSI_Off_State_Selection_for_Idle_mode_state
  421. * @{
  422. */
  423. #define TIM_OSSIState_Enable ((uint16_t)0x0400)
  424. #define TIM_OSSIState_Disable ((uint16_t)0x0000)
  425. #define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSIState_Enable) || \
  426. ((STATE) == TIM_OSSIState_Disable))
  427. /**
  428. * @}
  429. */
  430. /** @defgroup OSSR_Off_State_Selection_for_Run_mode_state
  431. * @{
  432. */
  433. #define TIM_OSSRState_Enable ((uint16_t)0x0800)
  434. #define TIM_OSSRState_Disable ((uint16_t)0x0000)
  435. #define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSRState_Enable) || \
  436. ((STATE) == TIM_OSSRState_Disable))
  437. /**
  438. * @}
  439. */
  440. /** @defgroup TIM_Output_Compare_Idle_State
  441. * @{
  442. */
  443. #define TIM_OCIdleState_Set ((uint16_t)0x0100)
  444. #define TIM_OCIdleState_Reset ((uint16_t)0x0000)
  445. #define IS_TIM_OCIDLE_STATE(STATE) (((STATE) == TIM_OCIdleState_Set) || \
  446. ((STATE) == TIM_OCIdleState_Reset))
  447. /**
  448. * @}
  449. */
  450. /** @defgroup TIM_Output_Compare_N_Idle_State
  451. * @{
  452. */
  453. #define TIM_OCNIdleState_Set ((uint16_t)0x0200)
  454. #define TIM_OCNIdleState_Reset ((uint16_t)0x0000)
  455. #define IS_TIM_OCNIDLE_STATE(STATE) (((STATE) == TIM_OCNIdleState_Set) || \
  456. ((STATE) == TIM_OCNIdleState_Reset))
  457. /**
  458. * @}
  459. */
  460. /** @defgroup TIM_Input_Capture_Polarity
  461. * @{
  462. */
  463. #define TIM_ICPolarity_Rising ((uint16_t)0x0000)
  464. #define TIM_ICPolarity_Falling ((uint16_t)0x0002)
  465. #define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || \
  466. ((POLARITY) == TIM_ICPolarity_Falling))
  467. /**
  468. * @}
  469. */
  470. /** @defgroup TIM_Input_Capture_Selection
  471. * @{
  472. */
  473. #define TIM_ICSelection_DirectTI ((uint16_t)0x0001) /*!< TIM Input 1, 2, 3 or 4 is selected to be
  474. connected to IC1, IC2, IC3 or IC4, respectively */
  475. #define TIM_ICSelection_IndirectTI ((uint16_t)0x0002) /*!< TIM Input 1, 2, 3 or 4 is selected to be
  476. connected to IC2, IC1, IC4 or IC3, respectively. */
  477. #define TIM_ICSelection_TRC ((uint16_t)0x0003) /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to TRC. */
  478. #define IS_TIM_IC_SELECTION(SELECTION) (((SELECTION) == TIM_ICSelection_DirectTI) || \
  479. ((SELECTION) == TIM_ICSelection_IndirectTI) || \
  480. ((SELECTION) == TIM_ICSelection_TRC))
  481. /**
  482. * @}
  483. */
  484. /** @defgroup TIM_Input_Capture_Prescaler
  485. * @{
  486. */
  487. #define TIM_ICPSC_DIV1 ((uint16_t)0x0000) /*!< Capture performed each time an edge is detected on the capture input. */
  488. #define TIM_ICPSC_DIV2 ((uint16_t)0x0004) /*!< Capture performed once every 2 events. */
  489. #define TIM_ICPSC_DIV4 ((uint16_t)0x0008) /*!< Capture performed once every 4 events. */
  490. #define TIM_ICPSC_DIV8 ((uint16_t)0x000C) /*!< Capture performed once every 8 events. */
  491. #define IS_TIM_IC_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ICPSC_DIV1) || \
  492. ((PRESCALER) == TIM_ICPSC_DIV2) || \
  493. ((PRESCALER) == TIM_ICPSC_DIV4) || \
  494. ((PRESCALER) == TIM_ICPSC_DIV8))
  495. /**
  496. * @}
  497. */
  498. /** @defgroup TIM_interrupt_sources
  499. * @{
  500. */
  501. #define TIM_IT_Update ((uint16_t)0x0001)
  502. #define TIM_IT_CC1 ((uint16_t)0x0002)
  503. #define TIM_IT_CC2 ((uint16_t)0x0004)
  504. #define TIM_IT_CC3 ((uint16_t)0x0008)
  505. #define TIM_IT_CC4 ((uint16_t)0x0010)
  506. #define TIM_IT_COM ((uint16_t)0x0020)
  507. #define TIM_IT_Trigger ((uint16_t)0x0040)
  508. #define TIM_IT_Break ((uint16_t)0x0080)
  509. #define IS_TIM_IT(IT) ((((IT) & (uint16_t)0xFF00) == 0x0000) && ((IT) != 0x0000))
  510. #define IS_TIM_GET_IT(IT) (((IT) == TIM_IT_Update) || \
  511. ((IT) == TIM_IT_CC1) || \
  512. ((IT) == TIM_IT_CC2) || \
  513. ((IT) == TIM_IT_CC3) || \
  514. ((IT) == TIM_IT_CC4) || \
  515. ((IT) == TIM_IT_COM) || \
  516. ((IT) == TIM_IT_Trigger) || \
  517. ((IT) == TIM_IT_Break))
  518. /**
  519. * @}
  520. */
  521. /** @defgroup TIM_DMA_Base_address
  522. * @{
  523. */
  524. #define TIM_DMABase_CR1 ((uint16_t)0x0000)
  525. #define TIM_DMABase_CR2 ((uint16_t)0x0001)
  526. #define TIM_DMABase_SMCR ((uint16_t)0x0002)
  527. #define TIM_DMABase_DIER ((uint16_t)0x0003)
  528. #define TIM_DMABase_SR ((uint16_t)0x0004)
  529. #define TIM_DMABase_EGR ((uint16_t)0x0005)
  530. #define TIM_DMABase_CCMR1 ((uint16_t)0x0006)
  531. #define TIM_DMABase_CCMR2 ((uint16_t)0x0007)
  532. #define TIM_DMABase_CCER ((uint16_t)0x0008)
  533. #define TIM_DMABase_CNT ((uint16_t)0x0009)
  534. #define TIM_DMABase_PSC ((uint16_t)0x000A)
  535. #define TIM_DMABase_ARR ((uint16_t)0x000B)
  536. #define TIM_DMABase_RCR ((uint16_t)0x000C)
  537. #define TIM_DMABase_CCR1 ((uint16_t)0x000D)
  538. #define TIM_DMABase_CCR2 ((uint16_t)0x000E)
  539. #define TIM_DMABase_CCR3 ((uint16_t)0x000F)
  540. #define TIM_DMABase_CCR4 ((uint16_t)0x0010)
  541. #define TIM_DMABase_BDTR ((uint16_t)0x0011)
  542. #define TIM_DMABase_DCR ((uint16_t)0x0012)
  543. #define IS_TIM_DMA_BASE(BASE) (((BASE) == TIM_DMABase_CR1) || \
  544. ((BASE) == TIM_DMABase_CR2) || \
  545. ((BASE) == TIM_DMABase_SMCR) || \
  546. ((BASE) == TIM_DMABase_DIER) || \
  547. ((BASE) == TIM_DMABase_SR) || \
  548. ((BASE) == TIM_DMABase_EGR) || \
  549. ((BASE) == TIM_DMABase_CCMR1) || \
  550. ((BASE) == TIM_DMABase_CCMR2) || \
  551. ((BASE) == TIM_DMABase_CCER) || \
  552. ((BASE) == TIM_DMABase_CNT) || \
  553. ((BASE) == TIM_DMABase_PSC) || \
  554. ((BASE) == TIM_DMABase_ARR) || \
  555. ((BASE) == TIM_DMABase_RCR) || \
  556. ((BASE) == TIM_DMABase_CCR1) || \
  557. ((BASE) == TIM_DMABase_CCR2) || \
  558. ((BASE) == TIM_DMABase_CCR3) || \
  559. ((BASE) == TIM_DMABase_CCR4) || \
  560. ((BASE) == TIM_DMABase_BDTR) || \
  561. ((BASE) == TIM_DMABase_DCR))
  562. /**
  563. * @}
  564. */
  565. /** @defgroup TIM_DMA_Burst_Length
  566. * @{
  567. */
  568. #define TIM_DMABurstLength_1Byte ((uint16_t)0x0000)
  569. #define TIM_DMABurstLength_2Bytes ((uint16_t)0x0100)
  570. #define TIM_DMABurstLength_3Bytes ((uint16_t)0x0200)
  571. #define TIM_DMABurstLength_4Bytes ((uint16_t)0x0300)
  572. #define TIM_DMABurstLength_5Bytes ((uint16_t)0x0400)
  573. #define TIM_DMABurstLength_6Bytes ((uint16_t)0x0500)
  574. #define TIM_DMABurstLength_7Bytes ((uint16_t)0x0600)
  575. #define TIM_DMABurstLength_8Bytes ((uint16_t)0x0700)
  576. #define TIM_DMABurstLength_9Bytes ((uint16_t)0x0800)
  577. #define TIM_DMABurstLength_10Bytes ((uint16_t)0x0900)
  578. #define TIM_DMABurstLength_11Bytes ((uint16_t)0x0A00)
  579. #define TIM_DMABurstLength_12Bytes ((uint16_t)0x0B00)
  580. #define TIM_DMABurstLength_13Bytes ((uint16_t)0x0C00)
  581. #define TIM_DMABurstLength_14Bytes ((uint16_t)0x0D00)
  582. #define TIM_DMABurstLength_15Bytes ((uint16_t)0x0E00)
  583. #define TIM_DMABurstLength_16Bytes ((uint16_t)0x0F00)
  584. #define TIM_DMABurstLength_17Bytes ((uint16_t)0x1000)
  585. #define TIM_DMABurstLength_18Bytes ((uint16_t)0x1100)
  586. #define IS_TIM_DMA_LENGTH(LENGTH) (((LENGTH) == TIM_DMABurstLength_1Byte) || \
  587. ((LENGTH) == TIM_DMABurstLength_2Bytes) || \
  588. ((LENGTH) == TIM_DMABurstLength_3Bytes) || \
  589. ((LENGTH) == TIM_DMABurstLength_4Bytes) || \
  590. ((LENGTH) == TIM_DMABurstLength_5Bytes) || \
  591. ((LENGTH) == TIM_DMABurstLength_6Bytes) || \
  592. ((LENGTH) == TIM_DMABurstLength_7Bytes) || \
  593. ((LENGTH) == TIM_DMABurstLength_8Bytes) || \
  594. ((LENGTH) == TIM_DMABurstLength_9Bytes) || \
  595. ((LENGTH) == TIM_DMABurstLength_10Bytes) || \
  596. ((LENGTH) == TIM_DMABurstLength_11Bytes) || \
  597. ((LENGTH) == TIM_DMABurstLength_12Bytes) || \
  598. ((LENGTH) == TIM_DMABurstLength_13Bytes) || \
  599. ((LENGTH) == TIM_DMABurstLength_14Bytes) || \
  600. ((LENGTH) == TIM_DMABurstLength_15Bytes) || \
  601. ((LENGTH) == TIM_DMABurstLength_16Bytes) || \
  602. ((LENGTH) == TIM_DMABurstLength_17Bytes) || \
  603. ((LENGTH) == TIM_DMABurstLength_18Bytes))
  604. /**
  605. * @}
  606. */
  607. /** @defgroup TIM_DMA_sources
  608. * @{
  609. */
  610. #define TIM_DMA_Update ((uint16_t)0x0100)
  611. #define TIM_DMA_CC1 ((uint16_t)0x0200)
  612. #define TIM_DMA_CC2 ((uint16_t)0x0400)
  613. #define TIM_DMA_CC3 ((uint16_t)0x0800)
  614. #define TIM_DMA_CC4 ((uint16_t)0x1000)
  615. #define TIM_DMA_COM ((uint16_t)0x2000)
  616. #define TIM_DMA_Trigger ((uint16_t)0x4000)
  617. #define IS_TIM_DMA_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0x80FF) == 0x0000) && ((SOURCE) != 0x0000))
  618. /**
  619. * @}
  620. */
  621. /** @defgroup TIM_External_Trigger_Prescaler
  622. * @{
  623. */
  624. #define TIM_ExtTRGPSC_OFF ((uint16_t)0x0000)
  625. #define TIM_ExtTRGPSC_DIV2 ((uint16_t)0x1000)
  626. #define TIM_ExtTRGPSC_DIV4 ((uint16_t)0x2000)
  627. #define TIM_ExtTRGPSC_DIV8 ((uint16_t)0x3000)
  628. #define IS_TIM_EXT_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ExtTRGPSC_OFF) || \
  629. ((PRESCALER) == TIM_ExtTRGPSC_DIV2) || \
  630. ((PRESCALER) == TIM_ExtTRGPSC_DIV4) || \
  631. ((PRESCALER) == TIM_ExtTRGPSC_DIV8))
  632. /**
  633. * @}
  634. */
  635. /** @defgroup TIM_Internal_Trigger_Selection
  636. * @{
  637. */
  638. #define TIM_TS_ITR0 ((uint16_t)0x0000)
  639. #define TIM_TS_ITR1 ((uint16_t)0x0010)
  640. #define TIM_TS_ITR2 ((uint16_t)0x0020)
  641. #define TIM_TS_ITR3 ((uint16_t)0x0030)
  642. #define TIM_TS_TI1F_ED ((uint16_t)0x0040)
  643. #define TIM_TS_TI1FP1 ((uint16_t)0x0050)
  644. #define TIM_TS_TI2FP2 ((uint16_t)0x0060)
  645. #define TIM_TS_ETRF ((uint16_t)0x0070)
  646. #define IS_TIM_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
  647. ((SELECTION) == TIM_TS_ITR1) || \
  648. ((SELECTION) == TIM_TS_ITR2) || \
  649. ((SELECTION) == TIM_TS_ITR3) || \
  650. ((SELECTION) == TIM_TS_TI1F_ED) || \
  651. ((SELECTION) == TIM_TS_TI1FP1) || \
  652. ((SELECTION) == TIM_TS_TI2FP2) || \
  653. ((SELECTION) == TIM_TS_ETRF))
  654. #define IS_TIM_INTERNAL_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
  655. ((SELECTION) == TIM_TS_ITR1) || \
  656. ((SELECTION) == TIM_TS_ITR2) || \
  657. ((SELECTION) == TIM_TS_ITR3))
  658. /**
  659. * @}
  660. */
  661. /** @defgroup TIM_TIx_External_Clock_Source
  662. * @{
  663. */
  664. #define TIM_TIxExternalCLK1Source_TI1 ((uint16_t)0x0050)
  665. #define TIM_TIxExternalCLK1Source_TI2 ((uint16_t)0x0060)
  666. #define TIM_TIxExternalCLK1Source_TI1ED ((uint16_t)0x0040)
  667. #define IS_TIM_TIXCLK_SOURCE(SOURCE) (((SOURCE) == TIM_TIxExternalCLK1Source_TI1) || \
  668. ((SOURCE) == TIM_TIxExternalCLK1Source_TI2) || \
  669. ((SOURCE) == TIM_TIxExternalCLK1Source_TI1ED))
  670. /**
  671. * @}
  672. */
  673. /** @defgroup TIM_External_Trigger_Polarity
  674. * @{
  675. */
  676. #define TIM_ExtTRGPolarity_Inverted ((uint16_t)0x8000)
  677. #define TIM_ExtTRGPolarity_NonInverted ((uint16_t)0x0000)
  678. #define IS_TIM_EXT_POLARITY(POLARITY) (((POLARITY) == TIM_ExtTRGPolarity_Inverted) || \
  679. ((POLARITY) == TIM_ExtTRGPolarity_NonInverted))
  680. /**
  681. * @}
  682. */
  683. /** @defgroup TIM_Prescaler_Reload_Mode
  684. * @{
  685. */
  686. #define TIM_PSCReloadMode_Update ((uint16_t)0x0000)
  687. #define TIM_PSCReloadMode_Immediate ((uint16_t)0x0001)
  688. #define IS_TIM_PRESCALER_RELOAD(RELOAD) (((RELOAD) == TIM_PSCReloadMode_Update) || \
  689. ((RELOAD) == TIM_PSCReloadMode_Immediate))
  690. /**
  691. * @}
  692. */
  693. /** @defgroup TIM_Forced_Action
  694. * @{
  695. */
  696. #define TIM_ForcedAction_Active ((uint16_t)0x0050)
  697. #define TIM_ForcedAction_InActive ((uint16_t)0x0040)
  698. #define IS_TIM_FORCED_ACTION(ACTION) (((ACTION) == TIM_ForcedAction_Active) || \
  699. ((ACTION) == TIM_ForcedAction_InActive))
  700. /**
  701. * @}
  702. */
  703. /** @defgroup TIM_Encoder_Mode
  704. * @{
  705. */
  706. #define TIM_EncoderMode_TI1 ((uint16_t)0x0001)
  707. #define TIM_EncoderMode_TI2 ((uint16_t)0x0002)
  708. #define TIM_EncoderMode_TI12 ((uint16_t)0x0003)
  709. #define IS_TIM_ENCODER_MODE(MODE) (((MODE) == TIM_EncoderMode_TI1) || \
  710. ((MODE) == TIM_EncoderMode_TI2) || \
  711. ((MODE) == TIM_EncoderMode_TI12))
  712. /**
  713. * @}
  714. */
  715. /** @defgroup TIM_Event_Source
  716. * @{
  717. */
  718. #define TIM_EventSource_Update ((uint16_t)0x0001)
  719. #define TIM_EventSource_CC1 ((uint16_t)0x0002)
  720. #define TIM_EventSource_CC2 ((uint16_t)0x0004)
  721. #define TIM_EventSource_CC3 ((uint16_t)0x0008)
  722. #define TIM_EventSource_CC4 ((uint16_t)0x0010)
  723. #define TIM_EventSource_COM ((uint16_t)0x0020)
  724. #define TIM_EventSource_Trigger ((uint16_t)0x0040)
  725. #define TIM_EventSource_Break ((uint16_t)0x0080)
  726. #define IS_TIM_EVENT_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0xFF00) == 0x0000) && ((SOURCE) != 0x0000))
  727. /**
  728. * @}
  729. */
  730. /** @defgroup TIM_Update_Source
  731. * @{
  732. */
  733. #define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow
  734. or the setting of UG bit, or an update generation
  735. through the slave mode controller. */
  736. #define TIM_UpdateSource_Regular ((uint16_t)0x0001) /*!< Source of update is counter overflow/underflow. */
  737. #define IS_TIM_UPDATE_SOURCE(SOURCE) (((SOURCE) == TIM_UpdateSource_Global) || \
  738. ((SOURCE) == TIM_UpdateSource_Regular))
  739. /**
  740. * @}
  741. */
  742. /** @defgroup TIM_Ouput_Compare_Preload_State
  743. * @{
  744. */
  745. #define TIM_OCPreload_Enable ((uint16_t)0x0008)
  746. #define TIM_OCPreload_Disable ((uint16_t)0x0000)
  747. #define IS_TIM_OCPRELOAD_STATE(STATE) (((STATE) == TIM_OCPreload_Enable) || \
  748. ((STATE) == TIM_OCPreload_Disable))
  749. /**
  750. * @}
  751. */
  752. /** @defgroup TIM_Ouput_Compare_Fast_State
  753. * @{
  754. */
  755. #define TIM_OCFast_Enable ((uint16_t)0x0004)
  756. #define TIM_OCFast_Disable ((uint16_t)0x0000)
  757. #define IS_TIM_OCFAST_STATE(STATE) (((STATE) == TIM_OCFast_Enable) || \
  758. ((STATE) == TIM_OCFast_Disable))
  759. /**
  760. * @}
  761. */
  762. /** @defgroup TIM_Ouput_Compare_Clear_State
  763. * @{
  764. */
  765. #define TIM_OCClear_Enable ((uint16_t)0x0080)
  766. #define TIM_OCClear_Disable ((uint16_t)0x0000)
  767. #define IS_TIM_OCCLEAR_STATE(STATE) (((STATE) == TIM_OCClear_Enable) || \
  768. ((STATE) == TIM_OCClear_Disable))
  769. /**
  770. * @}
  771. */
  772. /** @defgroup TIM_Trigger_Output_Source
  773. * @{
  774. */
  775. #define TIM_TRGOSource_Reset ((uint16_t)0x0000)
  776. #define TIM_TRGOSource_Enable ((uint16_t)0x0010)
  777. #define TIM_TRGOSource_Update ((uint16_t)0x0020)
  778. #define TIM_TRGOSource_OC1 ((uint16_t)0x0030)
  779. #define TIM_TRGOSource_OC1Ref ((uint16_t)0x0040)
  780. #define TIM_TRGOSource_OC2Ref ((uint16_t)0x0050)
  781. #define TIM_TRGOSource_OC3Ref ((uint16_t)0x0060)
  782. #define TIM_TRGOSource_OC4Ref ((uint16_t)0x0070)
  783. #define IS_TIM_TRGO_SOURCE(SOURCE) (((SOURCE) == TIM_TRGOSource_Reset) || \
  784. ((SOURCE) == TIM_TRGOSource_Enable) || \
  785. ((SOURCE) == TIM_TRGOSource_Update) || \
  786. ((SOURCE) == TIM_TRGOSource_OC1) || \
  787. ((SOURCE) == TIM_TRGOSource_OC1Ref) || \
  788. ((SOURCE) == TIM_TRGOSource_OC2Ref) || \
  789. ((SOURCE) == TIM_TRGOSource_OC3Ref) || \
  790. ((SOURCE) == TIM_TRGOSource_OC4Ref))
  791. /**
  792. * @}
  793. */
  794. /** @defgroup TIM_Slave_Mode
  795. * @{
  796. */
  797. #define TIM_SlaveMode_Reset ((uint16_t)0x0004)
  798. #define TIM_SlaveMode_Gated ((uint16_t)0x0005)
  799. #define TIM_SlaveMode_Trigger ((uint16_t)0x0006)
  800. #define TIM_SlaveMode_External1 ((uint16_t)0x0007)
  801. #define IS_TIM_SLAVE_MODE(MODE) (((MODE) == TIM_SlaveMode_Reset) || \
  802. ((MODE) == TIM_SlaveMode_Gated) || \
  803. ((MODE) == TIM_SlaveMode_Trigger) || \
  804. ((MODE) == TIM_SlaveMode_External1))
  805. /**
  806. * @}
  807. */
  808. /** @defgroup TIM_Master_Slave_Mode
  809. * @{
  810. */
  811. #define TIM_MasterSlaveMode_Enable ((uint16_t)0x0080)
  812. #define TIM_MasterSlaveMode_Disable ((uint16_t)0x0000)
  813. #define IS_TIM_MSM_STATE(STATE) (((STATE) == TIM_MasterSlaveMode_Enable) || \
  814. ((STATE) == TIM_MasterSlaveMode_Disable))
  815. /**
  816. * @}
  817. */
  818. /** @defgroup TIM_Flags
  819. * @{
  820. */
  821. #define TIM_FLAG_Update ((uint16_t)0x0001)
  822. #define TIM_FLAG_CC1 ((uint16_t)0x0002)
  823. #define TIM_FLAG_CC2 ((uint16_t)0x0004)
  824. #define TIM_FLAG_CC3 ((uint16_t)0x0008)
  825. #define TIM_FLAG_CC4 ((uint16_t)0x0010)
  826. #define TIM_FLAG_COM ((uint16_t)0x0020)
  827. #define TIM_FLAG_Trigger ((uint16_t)0x0040)
  828. #define TIM_FLAG_Break ((uint16_t)0x0080)
  829. #define TIM_FLAG_CC1OF ((uint16_t)0x0200)
  830. #define TIM_FLAG_CC2OF ((uint16_t)0x0400)
  831. #define TIM_FLAG_CC3OF ((uint16_t)0x0800)
  832. #define TIM_FLAG_CC4OF ((uint16_t)0x1000)
  833. #define IS_TIM_GET_FLAG(FLAG) (((FLAG) == TIM_FLAG_Update) || \
  834. ((FLAG) == TIM_FLAG_CC1) || \
  835. ((FLAG) == TIM_FLAG_CC2) || \
  836. ((FLAG) == TIM_FLAG_CC3) || \
  837. ((FLAG) == TIM_FLAG_CC4) || \
  838. ((FLAG) == TIM_FLAG_COM) || \
  839. ((FLAG) == TIM_FLAG_Trigger) || \
  840. ((FLAG) == TIM_FLAG_Break) || \
  841. ((FLAG) == TIM_FLAG_CC1OF) || \
  842. ((FLAG) == TIM_FLAG_CC2OF) || \
  843. ((FLAG) == TIM_FLAG_CC3OF) || \
  844. ((FLAG) == TIM_FLAG_CC4OF))
  845. #define IS_TIM_CLEAR_FLAG(TIM_FLAG) ((((TIM_FLAG) & (uint16_t)0xE100) == 0x0000) && ((TIM_FLAG) != 0x0000))
  846. /**
  847. * @}
  848. */
  849. /** @defgroup TIM_Input_Capture_Filer_Value
  850. * @{
  851. */
  852. #define IS_TIM_IC_FILTER(ICFILTER) ((ICFILTER) <= 0xF)
  853. /**
  854. * @}
  855. */
  856. /** @defgroup TIM_External_Trigger_Filter
  857. * @{
  858. */
  859. #define IS_TIM_EXT_FILTER(EXTFILTER) ((EXTFILTER) <= 0xF)
  860. /**
  861. * @}
  862. */
  863. /**
  864. * @}
  865. */
  866. /** @defgroup TIM_Exported_Macros
  867. * @{
  868. */
  869. /**
  870. * @}
  871. */
  872. /** @defgroup TIM_Exported_Functions
  873. * @{
  874. */
  875. void TIM_DeInit(TIM_TypeDef* TIMx);
  876. void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct);
  877. void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
  878. void TIM_OC2Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
  879. void TIM_OC3Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
  880. void TIM_OC4Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
  881. void TIM_ICInit(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct);
  882. void TIM_PWMIConfig(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct);
  883. void TIM_BDTRConfig(TIM_TypeDef* TIMx, TIM_BDTRInitTypeDef *TIM_BDTRInitStruct);
  884. void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct);
  885. void TIM_OCStructInit(TIM_OCInitTypeDef* TIM_OCInitStruct);
  886. void TIM_ICStructInit(TIM_ICInitTypeDef* TIM_ICInitStruct);
  887. void TIM_BDTRStructInit(TIM_BDTRInitTypeDef* TIM_BDTRInitStruct);
  888. void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState);
  889. void TIM_CtrlPWMOutputs(TIM_TypeDef* TIMx, FunctionalState NewState);
  890. void TIM_ITConfig(TIM_TypeDef* TIMx, uint16_t TIM_IT, FunctionalState NewState);
  891. void TIM_GenerateEvent(TIM_TypeDef* TIMx, uint16_t TIM_EventSource);
  892. void TIM_DMAConfig(TIM_TypeDef* TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength);
  893. void TIM_DMACmd(TIM_TypeDef* TIMx, uint16_t TIM_DMASource, FunctionalState NewState);
  894. void TIM_InternalClockConfig(TIM_TypeDef* TIMx);
  895. void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource);
  896. void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_TIxExternalCLKSource,
  897. uint16_t TIM_ICPolarity, uint16_t ICFilter);
  898. void TIM_ETRClockMode1Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
  899. uint16_t ExtTRGFilter);
  900. void TIM_ETRClockMode2Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler,
  901. uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter);
  902. void TIM_ETRConfig(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
  903. uint16_t ExtTRGFilter);
  904. void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode);
  905. void TIM_CounterModeConfig(TIM_TypeDef* TIMx, uint16_t TIM_CounterMode);
  906. void TIM_SelectInputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource);
  907. void TIM_EncoderInterfaceConfig(TIM_TypeDef* TIMx, uint16_t TIM_EncoderMode,
  908. uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity);
  909. void TIM_ForcedOC1Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
  910. void TIM_ForcedOC2Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
  911. void TIM_ForcedOC3Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
  912. void TIM_ForcedOC4Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
  913. void TIM_ARRPreloadConfig(TIM_TypeDef* TIMx, FunctionalState NewState);
  914. void TIM_SelectCOM(TIM_TypeDef* TIMx, FunctionalState NewState);
  915. void TIM_SelectCCDMA(TIM_TypeDef* TIMx, FunctionalState NewState);
  916. void TIM_CCPreloadControl(TIM_TypeDef* TIMx, FunctionalState NewState);
  917. void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
  918. void TIM_OC2PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
  919. void TIM_OC3PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
  920. void TIM_OC4PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
  921. void TIM_OC1FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
  922. void TIM_OC2FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
  923. void TIM_OC3FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
  924. void TIM_OC4FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
  925. void TIM_ClearOC1Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
  926. void TIM_ClearOC2Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
  927. void TIM_ClearOC3Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
  928. void TIM_ClearOC4Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
  929. void TIM_OC1PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
  930. void TIM_OC1NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity);
  931. void TIM_OC2PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
  932. void TIM_OC2NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity);
  933. void TIM_OC3PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
  934. void TIM_OC3NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity);
  935. void TIM_OC4PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
  936. void TIM_CCxCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx);
  937. void TIM_CCxNCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN);
  938. void TIM_SelectOCxM(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode);
  939. void TIM_UpdateDisableConfig(TIM_TypeDef* TIMx, FunctionalState NewState);
  940. void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource);
  941. void TIM_SelectHallSensor(TIM_TypeDef* TIMx, FunctionalState NewState);
  942. void TIM_SelectOnePulseMode(TIM_TypeDef* TIMx, uint16_t TIM_OPMode);
  943. void TIM_SelectOutputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_TRGOSource);
  944. void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_SlaveMode);
  945. void TIM_SelectMasterSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_MasterSlaveMode);
  946. void TIM_SetCounter(TIM_TypeDef* TIMx, uint16_t Counter);
  947. void TIM_SetAutoreload(TIM_TypeDef* TIMx, uint16_t Autoreload);
  948. void TIM_SetCompare1(TIM_TypeDef* TIMx, uint16_t Compare1);
  949. void TIM_SetCompare2(TIM_TypeDef* TIMx, uint16_t Compare2);
  950. void TIM_SetCompare3(TIM_TypeDef* TIMx, uint16_t Compare3);
  951. void TIM_SetCompare4(TIM_TypeDef* TIMx, uint16_t Compare4);
  952. void TIM_SetIC1Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
  953. void TIM_SetIC2Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
  954. void TIM_SetIC3Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
  955. void TIM_SetIC4Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
  956. void TIM_SetClockDivision(TIM_TypeDef* TIMx, uint16_t TIM_CKD);
  957. uint16_t TIM_GetCapture1(TIM_TypeDef* TIMx);
  958. uint16_t TIM_GetCapture2(TIM_TypeDef* TIMx);
  959. uint16_t TIM_GetCapture3(TIM_TypeDef* TIMx);
  960. uint16_t TIM_GetCapture4(TIM_TypeDef* TIMx);
  961. uint16_t TIM_GetCounter(TIM_TypeDef* TIMx);
  962. uint16_t TIM_GetPrescaler(TIM_TypeDef* TIMx);
  963. FlagStatus TIM_GetFlagStatus(TIM_TypeDef* TIMx, uint16_t TIM_FLAG);
  964. void TIM_ClearFlag(TIM_TypeDef* TIMx, uint16_t TIM_FLAG);
  965. ITStatus TIM_GetITStatus(TIM_TypeDef* TIMx, uint16_t TIM_IT);
  966. void TIM_ClearITPendingBit(TIM_TypeDef* TIMx, uint16_t TIM_IT);
  967. #ifdef __cplusplus
  968. }
  969. #endif
  970. #endif /*__STM32F10x_TIM_H */
  971. /**
  972. * @}
  973. */
  974. /**
  975. * @}
  976. */
  977. /**
  978. * @}
  979. */
  980. /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/