stm8l15x_tim5.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. /**
  2. ******************************************************************************
  3. * @file stm8l15x_tim5.h
  4. * @author MCD Application Team
  5. * @version V1.6.1
  6. * @date 30-September-2014
  7. * @brief This file contains all the functions prototypes for the TIM5 firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM8L15x_TIM5_H
  30. #define __STM8L15x_TIM5_H
  31. /* Includes ------------------------------------------------------------------*/
  32. #include "stm8l15x.h"
  33. /** @addtogroup STM8L15x_StdPeriph_Driver
  34. * @{
  35. */
  36. /** @addtogroup TIM5
  37. * @{
  38. */
  39. /* Exported types ------------------------------------------------------------*/
  40. /** @defgroup TIM5_Exported_Types
  41. * @{
  42. */
  43. /** @defgroup TIM5_Forced_Action
  44. * @{
  45. */
  46. typedef enum
  47. {
  48. TIM5_ForcedAction_Active = ((uint8_t)0x50), /*!< Output Reference is forced low */
  49. TIM5_ForcedAction_Inactive = ((uint8_t)0x40) /*!< Output Reference is forced high */
  50. }
  51. TIM5_ForcedAction_TypeDef;
  52. #define IS_TIM5_FORCED_ACTION(ACTION) (((ACTION) == TIM5_ForcedAction_Active) || \
  53. ((ACTION) == TIM5_ForcedAction_Inactive))
  54. /**
  55. * @}
  56. */
  57. /** @defgroup TIM5_Prescaler
  58. * @{
  59. */
  60. typedef enum
  61. {
  62. TIM5_Prescaler_1 = ((uint8_t)0x00), /*!< Time base Prescaler = 1 (No effect)*/
  63. TIM5_Prescaler_2 = ((uint8_t)0x01), /*!< Time base Prescaler = 2 */
  64. TIM5_Prescaler_4 = ((uint8_t)0x02), /*!< Time base Prescaler = 4 */
  65. TIM5_Prescaler_8 = ((uint8_t)0x03), /*!< Time base Prescaler = 8 */
  66. TIM5_Prescaler_16 = ((uint8_t)0x04), /*!< Time base Prescaler = 16 */
  67. TIM5_Prescaler_32 = ((uint8_t)0x05), /*!< Time base Prescaler = 32 */
  68. TIM5_Prescaler_64 = ((uint8_t)0x06), /*!< Time base Prescaler = 64 */
  69. TIM5_Prescaler_128 = ((uint8_t)0x07) /*!< Time base Prescaler = 128 */
  70. }TIM5_Prescaler_TypeDef;
  71. #define IS_TIM5_PRESCALER(PRESCALER) (((PRESCALER) == TIM5_Prescaler_1) || \
  72. ((PRESCALER) == TIM5_Prescaler_2) || \
  73. ((PRESCALER) == TIM5_Prescaler_4) || \
  74. ((PRESCALER) == TIM5_Prescaler_8) || \
  75. ((PRESCALER) == TIM5_Prescaler_16) || \
  76. ((PRESCALER) == TIM5_Prescaler_32) || \
  77. ((PRESCALER) == TIM5_Prescaler_64) || \
  78. ((PRESCALER) == TIM5_Prescaler_128))
  79. /**
  80. * @}
  81. */
  82. /** @defgroup TIM5_OCMode
  83. * @{
  84. */
  85. typedef enum
  86. {
  87. TIM5_OCMode_Timing = ((uint8_t)0x00), /*!< Timing (Frozen) Mode*/
  88. TIM5_OCMode_Active = ((uint8_t)0x10), /*!< Active Mode*/
  89. TIM5_OCMode_Inactive = ((uint8_t)0x20), /*!< Inactive Mode*/
  90. TIM5_OCMode_Toggle = ((uint8_t)0x30), /*!< Toggle Mode*/
  91. TIM5_OCMode_PWM1 = ((uint8_t)0x60), /*!< PWM Mode 1*/
  92. TIM5_OCMode_PWM2 = ((uint8_t)0x70) /*!< PWM Mode 2*/
  93. }TIM5_OCMode_TypeDef;
  94. #define IS_TIM5_OC_MODE(MODE) (((MODE) == TIM5_OCMode_Timing) || \
  95. ((MODE) == TIM5_OCMode_Active) || \
  96. ((MODE) == TIM5_OCMode_Inactive) || \
  97. ((MODE) == TIM5_OCMode_Toggle) || \
  98. ((MODE) == TIM5_OCMode_PWM1) || \
  99. ((MODE) == TIM5_OCMode_PWM2))
  100. #define IS_TIM5_OCM(MODE) (((MODE) == TIM5_OCMode_Timing) || \
  101. ((MODE) == TIM5_OCMode_Active) || \
  102. ((MODE) == TIM5_OCMode_Inactive) || \
  103. ((MODE) == TIM5_OCMode_Toggle) || \
  104. ((MODE) == TIM5_OCMode_PWM1) || \
  105. ((MODE) == TIM5_OCMode_PWM2) || \
  106. ((MODE) == (uint8_t)TIM5_ForcedAction_Active) || \
  107. ((MODE) == (uint8_t)TIM5_ForcedAction_Inactive))
  108. /**
  109. * @}
  110. */
  111. /** @defgroup TIM5_OnePulseMode
  112. * @{
  113. */
  114. typedef enum
  115. {
  116. TIM5_OPMode_Single = ((uint8_t)0x01), /*!< Single one Pulse mode (OPM Active) */
  117. TIM5_OPMode_Repetitive = ((uint8_t)0x00) /*!< Repetitive Pulse mode (OPM inactive) */
  118. }TIM5_OPMode_TypeDef;
  119. #define IS_TIM5_OPM_MODE(MODE) (((MODE) == TIM5_OPMode_Single) || \
  120. ((MODE) == TIM5_OPMode_Repetitive))
  121. /**
  122. * @}
  123. */
  124. /** @defgroup TIM5_Channel
  125. * @{
  126. */
  127. typedef enum
  128. {
  129. TIM5_Channel_1 = ((uint8_t)0x00), /*!< Channel 1*/
  130. TIM5_Channel_2 = ((uint8_t)0x01) /*!< Channel 2*/
  131. }TIM5_Channel_TypeDef;
  132. #define IS_TIM5_CHANNEL(CHANNEL) (((CHANNEL) == TIM5_Channel_1) || \
  133. ((CHANNEL) == TIM5_Channel_2) )
  134. /**
  135. * @}
  136. */
  137. /** @defgroup TIM5_CounterMode
  138. * @{
  139. */
  140. typedef enum
  141. {
  142. TIM5_CounterMode_Up = ((uint8_t)0x00), /*!< Counter Up Mode */
  143. TIM5_CounterMode_Down = ((uint8_t)0x10), /*!< Counter Down Mode */
  144. TIM5_CounterMode_CenterAligned1 = ((uint8_t)0x20), /*!< Counter Central aligned Mode 1 */
  145. TIM5_CounterMode_CenterAligned2 = ((uint8_t)0x40), /*!< Counter Central aligned Mode 2 */
  146. TIM5_CounterMode_CenterAligned3 = ((uint8_t)0x60) /*!< Counter Central aligned Mode 3 */
  147. }TIM5_CounterMode_TypeDef;
  148. #define IS_TIM5_COUNTER_MODE(MODE) (((MODE) == TIM5_CounterMode_Up) || \
  149. ((MODE) == TIM5_CounterMode_Down) || \
  150. ((MODE) == TIM5_CounterMode_CenterAligned1) || \
  151. ((MODE) == TIM5_CounterMode_CenterAligned2) || \
  152. ((MODE) == TIM5_CounterMode_CenterAligned3))
  153. /**
  154. * @}
  155. */
  156. /** @defgroup TIM5_Output_Compare_Polarity
  157. * @{
  158. */
  159. typedef enum
  160. {
  161. TIM5_OCPolarity_High = ((uint8_t)0x00), /*!< Output compare polarity = High */
  162. TIM5_OCPolarity_Low = ((uint8_t)0x01) /*!< Output compare polarity = Low */
  163. }TIM5_OCPolarity_TypeDef;
  164. #define IS_TIM5_OC_POLARITY(POLARITY) (((POLARITY) == TIM5_OCPolarity_High) || \
  165. ((POLARITY) == TIM5_OCPolarity_Low))
  166. /**
  167. * @}
  168. */
  169. /** @defgroup TIM5_Output_State
  170. * @{
  171. */
  172. typedef enum
  173. {
  174. TIM5_OutputState_Disable = ((uint8_t)0x00), /*!< Output compare State disabled (channel output disabled) */
  175. TIM5_OutputState_Enable = ((uint8_t)0x01) /*!< Output compare State enabled (channel output enabled) */
  176. }TIM5_OutputState_TypeDef;
  177. #define IS_TIM5_OUTPUT_STATE(STATE) (((STATE) == TIM5_OutputState_Disable) || \
  178. ((STATE) == TIM5_OutputState_Enable))
  179. /**
  180. * @}
  181. */
  182. /** @defgroup TIM5_Break_State
  183. * @{
  184. */
  185. typedef enum
  186. {
  187. TIM5_BreakState_Disable = ((uint8_t)0x00), /*!< Break State disabled (break option disabled) */
  188. TIM5_BreakState_Enable = ((uint8_t)0x10) /*!< Break State enabled (break option enabled) */
  189. }TIM5_BreakState_TypeDef;
  190. #define IS_TIM5_BREAK_STATE(STATE) (((STATE) == TIM5_BreakState_Enable) || \
  191. ((STATE) == TIM5_BreakState_Disable))
  192. /**
  193. * @}
  194. */
  195. /** @defgroup TIM5_Break_Polarity
  196. * @{
  197. */
  198. typedef enum
  199. {
  200. TIM5_BreakPolarity_High = ((uint8_t)0x20), /*!< if Break, channel polarity = High */
  201. TIM5_BreakPolarity_Low = ((uint8_t)0x00) /*!< if Break, channel polarity = Low */
  202. }TIM5_BreakPolarity_TypeDef;
  203. #define IS_TIM5_BREAK_POLARITY(POLARITY) \
  204. (((POLARITY) == TIM5_BreakPolarity_Low) || \
  205. ((POLARITY) == TIM5_BreakPolarity_High))
  206. /**
  207. * @}
  208. */
  209. /** @defgroup TIM5_Automatic_Output
  210. * @{
  211. */
  212. typedef enum
  213. {
  214. TIM5_AutomaticOutput_Enable = ((uint8_t)0x40), /*!< Automatic Output option enabled */
  215. TIM5_AutomaticOutput_Disable = ((uint8_t)0x00) /*!< Automatic Output option disabled */
  216. }TIM5_AutomaticOutput_TypeDef;
  217. #define IS_TIM5_AUTOMATIC_OUTPUT_STATE(STATE) \
  218. (((STATE) == TIM5_AutomaticOutput_Enable) || \
  219. ((STATE) == TIM5_AutomaticOutput_Disable))
  220. /**
  221. * @}
  222. */
  223. /** @defgroup TIM5_Lock_Level
  224. * @{
  225. */
  226. typedef enum
  227. {
  228. TIM5_LockLevel_Off = ((uint8_t)0x00), /*!< Lock option disabled */
  229. TIM5_LockLevel_1 = ((uint8_t)0x01), /*!< Select Lock Level 1 */
  230. TIM5_LockLevel_2 = ((uint8_t)0x02), /*!< Select Lock Level 2 */
  231. TIM5_LockLevel_3 = ((uint8_t)0x03) /*!< Select Lock Level 3 */
  232. }TIM5_LockLevel_TypeDef;
  233. #define IS_TIM5_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM5_LockLevel_Off) || \
  234. ((LEVEL) == TIM5_LockLevel_1) || \
  235. ((LEVEL) == TIM5_LockLevel_2) || \
  236. ((LEVEL) == TIM5_LockLevel_3))
  237. /**
  238. * @}
  239. */
  240. /** @defgroup TIM5_OSSI_State
  241. * @{
  242. */
  243. typedef enum
  244. {
  245. TIM5_OSSIState_Enable = ((uint8_t)0x04), /*!< Off-State Selection for Idle mode enabled */
  246. TIM5_OSSIState_Disable = ((uint8_t)0x00) /*!< Off-State Selection for Idle mode disabled */
  247. }TIM5_OSSIState_TypeDef;
  248. #define IS_TIM5_OSSI_STATE(STATE) \
  249. (((STATE) == TIM5_OSSIState_Enable) || \
  250. ((STATE) == TIM5_OSSIState_Disable))
  251. /**
  252. * @}
  253. */
  254. /** @defgroup TIM5_Output_Compare_Idle_state
  255. * @{
  256. */
  257. typedef enum
  258. {
  259. TIM5_OCIdleState_Reset = ((uint8_t)0x00), /*!< Output Compare Idle state = Reset */
  260. TIM5_OCIdleState_Set = ((uint8_t)0x01) /*!< Output Compare Idle state = Set */
  261. }TIM5_OCIdleState_TypeDef;
  262. #define IS_TIM5_OCIDLE_STATE(STATE) \
  263. (((STATE) == TIM5_OCIdleState_Set) || \
  264. ((STATE) == TIM5_OCIdleState_Reset))
  265. /**
  266. * @}
  267. */
  268. /** @defgroup TIM5_Input_Capture_Polarity
  269. * @{
  270. */
  271. typedef enum
  272. {
  273. TIM5_ICPolarity_Rising = ((uint8_t)0x00), /*!< Input Capture on Rising Edge*/
  274. TIM5_ICPolarity_Falling = ((uint8_t)0x01) /*!< Input Capture on Falling Edge*/
  275. }TIM5_ICPolarity_TypeDef;
  276. #define IS_TIM5_IC_POLARITY(POLARITY) \
  277. (((POLARITY) == TIM5_ICPolarity_Rising) || \
  278. ((POLARITY) == TIM5_ICPolarity_Falling))
  279. /**
  280. * @}
  281. */
  282. /** @defgroup TIM5_Input_Capture_Selection
  283. * @{
  284. */
  285. typedef enum
  286. {
  287. TIM5_ICSelection_DirectTI = ((uint8_t)0x01), /*!< Input Capture mapped on the direct input*/
  288. TIM5_ICSelection_IndirectTI = ((uint8_t)0x02), /*!< Input Capture mapped on the indirect input*/
  289. TIM5_ICSelection_TRGI = ((uint8_t)0x03) /*!< Input Capture mapped on the Trigger Input*/
  290. }TIM5_ICSelection_TypeDef;
  291. #define IS_TIM5_IC_SELECTION(SELECTION) \
  292. (((SELECTION) == TIM5_ICSelection_DirectTI) || \
  293. ((SELECTION) == TIM5_ICSelection_IndirectTI) || \
  294. ((SELECTION) == TIM5_ICSelection_TRGI))
  295. /**
  296. * @}
  297. */
  298. /** @defgroup TIM5_Input_Capture_Prescaler
  299. * @{
  300. */
  301. typedef enum
  302. {
  303. TIM5_ICPSC_DIV1 = ((uint8_t)0x00), /*!< Input Capture Prescaler = 1 (one capture every 1 event) */
  304. TIM5_ICPSC_DIV2 = ((uint8_t)0x04), /*!< Input Capture Prescaler = 2 (one capture every 2 events) */
  305. TIM5_ICPSC_DIV4 = ((uint8_t)0x08), /*!< Input Capture Prescaler = 4 (one capture every 4 events) */
  306. TIM5_ICPSC_DIV8 = ((uint8_t)0x0C) /*!< Input Capture Prescaler = 8 (one capture every 8 events) */
  307. }TIM5_ICPSC_TypeDef;
  308. #define IS_TIM5_IC_PRESCALER(PRESCALER) \
  309. (((PRESCALER) == TIM5_ICPSC_DIV1) || \
  310. ((PRESCALER) == TIM5_ICPSC_DIV2) || \
  311. ((PRESCALER) == TIM5_ICPSC_DIV4) || \
  312. ((PRESCALER) == TIM5_ICPSC_DIV8))
  313. /**
  314. * @}
  315. */
  316. /** @defgroup TIM5_Interrupts
  317. * @{
  318. */
  319. typedef enum
  320. {
  321. TIM5_IT_Update = ((uint8_t)0x01), /*!< Update Interrupt*/
  322. TIM5_IT_CC1 = ((uint8_t)0x02), /*!< Capture Compare Channel1 Interrupt*/
  323. TIM5_IT_CC2 = ((uint8_t)0x04), /*!< Capture Compare Channel2 Interrupt*/
  324. TIM5_IT_Trigger = ((uint8_t)0x40), /*!< Trigger Interrupt*/
  325. TIM5_IT_Break = ((uint8_t)0x80) /*!< Break Interrupt*/
  326. }TIM5_IT_TypeDef;
  327. #define IS_TIM5_IT(IT) \
  328. ((IT) != 0x00)
  329. #define IS_TIM5_GET_IT(IT) \
  330. (((IT) == TIM5_IT_Update) || \
  331. ((IT) == TIM5_IT_CC1) || \
  332. ((IT) == TIM5_IT_CC2) || \
  333. ((IT) == TIM5_IT_Trigger) || \
  334. ((IT) == TIM5_IT_Break))
  335. /**
  336. * @}
  337. */
  338. /** @defgroup TIM5_External_Trigger_Prescaler
  339. * @{
  340. */
  341. typedef enum
  342. {
  343. TIM5_ExtTRGPSC_OFF = ((uint8_t)0x00), /*!< No External Trigger prescaler */
  344. TIM5_ExtTRGPSC_DIV2 = ((uint8_t)0x10), /*!< External Trigger prescaler = 2 (ETRP frequency divided by 2) */
  345. TIM5_ExtTRGPSC_DIV4 = ((uint8_t)0x20), /*!< External Trigger prescaler = 4 (ETRP frequency divided by 4) */
  346. TIM5_ExtTRGPSC_DIV8 = ((uint8_t)0x30) /*!< External Trigger prescaler = 8 (ETRP frequency divided by 8) */
  347. }TIM5_ExtTRGPSC_TypeDef;
  348. #define IS_TIM5_EXT_PRESCALER(PRESCALER) \
  349. (((PRESCALER) == TIM5_ExtTRGPSC_OFF) || \
  350. ((PRESCALER) == TIM5_ExtTRGPSC_DIV2) || \
  351. ((PRESCALER) == TIM5_ExtTRGPSC_DIV4) || \
  352. ((PRESCALER) == TIM5_ExtTRGPSC_DIV8))
  353. /**
  354. * @}
  355. */
  356. /** @defgroup TIM5_Internal_Trigger_Selection
  357. * @{
  358. */
  359. typedef enum
  360. {
  361. TIM5_TRGSelection_TIM4 = ((uint8_t)0x00), /*!< TRIG Input source = TIM TRIG Output */
  362. TIM5_TRGSelection_TIM1 = ((uint8_t)0x10), /*!< TRIG Input source = TIM TRIG Output */
  363. TIM5_TRGSelection_TIM3 = ((uint8_t)0x20), /*!< TRIG Input source = TIM TRIG Output */
  364. TIM5_TRGSelection_TIM2 = ((uint8_t)0x30), /*!< TRIG Input source = TIM TRIG Output */
  365. TIM5_TRGSelection_TI1F_ED = ((uint8_t)0x40), /*!< TRIG Input source = TI1F_ED (TI1 Edge Detector) */
  366. TIM5_TRGSelection_TI1FP1 = ((uint8_t)0x50), /*!< TRIG Input source = TI1FP1 (Filtered Timer Input 1) */
  367. TIM5_TRGSelection_TI2FP2 = ((uint8_t)0x60), /*!< TRIG Input source = TI2FP2 (Filtered Timer Input 2) */
  368. TIM5_TRGSelection_ETRF = ((uint8_t)0x70) /*!< TRIG Input source = ETRF (External Trigger Input ) */
  369. }TIM5_TRGSelection_TypeDef;
  370. #define IS_TIM5_TRIGGER_SELECTION(SELECTION) \
  371. (((SELECTION) == TIM5_TRGSelection_TIM4) || \
  372. ((SELECTION) == TIM5_TRGSelection_TIM1) || \
  373. ((SELECTION) == TIM5_TRGSelection_TIM3) || \
  374. ((SELECTION) == TIM5_TRGSelection_TIM2) || \
  375. ((SELECTION) == TIM5_TRGSelection_TI1F_ED) || \
  376. ((SELECTION) == TIM5_TRGSelection_TI1FP1) || \
  377. ((SELECTION) == TIM5_TRGSelection_TI2FP2) || \
  378. ((SELECTION) == TIM5_TRGSelection_ETRF))
  379. #define IS_TIM5_TIX_TRIGGER_SELECTION(SELECTION) \
  380. (((SELECTION) == TIM5_TRGSelection_TI1F_ED) || \
  381. ((SELECTION) == TIM5_TRGSelection_TI1FP1) || \
  382. ((SELECTION) == TIM5_TRGSelection_TI2FP2))
  383. /**
  384. * @}
  385. */
  386. /** @defgroup TIM5_TI_External_Clock_Source
  387. * @{
  388. */
  389. typedef enum
  390. {
  391. TIM5_TIxExternalCLK1Source_TI1ED = ((uint8_t)0x40), /*!< External Clock mode 1 source = TI1ED */
  392. TIM5_TIxExternalCLK1Source_TI1 = ((uint8_t)0x50), /*!< External Clock mode 1 source = TI1 */
  393. TIM5_TIxExternalCLK1Source_TI2 = ((uint8_t)0x60) /*!< External Clock mode 1 source = TI2 */
  394. }TIM5_TIxExternalCLK1Source_TypeDef;
  395. #define IS_TIM5_TIXCLK_SOURCE(SOURCE) \
  396. (((SOURCE) == TIM5_TIxExternalCLK1Source_TI1ED) || \
  397. ((SOURCE) == TIM5_TIxExternalCLK1Source_TI2) || \
  398. ((SOURCE) == TIM5_TIxExternalCLK1Source_TI1))
  399. /**
  400. * @}
  401. */
  402. /** @defgroup TIM5_External_Trigger_Polarity
  403. * @{
  404. */
  405. typedef enum
  406. {
  407. TIM5_ExtTRGPolarity_Inverted = ((uint8_t)0x80), /*!< External Trigger Polarity = inverted */
  408. TIM5_ExtTRGPolarity_NonInverted = ((uint8_t)0x00) /*!< External Trigger Polarity = non inverted */
  409. }TIM5_ExtTRGPolarity_TypeDef;
  410. #define IS_TIM5_EXT_POLARITY(POLARITY) \
  411. (((POLARITY) == TIM5_ExtTRGPolarity_Inverted) || \
  412. ((POLARITY) == TIM5_ExtTRGPolarity_NonInverted))
  413. /**
  414. * @}
  415. */
  416. /** @defgroup TIM5_Prescaler_Reload_Mode
  417. * @{
  418. */
  419. typedef enum
  420. {
  421. TIM5_PSCReloadMode_Update = ((uint8_t)0x00), /*!< Prescaler value is reloaded at every update*/
  422. TIM5_PSCReloadMode_Immediate = ((uint8_t)0x01) /*!< Prescaler value is reloaded immediatly*/
  423. }TIM5_PSCReloadMode_TypeDef;
  424. #define IS_TIM5_PRESCALER_RELOAD(RELOAD) \
  425. (((RELOAD) == TIM5_PSCReloadMode_Update) || \
  426. ((RELOAD) == TIM5_PSCReloadMode_Immediate))
  427. /**
  428. * @}
  429. */
  430. /** @defgroup TIM5_Encoder_Mode
  431. * @{
  432. */
  433. typedef enum
  434. {
  435. TIM5_EncoderMode_TI1 = ((uint8_t)0x01), /*!< Encoder mode 1*/
  436. TIM5_EncoderMode_TI2 = ((uint8_t)0x02), /*!< Encoder mode 2*/
  437. TIM5_EncoderMode_TI12 = ((uint8_t)0x03) /*!< Encoder mode 3*/
  438. }TIM5_EncoderMode_TypeDef;
  439. #define IS_TIM5_ENCODER_MODE(MODE) \
  440. (((MODE) == TIM5_EncoderMode_TI1) || \
  441. ((MODE) == TIM5_EncoderMode_TI2) || \
  442. ((MODE) == TIM5_EncoderMode_TI12))
  443. /**
  444. * @}
  445. */
  446. /** @defgroup TIM5_Event_Source
  447. * @{
  448. */
  449. typedef enum
  450. {
  451. TIM5_EventSource_Update = ((uint8_t)0x01), /*!< Update Event*/
  452. TIM5_EventSource_CC1 = ((uint8_t)0x02), /*!< Capture Compare Channel1 Event*/
  453. TIM5_EventSource_CC2 = ((uint8_t)0x04), /*!< Capture Compare Channel2 Event*/
  454. TIM5_EventSource_Trigger = ((uint8_t)0x40), /*!< Trigger Event*/
  455. TIM5_EventSource_Break = ((uint8_t)0x80) /*!< Break Event*/
  456. }TIM5_EventSource_TypeDef;
  457. #define IS_TIM5_EVENT_SOURCE(SOURCE) ((((SOURCE) & (uint8_t)0x18) == 0x00) && \
  458. ((SOURCE) != 0x00))
  459. /**
  460. * @}
  461. */
  462. /** @defgroup TIM5_Update_Source
  463. * @{
  464. */
  465. typedef enum
  466. {
  467. TIM5_UpdateSource_Global = ((uint8_t)0x00), /*!< Global Update request source */
  468. TIM5_UpdateSource_Regular = ((uint8_t)0x01) /*!< Regular Update request source */
  469. }TIM5_UpdateSource_TypeDef;
  470. #define IS_TIM5_UPDATE_SOURCE(SOURCE) \
  471. (((SOURCE) == TIM5_UpdateSource_Global) || \
  472. ((SOURCE) == TIM5_UpdateSource_Regular))
  473. /**
  474. * @}
  475. */
  476. /** @defgroup TIM5_Trigger_Output_Source
  477. * @{
  478. */
  479. typedef enum
  480. {
  481. TIM5_TRGOSource_Reset = ((uint8_t)0x00), /*!< Trigger Output source = Reset*/
  482. TIM5_TRGOSource_Enable = ((uint8_t)0x10), /*!< Trigger Output source = TIM5 is enabled*/
  483. TIM5_TRGOSource_Update = ((uint8_t)0x20), /*!< Trigger Output source = Update event*/
  484. TIM5_TRGOSource_OC1 = ((uint8_t)0x30), /*!< Trigger Output source = output compare channel1 */
  485. TIM5_TRGOSource_OC1REF = ((uint8_t)0x40), /*!< Trigger Output source = output compare channel 1 reference */
  486. TIM5_TRGOSource_OC2REF = ((uint8_t)0x50) /*!< Trigger Output source = output compare channel 2 reference */
  487. }TIM5_TRGOSource_TypeDef;
  488. #define IS_TIM5_TRGO_SOURCE(SOURCE) \
  489. (((SOURCE) == TIM5_TRGOSource_Reset) || \
  490. ((SOURCE) == TIM5_TRGOSource_Enable) || \
  491. ((SOURCE) == TIM5_TRGOSource_Update) || \
  492. ((SOURCE) == TIM5_TRGOSource_OC1) || \
  493. ((SOURCE) == TIM5_TRGOSource_OC1REF) || \
  494. ((SOURCE) == TIM5_TRGOSource_OC2REF))
  495. /**
  496. * @}
  497. */
  498. /** @defgroup TIM5_Slave_Mode
  499. * @{
  500. */
  501. typedef enum
  502. {
  503. TIM5_SlaveMode_Reset = ((uint8_t)0x04), /*!< Slave Mode Selection = Reset*/
  504. TIM5_SlaveMode_Gated = ((uint8_t)0x05), /*!< Slave Mode Selection = Gated*/
  505. TIM5_SlaveMode_Trigger = ((uint8_t)0x06), /*!< Slave Mode Selection = Trigger*/
  506. TIM5_SlaveMode_External1 = ((uint8_t)0x07) /*!< Slave Mode Selection = External 1*/
  507. }TIM5_SlaveMode_TypeDef;
  508. #define IS_TIM5_SLAVE_MODE(MODE) \
  509. (((MODE) == TIM5_SlaveMode_Reset) || \
  510. ((MODE) == TIM5_SlaveMode_Gated) || \
  511. ((MODE) == TIM5_SlaveMode_Trigger) || \
  512. ((MODE) == TIM5_SlaveMode_External1))
  513. /**
  514. * @}
  515. */
  516. /** @defgroup TIM5_Flags
  517. * @{
  518. */
  519. typedef enum
  520. {
  521. TIM5_FLAG_Update = ((uint16_t)0x0001), /*!< Update Flag */
  522. TIM5_FLAG_CC1 = ((uint16_t)0x0002), /*!< Capture compare 1 Flag */
  523. TIM5_FLAG_CC2 = ((uint16_t)0x0004), /*!< Capture compare 2 Flag */
  524. TIM5_FLAG_Trigger = ((uint16_t)0x0040), /*!< Trigger Flag */
  525. TIM5_FLAG_Break = ((uint16_t)0x0080), /*!< Break Flag */
  526. TIM5_FLAG_CC1OF = ((uint16_t)0x0200), /*!< Capture compare 1 over capture Flag */
  527. TIM5_FLAG_CC2OF = ((uint16_t)0x0400) /*!< Capture compare 2 over capture Flag */
  528. }TIM5_FLAG_TypeDef;
  529. #define IS_TIM5_GET_FLAG(FLAG) \
  530. (((FLAG) == TIM5_FLAG_Update) || \
  531. ((FLAG) == TIM5_FLAG_CC1) || \
  532. ((FLAG) == TIM5_FLAG_CC2) || \
  533. ((FLAG) == TIM5_FLAG_Trigger) || \
  534. ((FLAG) == TIM5_FLAG_Break) || \
  535. ((FLAG) == TIM5_FLAG_CC1OF) || \
  536. ((FLAG) == TIM5_FLAG_CC2OF))
  537. #define IS_TIM5_CLEAR_FLAG(FLAG) \
  538. ((((FLAG) & (uint16_t)0xE100) == 0x0000) && ((FLAG) != 0x0000))
  539. /**
  540. * @}
  541. */
  542. /** @defgroup TIM5_DMA_Source_Requests
  543. * @{
  544. */
  545. typedef enum
  546. {
  547. TIM5_DMASource_Update = ((uint8_t)0x01), /*!< TIM5 DMA Update Request*/
  548. TIM5_DMASource_CC1 = ((uint8_t)0x02), /*!< TIM5 DMA CC1 Request*/
  549. TIM5_DMASource_CC2 = ((uint8_t)0x04) /*!< TIM5 DMA CC2 Request*/
  550. }TIM5_DMASource_TypeDef;
  551. #define IS_TIM5_DMA_SOURCE(SOURCE) \
  552. (((SOURCE) == TIM5_DMASource_Update) || \
  553. ((SOURCE) == TIM5_DMASource_CC1) || \
  554. ((SOURCE) == TIM5_DMASource_CC2))
  555. /**
  556. * @}
  557. */
  558. /**
  559. * @}
  560. */
  561. /* Exported constants --------------------------------------------------------*/
  562. /* Exported macros -----------------------------------------------------------*/
  563. /** @defgroup TIM5_Exported_Macros
  564. * @{
  565. */
  566. /**
  567. * @brief Macro TIM5 Input Capture Filter Value
  568. */
  569. #define IS_TIM5_IC_FILTER(ICFILTER) ((ICFILTER) <= 0x0F)
  570. /**
  571. * @brief Macro TIM5 External Trigger Filter
  572. */
  573. #define IS_TIM5_EXT_FILTER(EXTFILTER) \
  574. ((EXTFILTER) <= 0x0F)
  575. /**
  576. * @}
  577. */
  578. /* Exported functions ------------------------------------------------------- */
  579. /* TimeBase management ********************************************************/
  580. void TIM5_DeInit(void);
  581. void TIM5_TimeBaseInit(TIM5_Prescaler_TypeDef TIM5_Prescaler,
  582. TIM5_CounterMode_TypeDef TIM5_CounterMode, uint16_t TIM5_Period);
  583. void TIM5_PrescalerConfig(TIM5_Prescaler_TypeDef Prescaler,
  584. TIM5_PSCReloadMode_TypeDef TIM5_PSCReloadMode);
  585. void TIM5_CounterModeConfig(TIM5_CounterMode_TypeDef TIM5_CounterMode);
  586. void TIM5_SetCounter(uint16_t Counter);
  587. void TIM5_SetAutoreload(uint16_t Autoreload);
  588. uint16_t TIM5_GetCounter(void);
  589. TIM5_Prescaler_TypeDef TIM5_GetPrescaler(void);
  590. void TIM5_UpdateDisableConfig(FunctionalState NewState);
  591. void TIM5_UpdateRequestConfig(TIM5_UpdateSource_TypeDef TIM5_UpdateSource);
  592. void TIM5_ARRPreloadConfig(FunctionalState NewState);
  593. void TIM5_SelectOnePulseMode(TIM5_OPMode_TypeDef TIM5_OPMode);
  594. void TIM5_Cmd(FunctionalState NewState);
  595. /* Output Compare management **************************************************/
  596. void TIM5_OC1Init(TIM5_OCMode_TypeDef TIM5_OCMode,
  597. TIM5_OutputState_TypeDef TIM5_OutputState,
  598. uint16_t TIM5_Pulse,
  599. TIM5_OCPolarity_TypeDef TIM5_OCPolarity,
  600. TIM5_OCIdleState_TypeDef TIM5_OCIdleState);
  601. void TIM5_OC2Init(TIM5_OCMode_TypeDef TIM5_OCMode,
  602. TIM5_OutputState_TypeDef TIM5_OutputState,
  603. uint16_t TIM5_Pulse,
  604. TIM5_OCPolarity_TypeDef TIM5_OCPolarity,
  605. TIM5_OCIdleState_TypeDef TIM5_OCIdleState);
  606. void TIM5_BKRConfig(TIM5_OSSIState_TypeDef TIM5_OSSIState,
  607. TIM5_LockLevel_TypeDef TIM5_LockLevel,
  608. TIM5_BreakState_TypeDef TIM5_BreakState,
  609. TIM5_BreakPolarity_TypeDef TIM5_BreakPolarity,
  610. TIM5_AutomaticOutput_TypeDef TIM5_AutomaticOutput);
  611. void TIM5_CtrlPWMOutputs(FunctionalState NewState);
  612. void TIM5_SelectOCxM(TIM5_Channel_TypeDef TIM5_Channel, TIM5_OCMode_TypeDef TIM5_OCMode);
  613. void TIM5_SetCompare1(uint16_t Compare);
  614. void TIM5_SetCompare2(uint16_t Compare);
  615. void TIM5_ForcedOC1Config(TIM5_ForcedAction_TypeDef TIM5_ForcedAction);
  616. void TIM5_ForcedOC2Config(TIM5_ForcedAction_TypeDef TIM5_ForcedAction);
  617. void TIM5_OC1PreloadConfig(FunctionalState NewState);
  618. void TIM5_OC2PreloadConfig(FunctionalState NewState);
  619. void TIM5_OC1FastConfig(FunctionalState NewState);
  620. void TIM5_OC2FastConfig(FunctionalState NewState);
  621. void TIM5_OC1PolarityConfig(TIM5_OCPolarity_TypeDef TIM5_OCPolarity);
  622. void TIM5_OC2PolarityConfig(TIM5_OCPolarity_TypeDef TIM5_OCPolarity);
  623. void TIM5_CCxCmd(TIM5_Channel_TypeDef TIM5_Channel, FunctionalState NewState);
  624. /* Input Capture management ***************************************************/
  625. void TIM5_ICInit(TIM5_Channel_TypeDef TIM5_Channel,
  626. TIM5_ICPolarity_TypeDef TIM5_ICPolarity,
  627. TIM5_ICSelection_TypeDef TIM5_ICSelection,
  628. TIM5_ICPSC_TypeDef TIM5_ICPrescaler,
  629. uint8_t TIM5_ICFilter);
  630. void TIM5_PWMIConfig(TIM5_Channel_TypeDef TIM5_Channel,
  631. TIM5_ICPolarity_TypeDef TIM5_ICPolarity,
  632. TIM5_ICSelection_TypeDef TIM5_ICSelection,
  633. TIM5_ICPSC_TypeDef TIM5_ICPrescaler,
  634. uint8_t TIM5_ICFilter);
  635. uint16_t TIM5_GetCapture1(void);
  636. uint16_t TIM5_GetCapture2(void);
  637. void TIM5_SetIC1Prescaler(TIM5_ICPSC_TypeDef TIM5_IC1Prescaler);
  638. void TIM5_SetIC2Prescaler(TIM5_ICPSC_TypeDef TIM5_IC2Prescaler);
  639. /* Interrupts, DMA and flags management ***************************************/
  640. void TIM5_ITConfig(TIM5_IT_TypeDef TIM5_IT, FunctionalState NewState);
  641. void TIM5_GenerateEvent(TIM5_EventSource_TypeDef TIM5_EventSource);
  642. FlagStatus TIM5_GetFlagStatus(TIM5_FLAG_TypeDef TIM5_FLAG);
  643. void TIM5_ClearFlag(TIM5_FLAG_TypeDef TIM5_FLAG);
  644. ITStatus TIM5_GetITStatus(TIM5_IT_TypeDef TIM5_IT);
  645. void TIM5_ClearITPendingBit(TIM5_IT_TypeDef TIM5_IT);
  646. void TIM5_DMACmd(TIM5_DMASource_TypeDef TIM5_DMASource, FunctionalState NewState);
  647. void TIM5_SelectCCDMA(FunctionalState NewState);
  648. /* Clocks management **********************************************************/
  649. void TIM5_InternalClockConfig(void);
  650. void TIM5_TIxExternalClockConfig(TIM5_TIxExternalCLK1Source_TypeDef TIM5_TIxExternalCLKSource,
  651. TIM5_ICPolarity_TypeDef TIM5_ICPolarity,
  652. uint8_t ICFilter);
  653. void TIM5_ETRClockMode1Config(TIM5_ExtTRGPSC_TypeDef TIM5_ExtTRGPrescaler,
  654. TIM5_ExtTRGPolarity_TypeDef TIM5_ExtTRGPolarity,
  655. uint8_t ExtTRGFilter);
  656. void TIM5_ETRClockMode2Config(TIM5_ExtTRGPSC_TypeDef TIM5_ExtTRGPrescaler,
  657. TIM5_ExtTRGPolarity_TypeDef TIM5_ExtTRGPolarity,
  658. uint8_t ExtTRGFilter);
  659. /* Synchronization management *************************************************/
  660. void TIM5_SelectInputTrigger(TIM5_TRGSelection_TypeDef TIM5_InputTriggerSource);
  661. void TIM5_SelectOutputTrigger(TIM5_TRGOSource_TypeDef TIM5_TRGOSource);
  662. void TIM5_SelectSlaveMode(TIM5_SlaveMode_TypeDef TIM5_SlaveMode);
  663. void TIM5_SelectMasterSlaveMode(FunctionalState NewState);
  664. void TIM5_ETRConfig(TIM5_ExtTRGPSC_TypeDef TIM5_ExtTRGPrescaler,
  665. TIM5_ExtTRGPolarity_TypeDef TIM5_ExtTRGPolarity,
  666. uint8_t ExtTRGFilter);
  667. /* Specific interface management **********************************************/
  668. void TIM5_EncoderInterfaceConfig(TIM5_EncoderMode_TypeDef TIM5_EncoderMode,
  669. TIM5_ICPolarity_TypeDef TIM5_IC1Polarity,
  670. TIM5_ICPolarity_TypeDef TIM5_IC2Polarity);
  671. void TIM5_SelectHallSensor(FunctionalState NewState);
  672. #endif /* __STM8L15x_TIM5_H */
  673. /**
  674. * @}
  675. */
  676. /**
  677. * @}
  678. */
  679. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/