stm8l15x_tim3.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. /**
  2. ******************************************************************************
  3. * @file stm8l15x_tim3.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 TIM3 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_TIM3_H
  30. #define __STM8L15x_TIM3_H
  31. /* Includes ------------------------------------------------------------------*/
  32. #include "stm8l15x.h"
  33. /** @defgroup STM8L15x_StdPeriph_Driver
  34. * @{
  35. */
  36. /** @defgroup TIM3
  37. * @{
  38. */
  39. /* Exported types ------------------------------------------------------------*/
  40. /** @defgroup TIM3_Exported_Types
  41. * @{
  42. */
  43. /** @defgroup TIM3_Forced_Action
  44. * @{
  45. */
  46. typedef enum
  47. {
  48. TIM3_ForcedAction_Active = ((uint8_t)0x50), /*!< Output Reference is forced low */
  49. TIM3_ForcedAction_Inactive = ((uint8_t)0x40) /*!< Output Reference is forced high */
  50. }
  51. TIM3_ForcedAction_TypeDef;
  52. /**
  53. * @}
  54. */
  55. /** @defgroup TIM3_Prescaler
  56. * @{
  57. */
  58. typedef enum
  59. {
  60. TIM3_Prescaler_1 = ((uint8_t)0x00), /*!< Time base Prescaler = 1 (No effect)*/
  61. TIM3_Prescaler_2 = ((uint8_t)0x01), /*!< Time base Prescaler = 2 */
  62. TIM3_Prescaler_4 = ((uint8_t)0x02), /*!< Time base Prescaler = 4 */
  63. TIM3_Prescaler_8 = ((uint8_t)0x03), /*!< Time base Prescaler = 8 */
  64. TIM3_Prescaler_16 = ((uint8_t)0x04), /*!< Time base Prescaler = 16 */
  65. TIM3_Prescaler_32 = ((uint8_t)0x05), /*!< Time base Prescaler = 32 */
  66. TIM3_Prescaler_64 = ((uint8_t)0x06), /*!< Time base Prescaler = 64 */
  67. TIM3_Prescaler_128 = ((uint8_t)0x07) /*!< Time base Prescaler = 128 */
  68. }TIM3_Prescaler_TypeDef;
  69. /**
  70. * @}
  71. */
  72. /** @defgroup TIM3_OCMode
  73. * @{
  74. */
  75. typedef enum
  76. {
  77. TIM3_OCMode_Timing = ((uint8_t)0x00), /*!< Timing (Frozen) Mode*/
  78. TIM3_OCMode_Active = ((uint8_t)0x10), /*!< Active Mode*/
  79. TIM3_OCMode_Inactive = ((uint8_t)0x20), /*!< Inactive Mode*/
  80. TIM3_OCMode_Toggle = ((uint8_t)0x30), /*!< Toggle Mode*/
  81. TIM3_OCMode_PWM1 = ((uint8_t)0x60), /*!< PWM Mode 1*/
  82. TIM3_OCMode_PWM2 = ((uint8_t)0x70) /*!< PWM Mode 2*/
  83. }TIM3_OCMode_TypeDef;
  84. /**
  85. * @}
  86. */
  87. /** @defgroup TIM3_OnePulseMode
  88. * @{
  89. */
  90. typedef enum
  91. {
  92. TIM3_OPMode_Single = ((uint8_t)0x01), /*!< Single one Pulse mode (OPM Active) */
  93. TIM3_OPMode_Repetitive = ((uint8_t)0x00) /*!< Repetitive Pulse mode (OPM inactive) */
  94. }TIM3_OPMode_TypeDef;
  95. /**
  96. * @}
  97. */
  98. /** @defgroup TIM3_Channel
  99. * @{
  100. */
  101. typedef enum
  102. {
  103. TIM3_Channel_1 = ((uint8_t)0x00), /*!< Channel 1*/
  104. TIM3_Channel_2 = ((uint8_t)0x01) /*!< Channel 2*/
  105. }TIM3_Channel_TypeDef;
  106. /**
  107. * @}
  108. */
  109. /** @defgroup TIM3_CounterMode
  110. * @{
  111. */
  112. typedef enum
  113. {
  114. TIM3_CounterMode_Up = ((uint8_t)0x00), /*!< Counter Up Mode */
  115. TIM3_CounterMode_Down = ((uint8_t)0x10), /*!< Counter Down Mode */
  116. TIM3_CounterMode_CenterAligned1 = ((uint8_t)0x20), /*!< Counter Central aligned Mode 1 */
  117. TIM3_CounterMode_CenterAligned2 = ((uint8_t)0x40), /*!< Counter Central aligned Mode 2 */
  118. TIM3_CounterMode_CenterAligned3 = ((uint8_t)0x60) /*!< Counter Central aligned Mode 3 */
  119. }TIM3_CounterMode_TypeDef;
  120. /**
  121. * @}
  122. */
  123. /** @defgroup TIM3_Output_Compare_Polarity
  124. * @{
  125. */
  126. typedef enum
  127. {
  128. TIM3_OCPolarity_High = ((uint8_t)0x00), /*!< Output compare polarity = High */
  129. TIM3_OCPolarity_Low = ((uint8_t)0x01) /*!< Output compare polarity = Low */
  130. }TIM3_OCPolarity_TypeDef;
  131. /**
  132. * @}
  133. */
  134. /** @defgroup TIM3_Output_State
  135. * @{
  136. */
  137. typedef enum
  138. {
  139. TIM3_OutputState_Disable = ((uint8_t)0x00), /*!< Output compare State disabled
  140. (channel output disabled) */
  141. TIM3_OutputState_Enable = ((uint8_t)0x01) /*!< Output compare State enabled
  142. (channel output enabled) */
  143. }TIM3_OutputState_TypeDef;
  144. /**
  145. * @}
  146. */
  147. /** @defgroup TIM3_Break_State
  148. * @{
  149. */
  150. typedef enum
  151. {
  152. TIM3_BreakState_Disable = ((uint8_t)0x00), /*!< Break State disabled (break option disabled) */
  153. TIM3_BreakState_Enable = ((uint8_t)0x10) /*!< Break State enabled (break option enabled) */
  154. }TIM3_BreakState_TypeDef;
  155. /**
  156. * @}
  157. */
  158. /** @defgroup TIM3_Break_Polarity
  159. * @{
  160. */
  161. typedef enum
  162. {
  163. TIM3_BreakPolarity_High = ((uint8_t)0x20), /*!< if Break, channel polarity = High */
  164. TIM3_BreakPolarity_Low = ((uint8_t)0x00) /*!< if Break, channel polarity = Low */
  165. }TIM3_BreakPolarity_TypeDef;
  166. /**
  167. * @}
  168. */
  169. /** @defgroup TIM3_Automatic_Output
  170. * @{
  171. */
  172. typedef enum
  173. {
  174. TIM3_AutomaticOutput_Enable = ((uint8_t)0x40), /*!< Automatic Output option enabled */
  175. TIM3_AutomaticOutput_Disable = ((uint8_t)0x00) /*!< Automatic Output option disabled */
  176. }TIM3_AutomaticOutput_TypeDef;
  177. /**
  178. * @}
  179. */
  180. /** @defgroup TIM3_Lock_Level
  181. * @{
  182. */
  183. typedef enum
  184. {
  185. TIM3_LockLevel_Off = ((uint8_t)0x00), /*!< Lock option disabled */
  186. TIM3_LockLevel_1 = ((uint8_t)0x01), /*!< Select Lock Level 1 */
  187. TIM3_LockLevel_2 = ((uint8_t)0x02), /*!< Select Lock Level 2 */
  188. TIM3_LockLevel_3 = ((uint8_t)0x03) /*!< Select Lock Level 3 */
  189. }TIM3_LockLevel_TypeDef;
  190. /**
  191. * @}
  192. */
  193. /** @defgroup TIM3_OSSI_State
  194. * @{
  195. */
  196. typedef enum
  197. {
  198. TIM3_OSSIState_Enable = ((uint8_t)0x04), /*!< Off-State Selection for Idle mode enabled */
  199. TIM3_OSSIState_Disable = ((uint8_t)0x00) /*!< Off-State Selection for Idle mode disabled */
  200. }TIM3_OSSIState_TypeDef;
  201. /**
  202. * @}
  203. */
  204. /** @defgroup TIM3_Output_Compare_Idle_state
  205. * @{
  206. */
  207. typedef enum
  208. {
  209. TIM3_OCIdleState_Reset = ((uint8_t)0x00), /*!< Output Compare Idle state = Reset */
  210. TIM3_OCIdleState_Set = ((uint8_t)0x01) /*!< Output Compare Idle state = Set */
  211. }TIM3_OCIdleState_TypeDef;
  212. /**
  213. * @}
  214. */
  215. /** @defgroup TIM3_Input_Capture_Polarity
  216. * @{
  217. */
  218. typedef enum
  219. {
  220. TIM3_ICPolarity_Rising = ((uint8_t)0x00), /*!< Input Capture on Rising Edge*/
  221. TIM3_ICPolarity_Falling = ((uint8_t)0x01) /*!< Input Capture on Falling Edge*/
  222. }TIM3_ICPolarity_TypeDef;
  223. /**
  224. * @}
  225. */
  226. /** @defgroup TIM3_Input_Capture_Selection
  227. * @{
  228. */
  229. typedef enum
  230. {
  231. TIM3_ICSelection_DirectTI = ((uint8_t)0x01), /*!< Input Capture mapped on the direct input*/
  232. TIM3_ICSelection_IndirectTI = ((uint8_t)0x02), /*!< Input Capture mapped on the indirect input*/
  233. TIM3_ICSelection_TRGI = ((uint8_t)0x03) /*!< Input Capture mapped on the Trigger Input*/
  234. }TIM3_ICSelection_TypeDef;
  235. /**
  236. * @}
  237. */
  238. /** @defgroup TIM3_Input_Capture_Prescaler
  239. * @{
  240. */
  241. typedef enum
  242. {
  243. TIM3_ICPSC_DIV1 = ((uint8_t)0x00), /*!< Input Capture Prescaler = 1 (one capture every 1 event) */
  244. TIM3_ICPSC_DIV2 = ((uint8_t)0x04), /*!< Input Capture Prescaler = 2 (one capture every 2 events) */
  245. TIM3_ICPSC_DIV4 = ((uint8_t)0x08), /*!< Input Capture Prescaler = 4 (one capture every 4 events) */
  246. TIM3_ICPSC_DIV8 = ((uint8_t)0x0C) /*!< Input Capture Prescaler = 8 (one capture every 8 events) */
  247. }TIM3_ICPSC_TypeDef;
  248. /**
  249. * @}
  250. */
  251. /** @defgroup TIM3_Interrupts
  252. * @{
  253. */
  254. typedef enum
  255. {
  256. TIM3_IT_Update = ((uint8_t)0x01), /*!< Update Interrupt*/
  257. TIM3_IT_CC1 = ((uint8_t)0x02), /*!< Capture Compare Channel1 Interrupt*/
  258. TIM3_IT_CC2 = ((uint8_t)0x04), /*!< Capture Compare Channel2 Interrupt*/
  259. TIM3_IT_Trigger = ((uint8_t)0x40), /*!< Trigger Interrupt*/
  260. TIM3_IT_Break = ((uint8_t)0x80) /*!< Break Interrupt*/
  261. }TIM3_IT_TypeDef;
  262. /**
  263. * @}
  264. */
  265. /** @defgroup TIM3_External_Trigger_Prescaler
  266. * @{
  267. */
  268. typedef enum
  269. {
  270. TIM3_ExtTRGPSC_OFF = ((uint8_t)0x00), /*!< No External Trigger prescaler */
  271. TIM3_ExtTRGPSC_DIV2 = ((uint8_t)0x10), /*!< External Trigger prescaler = 2 (ETRP frequency divided by 2) */
  272. TIM3_ExtTRGPSC_DIV4 = ((uint8_t)0x20), /*!< External Trigger prescaler = 4 (ETRP frequency divided by 4) */
  273. TIM3_ExtTRGPSC_DIV8 = ((uint8_t)0x30) /*!< External Trigger prescaler = 8 (ETRP frequency divided by 8) */
  274. }TIM3_ExtTRGPSC_TypeDef;
  275. /**
  276. * @}
  277. */
  278. /** @defgroup TIM3_Internal_Trigger_Selection
  279. * @{
  280. */
  281. typedef enum
  282. {
  283. TIM3_TRGSelection_TIM4 = ((uint8_t)0x00), /*!< TRIG Input source = TIM TRIG Output */
  284. TIM3_TRGSelection_TIM1 = ((uint8_t)0x10), /*!< TRIG Input source = TIM TRIG Output */
  285. TIM3_TRGSelection_TIM5 = ((uint8_t)0x20), /*!< TRIG Input source = TIM TRIG Output */
  286. TIM3_TRGSelection_TIM2 = ((uint8_t)0x30), /*!< TRIG Input source = TIM TRIG Output */
  287. TIM3_TRGSelection_TI1F_ED = ((uint8_t)0x40), /*!< TRIG Input source = TI1F_ED (TI1 Edge Detector) */
  288. TIM3_TRGSelection_TI1FP1 = ((uint8_t)0x50), /*!< TRIG Input source = TI1FP1 (Filtered Timer Input 1) */
  289. TIM3_TRGSelection_TI2FP2 = ((uint8_t)0x60), /*!< TRIG Input source = TI2FP2 (Filtered Timer Input 2) */
  290. TIM3_TRGSelection_ETRF = ((uint8_t)0x70) /*!< TRIG Input source = ETRF (External Trigger Input ) */
  291. }TIM3_TRGSelection_TypeDef;
  292. /**
  293. * @}
  294. */
  295. /** @defgroup TIM3_TI_External_Clock_Source
  296. * @{
  297. */
  298. typedef enum
  299. {
  300. TIM3_TIxExternalCLK1Source_TI1ED = ((uint8_t)0x40), /*!< External Clock mode 1 source = TI1ED */
  301. TIM3_TIxExternalCLK1Source_TI1 = ((uint8_t)0x50), /*!< External Clock mode 1 source = TI1 */
  302. TIM3_TIxExternalCLK1Source_TI2 = ((uint8_t)0x60) /*!< External Clock mode 1 source = TI2 */
  303. }TIM3_TIxExternalCLK1Source_TypeDef;
  304. /**
  305. * @}
  306. */
  307. /** @defgroup TIM3_External_Trigger_Polarity
  308. * @{
  309. */
  310. typedef enum
  311. {
  312. TIM3_ExtTRGPolarity_Inverted = ((uint8_t)0x80), /*!< External Trigger Polarity = inverted */
  313. TIM3_ExtTRGPolarity_NonInverted = ((uint8_t)0x00) /*!< External Trigger Polarity = non inverted */
  314. }TIM3_ExtTRGPolarity_TypeDef;
  315. /**
  316. * @}
  317. */
  318. /** @defgroup TIM3_Prescaler_Reload_Mode
  319. * @{
  320. */
  321. typedef enum
  322. {
  323. TIM3_PSCReloadMode_Update = ((uint8_t)0x00), /*!< Prescaler value is reloaded at every update*/
  324. TIM3_PSCReloadMode_Immediate = ((uint8_t)0x01) /*!< Prescaler value is reloaded immediatly*/
  325. }TIM3_PSCReloadMode_TypeDef;
  326. /**
  327. * @}
  328. */
  329. /** @defgroup TIM3_Encoder_Mode
  330. * @{
  331. */
  332. typedef enum
  333. {
  334. TIM3_EncoderMode_TI1 = ((uint8_t)0x01), /*!< Encoder mode 1*/
  335. TIM3_EncoderMode_TI2 = ((uint8_t)0x02), /*!< Encoder mode 2*/
  336. TIM3_EncoderMode_TI12 = ((uint8_t)0x03) /*!< Encoder mode 3*/
  337. }TIM3_EncoderMode_TypeDef;
  338. /**
  339. * @}
  340. */
  341. /** @defgroup TIM3_Event_Source
  342. * @{
  343. */
  344. typedef enum
  345. {
  346. TIM3_EventSource_Update = ((uint8_t)0x01), /*!< Update Event*/
  347. TIM3_EventSource_CC1 = ((uint8_t)0x02), /*!< Capture Compare Channel1 Event*/
  348. TIM3_EventSource_CC2 = ((uint8_t)0x04), /*!< Capture Compare Channel2 Event*/
  349. TIM3_EventSource_Trigger = ((uint8_t)0x40), /*!< Trigger Event*/
  350. TIM3_EventSource_Break = ((uint8_t)0x80) /*!< Break Event*/
  351. }TIM3_EventSource_TypeDef;
  352. /**
  353. * @}
  354. */
  355. /** @defgroup TIM3_Update_Source
  356. * @{
  357. */
  358. typedef enum
  359. {
  360. TIM3_UpdateSource_Global = ((uint8_t)0x00), /*!< Global Update request source */
  361. TIM3_UpdateSource_Regular = ((uint8_t)0x01) /*!< Regular Update request source */
  362. }TIM3_UpdateSource_TypeDef;
  363. /**
  364. * @}
  365. */
  366. /** @defgroup TIM3_Trigger_Output_Source
  367. * @{
  368. */
  369. typedef enum
  370. {
  371. TIM3_TRGOSource_Reset = ((uint8_t)0x00), /*!< Trigger Output source = Reset*/
  372. TIM3_TRGOSource_Enable = ((uint8_t)0x10), /*!< Trigger Output source = TIM3 is enabled*/
  373. TIM3_TRGOSource_Update = ((uint8_t)0x20), /*!< Trigger Output source = Update event*/
  374. TIM3_TRGOSource_OC1 = ((uint8_t)0x30), /*!< Trigger Output source = output compare channel1 */
  375. TIM3_TRGOSource_OC1REF = ((uint8_t)0x40), /*!< Trigger Output source = output compare channel 1 reference */
  376. TIM3_TRGOSource_OC2REF = ((uint8_t)0x50) /*!< Trigger Output source = output compare channel 2 reference */
  377. }TIM3_TRGOSource_TypeDef;
  378. /**
  379. * @}
  380. */
  381. /** @defgroup TIM3_Slave_Mode
  382. * @{
  383. */
  384. typedef enum
  385. {
  386. TIM3_SlaveMode_Reset = ((uint8_t)0x04), /*!< Slave Mode Selection = Reset*/
  387. TIM3_SlaveMode_Gated = ((uint8_t)0x05), /*!< Slave Mode Selection = Gated*/
  388. TIM3_SlaveMode_Trigger = ((uint8_t)0x06), /*!< Slave Mode Selection = Trigger*/
  389. TIM3_SlaveMode_External1 = ((uint8_t)0x07) /*!< Slave Mode Selection = External 1*/
  390. }TIM3_SlaveMode_TypeDef;
  391. /**
  392. * @}
  393. */
  394. /** @defgroup TIM3_Flags
  395. * @{
  396. */
  397. typedef enum
  398. {
  399. TIM3_FLAG_Update = ((uint16_t)0x0001), /*!< Update Flag */
  400. TIM3_FLAG_CC1 = ((uint16_t)0x0002), /*!< Capture compare 1 Flag */
  401. TIM3_FLAG_CC2 = ((uint16_t)0x0004), /*!< Capture compare 2 Flag */
  402. TIM3_FLAG_Trigger = ((uint16_t)0x0040), /*!< Trigger Flag */
  403. TIM3_FLAG_Break = ((uint16_t)0x0080), /*!< Break Flag */
  404. TIM3_FLAG_CC1OF = ((uint16_t)0x0200), /*!< Capture compare 1 over capture Flag */
  405. TIM3_FLAG_CC2OF = ((uint16_t)0x0400) /*!< Capture compare 2 over capture Flag */
  406. }TIM3_FLAG_TypeDef;
  407. /**
  408. * @}
  409. */
  410. /** @defgroup TIM3_DMA_Source_Requests
  411. * @{
  412. */
  413. typedef enum
  414. {
  415. TIM3_DMASource_Update = ((uint8_t)0x01), /*!< TIM3 DMA Update Request*/
  416. TIM3_DMASource_CC1 = ((uint8_t)0x02),
  417. TIM3_DMASource_CC2 = ((uint8_t)0x04)
  418. }TIM3_DMASource_TypeDef;
  419. /**
  420. * @}
  421. */
  422. /**
  423. * @}
  424. */
  425. /* Exported constants --------------------------------------------------------*/
  426. /* Exported macros -----------------------------------------------------------*/
  427. /** @defgroup TIM3_Exported_Macros
  428. * @{
  429. */
  430. /**
  431. * @brief Macro used by the assert function to check the different functions parameters.
  432. */
  433. /**
  434. * @brief Macro TIM3 Forced Action
  435. */
  436. #define IS_TIM3_FORCED_ACTION(ACTION) \
  437. (((ACTION) == TIM3_ForcedAction_Active) || \
  438. ((ACTION) == TIM3_ForcedAction_Inactive))
  439. /**
  440. * @brief Macro TIM3 Prescaler
  441. */
  442. #define IS_TIM3_PRESCALER(PRESCALER) \
  443. (((PRESCALER) == TIM3_Prescaler_1) || \
  444. ((PRESCALER) == TIM3_Prescaler_2) || \
  445. ((PRESCALER) == TIM3_Prescaler_4) || \
  446. ((PRESCALER) == TIM3_Prescaler_8) || \
  447. ((PRESCALER) == TIM3_Prescaler_16) || \
  448. ((PRESCALER) == TIM3_Prescaler_32) || \
  449. ((PRESCALER) == TIM3_Prescaler_64) || \
  450. ((PRESCALER) == TIM3_Prescaler_128))
  451. /**
  452. * @brief Macro TIM3 Output Compare and PWM modes
  453. */
  454. #define IS_TIM3_OC_MODE(MODE) \
  455. (((MODE) == TIM3_OCMode_Timing) || \
  456. ((MODE) == TIM3_OCMode_Active) || \
  457. ((MODE) == TIM3_OCMode_Inactive) || \
  458. ((MODE) == TIM3_OCMode_Toggle) || \
  459. ((MODE) == TIM3_OCMode_PWM1) || \
  460. ((MODE) == TIM3_OCMode_PWM2))
  461. #define IS_TIM3_OCM(MODE) \
  462. (((MODE) == TIM3_OCMode_Timing) || \
  463. ((MODE) == TIM3_OCMode_Active) || \
  464. ((MODE) == TIM3_OCMode_Inactive) || \
  465. ((MODE) == TIM3_OCMode_Toggle) || \
  466. ((MODE) == TIM3_OCMode_PWM1) || \
  467. ((MODE) == TIM3_OCMode_PWM2) || \
  468. ((MODE) == (uint8_t)TIM3_ForcedAction_Active) || \
  469. ((MODE) == (uint8_t)TIM3_ForcedAction_Inactive))
  470. /**
  471. * @brief Macro TIM3 One Pulse Mode
  472. */
  473. #define IS_TIM3_OPM_MODE(MODE) \
  474. (((MODE) == TIM3_OPMode_Single) || \
  475. ((MODE) == TIM3_OPMode_Repetitive))
  476. /**
  477. * @brief Macro TIM3 Channel
  478. */
  479. #define IS_TIM3_CHANNEL(CHANNEL) \
  480. (((CHANNEL) == TIM3_Channel_1) || \
  481. ((CHANNEL) == TIM3_Channel_2) )
  482. /**
  483. * @brief Macro TIM3 Counter Mode
  484. */
  485. #define IS_TIM3_COUNTER_MODE(MODE) \
  486. (((MODE) == TIM3_CounterMode_Up) || \
  487. ((MODE) == TIM3_CounterMode_Down) || \
  488. ((MODE) == TIM3_CounterMode_CenterAligned1) || \
  489. ((MODE) == TIM3_CounterMode_CenterAligned2) || \
  490. ((MODE) == TIM3_CounterMode_CenterAligned3))
  491. /**
  492. * @brief Macro TIM3 Output Compare Polarity
  493. */
  494. #define IS_TIM3_OC_POLARITY(POLARITY) \
  495. (((POLARITY) == TIM3_OCPolarity_High) || \
  496. ((POLARITY) == TIM3_OCPolarity_Low))
  497. /**
  498. * @brief Macro TIM3 Output Compare states
  499. */
  500. #define IS_TIM3_OUTPUT_STATE(STATE) \
  501. (((STATE) == TIM3_OutputState_Disable) || \
  502. ((STATE) == TIM3_OutputState_Enable))
  503. /**
  504. * @brief Macro Break Input enable/disable
  505. */
  506. #define IS_TIM3_BREAK_STATE(STATE) \
  507. (((STATE) == TIM3_BreakState_Enable) || \
  508. ((STATE) == TIM3_BreakState_Disable))
  509. /**
  510. * @brief Macro Break Polarity
  511. */
  512. #define IS_TIM3_BREAK_POLARITY(POLARITY) \
  513. (((POLARITY) == TIM3_BreakPolarity_Low) || \
  514. ((POLARITY) == TIM3_BreakPolarity_High))
  515. /**
  516. * @brief Macro TIM3 AOE Bit Set/Reset
  517. */
  518. #define IS_TIM3_AUTOMATIC_OUTPUT_STATE(STATE) \
  519. (((STATE) == TIM3_AutomaticOutput_Enable) || \
  520. ((STATE) == TIM3_AutomaticOutput_Disable))
  521. /**
  522. * @brief Macro Lock levels
  523. */
  524. #define IS_TIM3_LOCK_LEVEL(LEVEL) \
  525. (((LEVEL) == TIM3_LockLevel_Off) || \
  526. ((LEVEL) == TIM3_LockLevel_1) || \
  527. ((LEVEL) == TIM3_LockLevel_2) || \
  528. ((LEVEL) == TIM3_LockLevel_3))
  529. /**
  530. * @brief Macro OSSI: Off-State Selection for Idle mode states
  531. */
  532. #define IS_TIM3_OSSI_STATE(STATE) \
  533. (((STATE) == TIM3_OSSIState_Enable) || \
  534. ((STATE) == TIM3_OSSIState_Disable))
  535. /**
  536. * @brief Macro TIM3 OC IDLE STATE
  537. */
  538. #define IS_TIM3_OCIDLE_STATE(STATE) \
  539. (((STATE) == TIM3_OCIdleState_Set) || \
  540. ((STATE) == TIM3_OCIdleState_Reset))
  541. /**
  542. * @brief Macro TIM3 IC POLARITY
  543. */
  544. #define IS_TIM3_IC_POLARITY(POLARITY) \
  545. (((POLARITY) == TIM3_ICPolarity_Rising) || \
  546. ((POLARITY) == TIM3_ICPolarity_Falling))
  547. /**
  548. * @brief Macro TIM3 IC SELECTION
  549. */
  550. #define IS_TIM3_IC_SELECTION(SELECTION) \
  551. (((SELECTION) == TIM3_ICSelection_DirectTI) || \
  552. ((SELECTION) == TIM3_ICSelection_IndirectTI) || \
  553. ((SELECTION) == TIM3_ICSelection_TRGI))
  554. /**
  555. * @brief Macro TIM3 IC PRESCALER
  556. */
  557. #define IS_TIM3_IC_PRESCALER(PRESCALER) \
  558. (((PRESCALER) == TIM3_ICPSC_DIV1) || \
  559. ((PRESCALER) == TIM3_ICPSC_DIV2) || \
  560. ((PRESCALER) == TIM3_ICPSC_DIV4) || \
  561. ((PRESCALER) == TIM3_ICPSC_DIV8))
  562. /**
  563. * @brief Macro TIM3 Input Capture Filter Value
  564. */
  565. #define IS_TIM3_IC_FILTER(ICFILTER) \
  566. ((ICFILTER) <= 0x0F)
  567. /**
  568. * @brief Macro TIM3 Interrupts
  569. */
  570. #define IS_TIM3_IT(IT) \
  571. ((IT) != 0x00)
  572. #define IS_TIM3_GET_IT(IT) \
  573. (((IT) == TIM3_IT_Update) || \
  574. ((IT) == TIM3_IT_CC1) || \
  575. ((IT) == TIM3_IT_CC2) || \
  576. ((IT) == TIM3_IT_Trigger) || \
  577. ((IT) == TIM3_IT_Break))
  578. /**
  579. * @brief Macro TIM3 external trigger prescaler
  580. */
  581. #define IS_TIM3_EXT_PRESCALER(PRESCALER) \
  582. (((PRESCALER) == TIM3_ExtTRGPSC_OFF) || \
  583. ((PRESCALER) == TIM3_ExtTRGPSC_DIV2) || \
  584. ((PRESCALER) == TIM3_ExtTRGPSC_DIV4) || \
  585. ((PRESCALER) == TIM3_ExtTRGPSC_DIV8))
  586. /**
  587. * @brief Macro TIM3 Trigger Selection
  588. */
  589. #define IS_TIM3_TRIGGER_SELECTION(SELECTION) \
  590. (((SELECTION) == TIM3_TRGSelection_TI1F_ED) || \
  591. ((SELECTION) == TIM3_TRGSelection_TI1FP1) || \
  592. ((SELECTION) == TIM3_TRGSelection_TI2FP2) || \
  593. ((SELECTION) == TIM3_TRGSelection_TIM4) || \
  594. ((SELECTION) == TIM3_TRGSelection_TIM1) || \
  595. ((SELECTION) == TIM3_TRGSelection_TIM5) || \
  596. ((SELECTION) == TIM3_TRGSelection_TIM2) || \
  597. ((SELECTION) == TIM3_TRGSelection_ETRF))
  598. #define IS_TIM3_TIX_TRIGGER_SELECTION(SELECTION) \
  599. (((SELECTION) == TIM3_TRGSelection_TI1F_ED) || \
  600. ((SELECTION) == TIM3_TRGSelection_TI1FP1) || \
  601. ((SELECTION) == TIM3_TRGSelection_TI2FP2))
  602. /**
  603. * @brief Macro TIM3 TIx external Clock Selection
  604. */
  605. #define IS_TIM3_TIXCLK_SOURCE(SOURCE) \
  606. (((SOURCE) == TIM3_TIxExternalCLK1Source_TI1ED) || \
  607. ((SOURCE) == TIM3_TIxExternalCLK1Source_TI2) || \
  608. ((SOURCE) == TIM3_TIxExternalCLK1Source_TI1))
  609. /**
  610. * @brief Macro TIM3 Trigger Polarity
  611. */
  612. #define IS_TIM3_EXT_POLARITY(POLARITY) \
  613. (((POLARITY) == TIM3_ExtTRGPolarity_Inverted) || \
  614. ((POLARITY) == TIM3_ExtTRGPolarity_NonInverted))
  615. /**
  616. * @brief Macro TIM3 External Trigger Filter
  617. */
  618. #define IS_TIM3_EXT_FILTER(EXTFILTER) \
  619. ((EXTFILTER) <= 0x0F)
  620. /**
  621. * @brief Macro TIM3 Prescaler Reload
  622. */
  623. #define IS_TIM3_PRESCALER_RELOAD(RELOAD) \
  624. (((RELOAD) == TIM3_PSCReloadMode_Update) || \
  625. ((RELOAD) == TIM3_PSCReloadMode_Immediate))
  626. /**
  627. * @brief Macro TIM3 encoder mode
  628. */
  629. #define IS_TIM3_ENCODER_MODE(MODE) \
  630. (((MODE) == TIM3_EncoderMode_TI1) || \
  631. ((MODE) == TIM3_EncoderMode_TI2) || \
  632. ((MODE) == TIM3_EncoderMode_TI12))
  633. /**
  634. * @brief Macro TIM3 event source
  635. */
  636. #define IS_TIM3_EVENT_SOURCE(SOURCE) \
  637. ((((SOURCE) & (uint8_t)0x18) == 0x00) && ((SOURCE) != 0x00))
  638. /**
  639. * @brief Macro TIM3 update source
  640. */
  641. #define IS_TIM3_UPDATE_SOURCE(SOURCE) \
  642. (((SOURCE) == TIM3_UpdateSource_Global) || \
  643. ((SOURCE) == TIM3_UpdateSource_Regular))
  644. /**
  645. * @brief Macro TIM3 TRGO source
  646. */
  647. #define IS_TIM3_TRGO_SOURCE(SOURCE) \
  648. (((SOURCE) == TIM3_TRGOSource_Reset) || \
  649. ((SOURCE) == TIM3_TRGOSource_Enable) || \
  650. ((SOURCE) == TIM3_TRGOSource_Update) || \
  651. ((SOURCE) == TIM3_TRGOSource_OC1) || \
  652. ((SOURCE) == TIM3_TRGOSource_OC1REF) || \
  653. ((SOURCE) == TIM3_TRGOSource_OC2REF))
  654. /**
  655. * @brief Macro TIM3 Slave mode
  656. */
  657. #define IS_TIM3_SLAVE_MODE(MODE) \
  658. (((MODE) == TIM3_SlaveMode_Reset) || \
  659. ((MODE) == TIM3_SlaveMode_Gated) || \
  660. ((MODE) == TIM3_SlaveMode_Trigger) || \
  661. ((MODE) == TIM3_SlaveMode_External1))
  662. /**
  663. * @brief Macro TIM3 Flags
  664. */
  665. #define IS_TIM3_GET_FLAG(FLAG) \
  666. (((FLAG) == TIM3_FLAG_Update) || \
  667. ((FLAG) == TIM3_FLAG_CC1) || \
  668. ((FLAG) == TIM3_FLAG_CC2) || \
  669. ((FLAG) == TIM3_FLAG_Trigger) || \
  670. ((FLAG) == TIM3_FLAG_Break) || \
  671. ((FLAG) == TIM3_FLAG_CC1OF) || \
  672. ((FLAG) == TIM3_FLAG_CC2OF))
  673. #define IS_TIM3_CLEAR_FLAG(FLAG) \
  674. ((((FLAG) & (uint16_t)0xE100) == 0x0000) && ((FLAG) != 0x0000))
  675. /**
  676. * @brief Macro TIM3 DMA sources
  677. */
  678. #define IS_TIM3_DMA_SOURCE(SOURCE) \
  679. (((SOURCE) == TIM3_DMASource_Update) || \
  680. ((SOURCE) == TIM3_DMASource_CC1) || \
  681. ((SOURCE) == TIM3_DMASource_CC2))
  682. /**
  683. * @}
  684. */
  685. /* Exported functions ------------------------------------------------------- */
  686. /* TimeBase management ********************************************************/
  687. void TIM3_DeInit(void);
  688. void TIM3_TimeBaseInit(TIM3_Prescaler_TypeDef TIM3_Prescaler,
  689. TIM3_CounterMode_TypeDef TIM3_CounterMode,
  690. uint16_t TIM3_Period);
  691. void TIM3_PrescalerConfig(TIM3_Prescaler_TypeDef Prescaler,
  692. TIM3_PSCReloadMode_TypeDef TIM3_PSCReloadMode);
  693. void TIM3_CounterModeConfig(TIM3_CounterMode_TypeDef TIM3_CounterMode);
  694. void TIM3_SetCounter(uint16_t Counter);
  695. void TIM3_SetAutoreload(uint16_t Autoreload);
  696. uint16_t TIM3_GetCounter(void);
  697. TIM3_Prescaler_TypeDef TIM3_GetPrescaler(void);
  698. void TIM3_UpdateDisableConfig(FunctionalState NewState);
  699. void TIM3_UpdateRequestConfig(TIM3_UpdateSource_TypeDef TIM3_UpdateSource);
  700. void TIM3_ARRPreloadConfig(FunctionalState NewState);
  701. void TIM3_SelectOnePulseMode(TIM3_OPMode_TypeDef TIM3_OPMode);
  702. void TIM3_Cmd(FunctionalState NewState);
  703. /* Output Compare management **************************************************/
  704. void TIM3_OC1Init(TIM3_OCMode_TypeDef TIM3_OCMode,
  705. TIM3_OutputState_TypeDef TIM3_OutputState,
  706. uint16_t TIM3_Pulse,
  707. TIM3_OCPolarity_TypeDef TIM3_OCPolarity,
  708. TIM3_OCIdleState_TypeDef TIM3_OCIdleState);
  709. void TIM3_OC2Init(TIM3_OCMode_TypeDef TIM3_OCMode,
  710. TIM3_OutputState_TypeDef TIM3_OutputState,
  711. uint16_t TIM3_Pulse,
  712. TIM3_OCPolarity_TypeDef TIM3_OCPolarity,
  713. TIM3_OCIdleState_TypeDef TIM3_OCIdleState);
  714. void TIM3_BKRConfig(TIM3_OSSIState_TypeDef TIM3_OSSIState,
  715. TIM3_LockLevel_TypeDef TIM3_LockLevel,
  716. TIM3_BreakState_TypeDef TIM3_BreakState,
  717. TIM3_BreakPolarity_TypeDef TIM3_BreakPolarity,
  718. TIM3_AutomaticOutput_TypeDef TIM3_AutomaticOutput);
  719. void TIM3_CtrlPWMOutputs(FunctionalState NewState);
  720. void TIM3_SelectOCxM(TIM3_Channel_TypeDef TIM3_Channel,
  721. TIM3_OCMode_TypeDef TIM3_OCMode);
  722. void TIM3_SetCompare1(uint16_t Compare);
  723. void TIM3_SetCompare2(uint16_t Compare);
  724. void TIM3_ForcedOC1Config(TIM3_ForcedAction_TypeDef TIM3_ForcedAction);
  725. void TIM3_ForcedOC2Config(TIM3_ForcedAction_TypeDef TIM3_ForcedAction);
  726. void TIM3_OC1PreloadConfig(FunctionalState NewState);
  727. void TIM3_OC2PreloadConfig(FunctionalState NewState);
  728. void TIM3_OC1FastConfig(FunctionalState NewState);
  729. void TIM3_OC2FastConfig(FunctionalState NewState);
  730. void TIM3_OC1PolarityConfig(TIM3_OCPolarity_TypeDef TIM3_OCPolarity);
  731. void TIM3_OC2PolarityConfig(TIM3_OCPolarity_TypeDef TIM3_OCPolarity);
  732. void TIM3_CCxCmd(TIM3_Channel_TypeDef TIM3_Channel, FunctionalState NewState);
  733. /* Input Capture management ***************************************************/
  734. void TIM3_ICInit(TIM3_Channel_TypeDef TIM3_Channel,
  735. TIM3_ICPolarity_TypeDef TIM3_ICPolarity,
  736. TIM3_ICSelection_TypeDef TIM3_ICSelection,
  737. TIM3_ICPSC_TypeDef TIM3_ICPrescaler,
  738. uint8_t TIM3_ICFilter);
  739. void TIM3_PWMIConfig(TIM3_Channel_TypeDef TIM3_Channel,
  740. TIM3_ICPolarity_TypeDef TIM3_ICPolarity,
  741. TIM3_ICSelection_TypeDef TIM3_ICSelection,
  742. TIM3_ICPSC_TypeDef TIM3_ICPrescaler,
  743. uint8_t TIM3_ICFilter);
  744. uint16_t TIM3_GetCapture1(void);
  745. uint16_t TIM3_GetCapture2(void);
  746. void TIM3_SetIC1Prescaler(TIM3_ICPSC_TypeDef TIM3_IC1Prescaler);
  747. void TIM3_SetIC2Prescaler(TIM3_ICPSC_TypeDef TIM3_IC2Prescaler);
  748. /* Interrupts, DMA and flags management ***************************************/
  749. void TIM3_ITConfig(TIM3_IT_TypeDef TIM3_IT, FunctionalState NewState);
  750. void TIM3_GenerateEvent(TIM3_EventSource_TypeDef TIM3_EventSource);
  751. FlagStatus TIM3_GetFlagStatus(TIM3_FLAG_TypeDef TIM3_FLAG);
  752. void TIM3_ClearFlag(TIM3_FLAG_TypeDef TIM3_FLAG);
  753. ITStatus TIM3_GetITStatus(TIM3_IT_TypeDef TIM3_IT);
  754. void TIM3_ClearITPendingBit(TIM3_IT_TypeDef TIM3_IT);
  755. void TIM3_DMACmd(TIM3_DMASource_TypeDef TIM3_DMASource, FunctionalState NewState);
  756. void TIM3_SelectCCDMA(FunctionalState NewState);
  757. /* Clocks management **********************************************************/
  758. void TIM3_InternalClockConfig(void);
  759. void TIM3_TIxExternalClockConfig(TIM3_TIxExternalCLK1Source_TypeDef TIM3_TIxExternalCLKSource,
  760. TIM3_ICPolarity_TypeDef TIM3_ICPolarity,
  761. uint8_t ICFilter);
  762. void TIM3_ETRClockMode1Config(TIM3_ExtTRGPSC_TypeDef TIM3_ExtTRGPrescaler,
  763. TIM3_ExtTRGPolarity_TypeDef TIM3_ExtTRGPolarity,
  764. uint8_t ExtTRGFilter);
  765. void TIM3_ETRClockMode2Config(TIM3_ExtTRGPSC_TypeDef TIM3_ExtTRGPrescaler,
  766. TIM3_ExtTRGPolarity_TypeDef TIM3_ExtTRGPolarity,
  767. uint8_t ExtTRGFilter);
  768. /* Synchronization management *************************************************/
  769. void TIM3_SelectInputTrigger(TIM3_TRGSelection_TypeDef TIM3_InputTriggerSource);
  770. void TIM3_SelectOutputTrigger(TIM3_TRGOSource_TypeDef TIM3_TRGOSource);
  771. void TIM3_SelectSlaveMode(TIM3_SlaveMode_TypeDef TIM3_SlaveMode);
  772. void TIM3_SelectMasterSlaveMode(FunctionalState NewState);
  773. void TIM3_ETRConfig(TIM3_ExtTRGPSC_TypeDef TIM3_ExtTRGPrescaler,
  774. TIM3_ExtTRGPolarity_TypeDef TIM3_ExtTRGPolarity,
  775. uint8_t ExtTRGFilter);
  776. /* Specific interface management **********************************************/
  777. void TIM3_EncoderInterfaceConfig(TIM3_EncoderMode_TypeDef TIM3_EncoderMode,
  778. TIM3_ICPolarity_TypeDef TIM3_IC1Polarity,
  779. TIM3_ICPolarity_TypeDef TIM3_IC2Polarity);
  780. void TIM3_SelectHallSensor(FunctionalState NewState);
  781. #endif /* __STM8L15x_TIM3_H */
  782. /**
  783. * @}
  784. */
  785. /**
  786. * @}
  787. */
  788. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/