fm33lc0xx_fl_lptim32.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  1. /**
  2. *******************************************************************************************************
  3. * @file fm33lc0xx_fl_lptim32.h
  4. * @author FMSH Application Team
  5. * @brief Head file of LPTIM32 FL Module
  6. *******************************************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) [2019] [Fudan Microelectronics]
  10. * THIS SOFTWARE is licensed under the Mulan PSL v1.
  11. * can use this software according to the terms and conditions of the Mulan PSL v1.
  12. * You may obtain a copy of Mulan PSL v1 at:
  13. * http://license.coscl.org.cn/MulanPSL
  14. * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
  16. * PURPOSE.
  17. * See the Mulan PSL v1 for more details.
  18. *
  19. *******************************************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion---------------------------------------------------------------*/
  22. #ifndef __FM33LC0XX_FL_LPTIM32_H
  23. #define __FM33LC0XX_FL_LPTIM32_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes -------------------------------------------------------------------------------------------*/
  28. #include "fm33lc0xx_fl.h"
  29. /** @addtogroup FM33LC0XX_FL_Driver
  30. * @{
  31. */
  32. /** @defgroup LPTIM32 LPTIM32
  33. * @brief LPTIM32 FL driver
  34. * @{
  35. */
  36. /* Exported types -------------------------------------------------------------------------------------*/
  37. /** @defgroup LPTIM32_FL_ES_INIT LPTIM32 Exported Init structures
  38. * @{
  39. */
  40. /**
  41. * @brief LPTIM32 Init Sturcture Definition
  42. */
  43. typedef struct
  44. {
  45. /* 内部时钟源 */
  46. uint32_t clockSource;
  47. /* 预分频器的时钟源 可选择内部时钟, 也可选择外部时钟 */
  48. uint32_t prescalerClockSource;
  49. /* 预分频系数 */
  50. uint32_t prescaler;
  51. /* 重装值 */
  52. uint32_t autoReload;
  53. /* 定时器工作模式选择 */
  54. uint32_t mode;
  55. /* 单次计数使能 */
  56. uint32_t onePulseMode;
  57. /* ETR异步计数边沿 */
  58. uint32_t countEdge;
  59. /* ETR触发计数边沿 */
  60. uint32_t triggerEdge;
  61. } FL_LPTIM32_InitTypeDef;
  62. /**
  63. * @brief LPTIM32 Output Compare Init Structure Definition
  64. */
  65. typedef struct
  66. {
  67. /* 比较值 */
  68. uint32_t compareValue;
  69. /* 比较输出极性 */
  70. uint32_t OCPolarity;
  71. } FL_LPTIM32_OC_InitTypeDef;
  72. /**
  73. * @brief LPTIM32 Input Capture Init Structure Definition
  74. */
  75. typedef struct
  76. {
  77. /* 通道1捕获源 */
  78. uint32_t ICSource;
  79. /* 输入捕获极性 */
  80. uint32_t ICEdge;
  81. } FL_LPTIM32_IC_InitTypeDef;
  82. /**
  83. * @}
  84. */
  85. /* Exported constants ---------------------------------------------------------------------------------*/
  86. /** @defgroup LPTIM32_FL_Exported_Constants LPTIM32 Exported Constants
  87. * @{
  88. */
  89. #define LPTIM32_CR_EN_Pos (0U)
  90. #define LPTIM32_CR_EN_Msk (0x1U << LPTIM32_CR_EN_Pos)
  91. #define LPTIM32_CR_EN LPTIM32_CR_EN_Msk
  92. #define LPTIM32_CFGR_ETR_AFEN_Pos (24U)
  93. #define LPTIM32_CFGR_ETR_AFEN_Msk (0x1U << LPTIM32_CFGR_ETR_AFEN_Pos)
  94. #define LPTIM32_CFGR_ETR_AFEN LPTIM32_CFGR_ETR_AFEN_Msk
  95. #define LPTIM32_CFGR_PSCSEL_Pos (14U)
  96. #define LPTIM32_CFGR_PSCSEL_Msk (0x1U << LPTIM32_CFGR_PSCSEL_Pos)
  97. #define LPTIM32_CFGR_PSCSEL LPTIM32_CFGR_PSCSEL_Msk
  98. #define LPTIM32_CFGR_LPTINSEL_Pos (13U)
  99. #define LPTIM32_CFGR_LPTINSEL_Msk (0x1U << LPTIM32_CFGR_LPTINSEL_Pos)
  100. #define LPTIM32_CFGR_LPTINSEL LPTIM32_CFGR_LPTINSEL_Msk
  101. #define LPTIM32_CFGR_DIVSEL_Pos (10U)
  102. #define LPTIM32_CFGR_DIVSEL_Msk (0x7U << LPTIM32_CFGR_DIVSEL_Pos)
  103. #define LPTIM32_CFGR_DIVSEL LPTIM32_CFGR_DIVSEL_Msk
  104. #define LPTIM32_CFGR_EDGESEL_Pos (7U)
  105. #define LPTIM32_CFGR_EDGESEL_Msk (0x1U << LPTIM32_CFGR_EDGESEL_Pos)
  106. #define LPTIM32_CFGR_EDGESEL LPTIM32_CFGR_EDGESEL_Msk
  107. #define LPTIM32_CFGR_TRIGCFG_Pos (5U)
  108. #define LPTIM32_CFGR_TRIGCFG_Msk (0x3U << LPTIM32_CFGR_TRIGCFG_Pos)
  109. #define LPTIM32_CFGR_TRIGCFG LPTIM32_CFGR_TRIGCFG_Msk
  110. #define LPTIM32_CFGR_ONST_Pos (2U)
  111. #define LPTIM32_CFGR_ONST_Msk (0x1U << LPTIM32_CFGR_ONST_Pos)
  112. #define LPTIM32_CFGR_ONST LPTIM32_CFGR_ONST_Msk
  113. #define LPTIM32_CFGR_TMOD_Pos (0U)
  114. #define LPTIM32_CFGR_TMOD_Msk (0x3U << LPTIM32_CFGR_TMOD_Pos)
  115. #define LPTIM32_CFGR_TMOD LPTIM32_CFGR_TMOD_Msk
  116. #define LPTIM32_IER_CCIE_Pos (0U)
  117. #define LPTIM32_IER_CCIE_Msk (0x3U << LPTIM32_IER_CCIE_Pos)
  118. #define LPTIM32_IER_CCIE LPTIM32_IER_CCIE_Msk
  119. #define LPTIM32_IER_OVIE_Pos (2U)
  120. #define LPTIM32_IER_OVIE_Msk (0x1U << LPTIM32_IER_OVIE_Pos)
  121. #define LPTIM32_IER_OVIE LPTIM32_IER_OVIE_Msk
  122. #define LPTIM32_IER_TRIGIE_Pos (3U)
  123. #define LPTIM32_IER_TRIGIE_Msk (0x1U << LPTIM32_IER_TRIGIE_Pos)
  124. #define LPTIM32_IER_TRIGIE LPTIM32_IER_TRIGIE_Msk
  125. #define LPTIM32_IER_OVRIE_Pos (8U)
  126. #define LPTIM32_IER_OVRIE_Msk (0x3U << LPTIM32_IER_OVRIE_Pos)
  127. #define LPTIM32_IER_OVRIE LPTIM32_IER_OVRIE_Msk
  128. #define LPTIM32_ISR_CCIF_Pos (0U)
  129. #define LPTIM32_ISR_CCIF_Msk (0x3U << LPTIM32_ISR_CCIF_Pos)
  130. #define LPTIM32_ISR_CCIF LPTIM32_ISR_CCIF_Msk
  131. #define LPTIM32_ISR_OVIF_Pos (2U)
  132. #define LPTIM32_ISR_OVIF_Msk (0x1U << LPTIM32_ISR_OVIF_Pos)
  133. #define LPTIM32_ISR_OVIF LPTIM32_ISR_OVIF_Msk
  134. #define LPTIM32_ISR_TRIGIF_Pos (3U)
  135. #define LPTIM32_ISR_TRIGIF_Msk (0x1U << LPTIM32_ISR_TRIGIF_Pos)
  136. #define LPTIM32_ISR_TRIGIF LPTIM32_ISR_TRIGIF_Msk
  137. #define LPTIM32_ISR_CAPOVR_Pos (8U)
  138. #define LPTIM32_ISR_CAPOVR_Msk (0x3U << LPTIM32_ISR_CAPOVR_Pos)
  139. #define LPTIM32_ISR_CAPOVR LPTIM32_ISR_CAPOVR_Msk
  140. #define LPTIM32_CCSR_CAPCFG_Pos (8U)
  141. #define LPTIM32_CCSR_CAPCFG_Msk (0x3U << LPTIM32_CCSR_CAPCFG_Pos)
  142. #define LPTIM32_CCSR_CAPCFG LPTIM32_CCSR_CAPCFG_Msk
  143. #define LPTIM32_CCSR_POLAR_Pos (4U)
  144. #define LPTIM32_CCSR_POLAR_Msk (0x1U << LPTIM32_CCSR_POLAR_Pos)
  145. #define LPTIM32_CCSR_POLAR LPTIM32_CCSR_POLAR_Msk
  146. #define LPTIM32_CCSR_CCS_Pos (0U)
  147. #define LPTIM32_CCSR_CCS_Msk (0x3U << LPTIM32_CCSR_CCS_Pos)
  148. #define LPTIM32_CCSR_CCS LPTIM32_CCSR_CCS_Msk
  149. #define LPTIM32_CCSR_CAPEDGE_Pos (20U)
  150. #define LPTIM32_CCSR_CAPEDGE_Msk (0x3U << LPTIM32_CCSR_CAPEDGE_Pos)
  151. #define LPTIM32_CCSR_CAPEDGE LPTIM32_CCSR_CAPEDGE_Msk
  152. #define LPTIM32_CCSR_CAPSSEL_Pos (16U)
  153. #define LPTIM32_CCSR_CAPSSEL_Msk (0x3U << LPTIM32_CCSR_CAPSSEL_Pos)
  154. #define LPTIM32_CCSR_CAPSSEL LPTIM32_CCSR_CAPSSEL_Msk
  155. #define FL_LPTIM32_CHANNEL_1 (0x1U << 0U)
  156. #define FL_LPTIM32_CHANNEL_2 (0x1U << 1U)
  157. #define FL_LPTIM32_CLK_SOURCE_INTERNAL (0x0U << LPTIM32_CFGR_PSCSEL_Pos)
  158. #define FL_LPTIM32_CLK_SOURCE_EXTERNAL (0x1U << LPTIM32_CFGR_PSCSEL_Pos)
  159. #define FL_LPTIM32_ETR_SOURCE_EXTERNAL (0x0U << LPTIM32_CFGR_LPTINSEL_Pos)
  160. #define FL_LPTIM32_ETR_SOURCE_ADC_EOC (0x1U << LPTIM32_CFGR_LPTINSEL_Pos)
  161. #define FL_LPTIM32_PSC_DIV1 (0x0U << LPTIM32_CFGR_DIVSEL_Pos)
  162. #define FL_LPTIM32_PSC_DIV2 (0x1U << LPTIM32_CFGR_DIVSEL_Pos)
  163. #define FL_LPTIM32_PSC_DIV4 (0x2U << LPTIM32_CFGR_DIVSEL_Pos)
  164. #define FL_LPTIM32_PSC_DIV8 (0x3U << LPTIM32_CFGR_DIVSEL_Pos)
  165. #define FL_LPTIM32_PSC_DIV16 (0x4U << LPTIM32_CFGR_DIVSEL_Pos)
  166. #define FL_LPTIM32_PSC_DIV32 (0x5U << LPTIM32_CFGR_DIVSEL_Pos)
  167. #define FL_LPTIM32_PSC_DIV64 (0x6U << LPTIM32_CFGR_DIVSEL_Pos)
  168. #define FL_LPTIM32_PSC_DIV128 (0x7U << LPTIM32_CFGR_DIVSEL_Pos)
  169. #define FL_LPTIM32_ETR_COUNT_EDGE_RISING (0x0U << LPTIM32_CFGR_EDGESEL_Pos)
  170. #define FL_LPTIM32_ETR_COUNT_EDGE_FALLING (0x1U << LPTIM32_CFGR_EDGESEL_Pos)
  171. #define FL_LPTIM32_ETR_TRIGGER_EDGE_RISING (0x0U << LPTIM32_CFGR_TRIGCFG_Pos)
  172. #define FL_LPTIM32_ETR_TRIGGER_EDGE_FALLING (0x1U << LPTIM32_CFGR_TRIGCFG_Pos)
  173. #define FL_LPTIM32_ETR_TRIGGER_EDGE_BOTH (0x2U << LPTIM32_CFGR_TRIGCFG_Pos)
  174. #define FL_LPTIM32_ONE_PULSE_MODE_CONTINUOUS (0x0U << LPTIM32_CFGR_ONST_Pos)
  175. #define FL_LPTIM32_ONE_PULSE_MODE_SINGLE (0x1U << LPTIM32_CFGR_ONST_Pos)
  176. #define FL_LPTIM32_OPERATION_MODE_NORMAL (0x0U << LPTIM32_CFGR_TMOD_Pos)
  177. #define FL_LPTIM32_OPERATION_MODE_EXTERNAL_TRIGGER_CNT (0x1U << LPTIM32_CFGR_TMOD_Pos)
  178. #define FL_LPTIM32_OPERATION_MODE_EXTERNAL_ASYNC_PULSE_CNT (0x2U << LPTIM32_CFGR_TMOD_Pos)
  179. #define FL_LPTIM32_OPERATION_MODE_TIMEOUT (0x3U << LPTIM32_CFGR_TMOD_Pos)
  180. #define FL_LPTIM32_IC_EDGE_RISING (0x0U << LPTIM32_CCSR_CAPCFG_Pos)
  181. #define FL_LPTIM32_IC_EDGE_FALLING (0x1U << LPTIM32_CCSR_CAPCFG_Pos)
  182. #define FL_LPTIM32_IC_EDGE_BOTH (0x2U << LPTIM32_CCSR_CAPCFG_Pos)
  183. #define FL_LPTIM32_OC_POLARITY_NORMAL (0x0U << LPTIM32_CCSR_POLAR_Pos)
  184. #define FL_LPTIM32_OC_POLARITY_INVERT (0x1U << LPTIM32_CCSR_POLAR_Pos)
  185. #define FL_LPTIM32_CHANNEL_MODE_DISABLE (0x0U << LPTIM32_CCSR_CCS_Pos)
  186. #define FL_LPTIM32_CHANNEL_MODE_INPUT (0x1U << LPTIM32_CCSR_CCS_Pos)
  187. #define FL_LPTIM32_CHANNEL_MODE_OUTPUT (0x2U << LPTIM32_CCSR_CCS_Pos)
  188. #define FL_LPTIM32_IC_CAPTURED_EDGE_RISING (0x0U << LPTIM32_CCSR_CAPEDGE_Pos)
  189. #define FL_LPTIM32_IC_CAPTURED_EDGE_FALLING (0x1U << LPTIM32_CCSR_CAPEDGE_Pos)
  190. #define FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP0 (0x0U << LPTIM32_CCSR_CAPSSEL_Pos)
  191. #define FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP1 (0x1U << LPTIM32_CCSR_CAPSSEL_Pos)
  192. #define FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP2 (0x2U << LPTIM32_CCSR_CAPSSEL_Pos)
  193. #define FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP3 (0x3U << LPTIM32_CCSR_CAPSSEL_Pos)
  194. /**
  195. * @}
  196. */
  197. /* Exported functions ---------------------------------------------------------------------------------*/
  198. /** @defgroup LPTIM32_FL_Exported_Functions LPTIM32 Exported Functions
  199. * @{
  200. */
  201. /**
  202. * @brief Enable LPTIM32
  203. * @rmtoll CR EN FL_LPTIM32_Enable
  204. * @param LPTIM32x LPTIM32 instance
  205. * @retval None
  206. */
  207. __STATIC_INLINE void FL_LPTIM32_Enable(LPTIM32_Type *LPTIM32x)
  208. {
  209. SET_BIT(LPTIM32x->CR, LPTIM32_CR_EN_Msk);
  210. }
  211. /**
  212. * @brief Disable LPTIM32
  213. * @rmtoll CR EN FL_LPTIM32_Disable
  214. * @param LPTIM32x LPTIM32 instance
  215. * @retval None
  216. */
  217. __STATIC_INLINE void FL_LPTIM32_Disable(LPTIM32_Type *LPTIM32x)
  218. {
  219. CLEAR_BIT(LPTIM32x->CR, LPTIM32_CR_EN_Msk);
  220. }
  221. /**
  222. * @brief Get LPTIM32 Enable Status
  223. * @rmtoll CR EN FL_LPTIM32_IsEnabled
  224. * @param LPTIM32x LPTIM32 instance
  225. * @retval State of bit (1 or 0).
  226. */
  227. __STATIC_INLINE uint32_t FL_LPTIM32_IsEnabled(LPTIM32_Type *LPTIM32x)
  228. {
  229. return (uint32_t)(READ_BIT(LPTIM32x->CR, LPTIM32_CR_EN_Msk) == LPTIM32_CR_EN_Msk);
  230. }
  231. /**
  232. * @brief Enable External Trigger Input Analog Filter
  233. * @rmtoll CFGR ETR_AFEN FL_LPTIM32_EnableETRFilter
  234. * @param LPTIM32x LPTIM32 instance
  235. * @retval None
  236. */
  237. __STATIC_INLINE void FL_LPTIM32_EnableETRFilter(LPTIM32_Type *LPTIM32x)
  238. {
  239. SET_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_ETR_AFEN_Msk);
  240. }
  241. /**
  242. * @brief Disable External Trigger Input Analog Filter
  243. * @rmtoll CFGR ETR_AFEN FL_LPTIM32_DisableETRFilter
  244. * @param LPTIM32x LPTIM32 instance
  245. * @retval None
  246. */
  247. __STATIC_INLINE void FL_LPTIM32_DisableETRFilter(LPTIM32_Type *LPTIM32x)
  248. {
  249. CLEAR_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_ETR_AFEN_Msk);
  250. }
  251. /**
  252. * @brief Get External Trigger Input Analog Filter Enable Status
  253. * @rmtoll CFGR ETR_AFEN FL_LPTIM32_IsEnabledETRFilter
  254. * @param LPTIM32x LPTIM32 instance
  255. * @retval State of bit (1 or 0).
  256. */
  257. __STATIC_INLINE uint32_t FL_LPTIM32_IsEnabledETRFilter(LPTIM32_Type *LPTIM32x)
  258. {
  259. return (uint32_t)(READ_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_ETR_AFEN_Msk) == LPTIM32_CFGR_ETR_AFEN_Msk);
  260. }
  261. /**
  262. * @brief Set Prescaler Input
  263. * @rmtoll CFGR PSCSEL FL_LPTIM32_SetClockSource
  264. * @param LPTIM32x LPTIM32 instance
  265. * @param source This parameter can be one of the following values:
  266. * @arg @ref FL_LPTIM32_CLK_SOURCE_INTERNAL
  267. * @arg @ref FL_LPTIM32_CLK_SOURCE_EXTERNAL
  268. * @retval None
  269. */
  270. __STATIC_INLINE void FL_LPTIM32_SetClockSource(LPTIM32_Type *LPTIM32x, uint32_t source)
  271. {
  272. MODIFY_REG(LPTIM32x->CFGR, LPTIM32_CFGR_PSCSEL_Msk, source);
  273. }
  274. /**
  275. * @brief Get Prescaler Input Setting
  276. * @rmtoll CFGR PSCSEL FL_LPTIM32_GetClockSource
  277. * @param LPTIM32x LPTIM32 instance
  278. * @retval Returned value can be one of the following values:
  279. * @arg @ref FL_LPTIM32_CLK_SOURCE_INTERNAL
  280. * @arg @ref FL_LPTIM32_CLK_SOURCE_EXTERNAL
  281. */
  282. __STATIC_INLINE uint32_t FL_LPTIM32_GetClockSource(LPTIM32_Type *LPTIM32x)
  283. {
  284. return (uint32_t)(READ_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_PSCSEL_Msk));
  285. }
  286. /**
  287. * @brief Set External Trigger Input Source
  288. * @rmtoll CFGR LPTINSEL FL_LPTIM32_SetETRSource
  289. * @param LPTIM32x LPTIM32 instance
  290. * @param Input This parameter can be one of the following values:
  291. * @arg @ref FL_LPTIM32_ETR_SOURCE_EXTERNAL
  292. * @arg @ref FL_LPTIM32_ETR_SOURCE_ADC_EOC
  293. * @retval None
  294. */
  295. __STATIC_INLINE void FL_LPTIM32_SetETRSource(LPTIM32_Type *LPTIM32x, uint32_t Input)
  296. {
  297. MODIFY_REG(LPTIM32x->CFGR, LPTIM32_CFGR_LPTINSEL_Msk, Input);
  298. }
  299. /**
  300. * @brief Get External Trigger Input Source Setting
  301. * @rmtoll CFGR LPTINSEL FL_LPTIM32_GetETRSource
  302. * @param LPTIM32x LPTIM32 instance
  303. * @retval Returned value can be one of the following values:
  304. * @arg @ref FL_LPTIM32_ETR_SOURCE_EXTERNAL
  305. * @arg @ref FL_LPTIM32_ETR_SOURCE_ADC_EOC
  306. */
  307. __STATIC_INLINE uint32_t FL_LPTIM32_GetETRSource(LPTIM32_Type *LPTIM32x)
  308. {
  309. return (uint32_t)(READ_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_LPTINSEL_Msk));
  310. }
  311. /**
  312. * @brief Set Counter Clock Divider
  313. * @rmtoll CFGR DIVSEL FL_LPTIM32_SetPrescaler
  314. * @param LPTIM32x LPTIM32 instance
  315. * @param psc This parameter can be one of the following values:
  316. * @arg @ref FL_LPTIM32_PSC_DIV1
  317. * @arg @ref FL_LPTIM32_PSC_DIV2
  318. * @arg @ref FL_LPTIM32_PSC_DIV4
  319. * @arg @ref FL_LPTIM32_PSC_DIV8
  320. * @arg @ref FL_LPTIM32_PSC_DIV16
  321. * @arg @ref FL_LPTIM32_PSC_DIV32
  322. * @arg @ref FL_LPTIM32_PSC_DIV64
  323. * @arg @ref FL_LPTIM32_PSC_DIV128
  324. * @retval None
  325. */
  326. __STATIC_INLINE void FL_LPTIM32_SetPrescaler(LPTIM32_Type *LPTIM32x, uint32_t psc)
  327. {
  328. MODIFY_REG(LPTIM32x->CFGR, LPTIM32_CFGR_DIVSEL_Msk, psc);
  329. }
  330. /**
  331. * @brief Get Counter Clock Divider Setting
  332. * @rmtoll CFGR DIVSEL FL_LPTIM32_GetPrescaler
  333. * @param LPTIM32x LPTIM32 instance
  334. * @retval Returned value can be one of the following values:
  335. * @arg @ref FL_LPTIM32_PSC_DIV1
  336. * @arg @ref FL_LPTIM32_PSC_DIV2
  337. * @arg @ref FL_LPTIM32_PSC_DIV4
  338. * @arg @ref FL_LPTIM32_PSC_DIV8
  339. * @arg @ref FL_LPTIM32_PSC_DIV16
  340. * @arg @ref FL_LPTIM32_PSC_DIV32
  341. * @arg @ref FL_LPTIM32_PSC_DIV64
  342. * @arg @ref FL_LPTIM32_PSC_DIV128
  343. */
  344. __STATIC_INLINE uint32_t FL_LPTIM32_GetPrescaler(LPTIM32_Type *LPTIM32x)
  345. {
  346. return (uint32_t)(READ_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_DIVSEL_Msk));
  347. }
  348. /**
  349. * @brief Set ETR Input Edge Polarity
  350. * @rmtoll CFGR EDGESEL FL_LPTIM32_SetETRCountEdge
  351. * @param LPTIM32x LPTIM32 instance
  352. * @param edge This parameter can be one of the following values:
  353. * @arg @ref FL_LPTIM32_ETR_COUNT_EDGE_RISING
  354. * @arg @ref FL_LPTIM32_ETR_COUNT_EDGE_FALLING
  355. * @retval None
  356. */
  357. __STATIC_INLINE void FL_LPTIM32_SetETRCountEdge(LPTIM32_Type *LPTIM32x, uint32_t edge)
  358. {
  359. MODIFY_REG(LPTIM32x->CFGR, LPTIM32_CFGR_EDGESEL_Msk, edge);
  360. }
  361. /**
  362. * @brief Get ETR Input Edge Polarity Setting
  363. * @rmtoll CFGR EDGESEL FL_LPTIM32_GetETRCountEdge
  364. * @param LPTIM32x LPTIM32 instance
  365. * @retval Returned value can be one of the following values:
  366. * @arg @ref FL_LPTIM32_ETR_COUNT_EDGE_RISING
  367. * @arg @ref FL_LPTIM32_ETR_COUNT_EDGE_FALLING
  368. */
  369. __STATIC_INLINE uint32_t FL_LPTIM32_GetETRCountEdge(LPTIM32_Type *LPTIM32x)
  370. {
  371. return (uint32_t)(READ_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_EDGESEL_Msk));
  372. }
  373. /**
  374. * @brief Set ETR Trigger Edge Polarity
  375. * @rmtoll CFGR TRIGCFG FL_LPTIM32_SetETRTriggerEdge
  376. * @param LPTIM32x LPTIM32 instance
  377. * @param edge This parameter can be one of the following values:
  378. * @arg @ref FL_LPTIM32_ETR_TRIGGER_EDGE_RISING
  379. * @arg @ref FL_LPTIM32_ETR_TRIGGER_EDGE_FALLING
  380. * @arg @ref FL_LPTIM32_ETR_TRIGGER_EDGE_BOTH
  381. * @retval None
  382. */
  383. __STATIC_INLINE void FL_LPTIM32_SetETRTriggerEdge(LPTIM32_Type *LPTIM32x, uint32_t edge)
  384. {
  385. MODIFY_REG(LPTIM32x->CFGR, LPTIM32_CFGR_TRIGCFG_Msk, edge);
  386. }
  387. /**
  388. * @brief Get ETR Trigger Edge Polarity Setting
  389. * @rmtoll CFGR TRIGCFG FL_LPTIM32_GetETRTriggerEdge
  390. * @param LPTIM32x LPTIM32 instance
  391. * @retval Returned value can be one of the following values:
  392. * @arg @ref FL_LPTIM32_ETR_TRIGGER_EDGE_RISING
  393. * @arg @ref FL_LPTIM32_ETR_TRIGGER_EDGE_FALLING
  394. * @arg @ref FL_LPTIM32_ETR_TRIGGER_EDGE_BOTH
  395. */
  396. __STATIC_INLINE uint32_t FL_LPTIM32_GetETRTriggerEdge(LPTIM32_Type *LPTIM32x)
  397. {
  398. return (uint32_t)(READ_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_TRIGCFG_Msk));
  399. }
  400. /**
  401. * @brief Set One State Timer
  402. * @rmtoll CFGR ONST FL_LPTIM32_SetOnePulseMode
  403. * @param LPTIM32x LPTIM32 instance
  404. * @param mode This parameter can be one of the following values:
  405. * @arg @ref FL_LPTIM32_ONE_PULSE_MODE_CONTINUOUS
  406. * @arg @ref FL_LPTIM32_ONE_PULSE_MODE_SINGLE
  407. * @retval None
  408. */
  409. __STATIC_INLINE void FL_LPTIM32_SetOnePulseMode(LPTIM32_Type *LPTIM32x, uint32_t mode)
  410. {
  411. MODIFY_REG(LPTIM32x->CFGR, LPTIM32_CFGR_ONST_Msk, mode);
  412. }
  413. /**
  414. * @brief Get One State Timer Setting
  415. * @rmtoll CFGR ONST FL_LPTIM32_GetOnePulseMode
  416. * @param LPTIM32x LPTIM32 instance
  417. * @retval Returned value can be one of the following values:
  418. * @arg @ref FL_LPTIM32_ONE_PULSE_MODE_CONTINUOUS
  419. * @arg @ref FL_LPTIM32_ONE_PULSE_MODE_SINGLE
  420. */
  421. __STATIC_INLINE uint32_t FL_LPTIM32_GetOnePulseMode(LPTIM32_Type *LPTIM32x)
  422. {
  423. return (uint32_t)(READ_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_ONST_Msk));
  424. }
  425. /**
  426. * @brief Set Operation Mode
  427. * @rmtoll CFGR TMOD FL_LPTIM32_SetOperationMode
  428. * @param LPTIM32x LPTIM32 instance
  429. * @param mode This parameter can be one of the following values:
  430. * @arg @ref FL_LPTIM32_OPERATION_MODE_NORMAL
  431. * @arg @ref FL_LPTIM32_OPERATION_MODE_EXTERNAL_TRIGGER_CNT
  432. * @arg @ref FL_LPTIM32_OPERATION_MODE_EXTERNAL_ASYNC_PULSE_CNT
  433. * @arg @ref FL_LPTIM32_OPERATION_MODE_TIMEOUT
  434. * @retval None
  435. */
  436. __STATIC_INLINE void FL_LPTIM32_SetOperationMode(LPTIM32_Type *LPTIM32x, uint32_t mode)
  437. {
  438. MODIFY_REG(LPTIM32x->CFGR, LPTIM32_CFGR_TMOD_Msk, mode);
  439. }
  440. /**
  441. * @brief Get Operation Mode Setting
  442. * @rmtoll CFGR TMOD FL_LPTIM32_GetOperationMode
  443. * @param LPTIM32x LPTIM32 instance
  444. * @retval Returned value can be one of the following values:
  445. * @arg @ref FL_LPTIM32_OPERATION_MODE_NORMAL
  446. * @arg @ref FL_LPTIM32_OPERATION_MODE_EXTERNAL_TRIGGER_CNT
  447. * @arg @ref FL_LPTIM32_OPERATION_MODE_EXTERNAL_ASYNC_PULSE_CNT
  448. * @arg @ref FL_LPTIM32_OPERATION_MODE_TIMEOUT
  449. */
  450. __STATIC_INLINE uint32_t FL_LPTIM32_GetOperationMode(LPTIM32_Type *LPTIM32x)
  451. {
  452. return (uint32_t)(READ_BIT(LPTIM32x->CFGR, LPTIM32_CFGR_TMOD_Msk));
  453. }
  454. /**
  455. * @brief Set Channel 1 Compare Value
  456. * @rmtoll CCR1 FL_LPTIM32_WriteCompareCH1
  457. * @param LPTIM32x LPTIM32 instance
  458. * @param compareVal
  459. * @retval None
  460. */
  461. __STATIC_INLINE void FL_LPTIM32_WriteCompareCH1(LPTIM32_Type *LPTIM32x, uint32_t compareVal)
  462. {
  463. MODIFY_REG(LPTIM32x->CCR1, (0xffffffffU << 0U), (compareVal << 0U));
  464. }
  465. /**
  466. * @brief Get Channel 1 Compare Value
  467. * @rmtoll CCR1 FL_LPTIM32_ReadCompareCH1
  468. * @param LPTIM32x LPTIM32 instance
  469. * @retval
  470. */
  471. __STATIC_INLINE uint32_t FL_LPTIM32_ReadCompareCH1(LPTIM32_Type *LPTIM32x)
  472. {
  473. return (uint32_t)(READ_BIT(LPTIM32x->CCR1, (0xffffffffU << 0U)) >> 0U);
  474. }
  475. /**
  476. * @brief Set Channel 2 Compare Value
  477. * @rmtoll CCR2 FL_LPTIM32_WriteCompareCH2
  478. * @param LPTIM32x LPTIM32 instance
  479. * @param compareVal
  480. * @retval None
  481. */
  482. __STATIC_INLINE void FL_LPTIM32_WriteCompareCH2(LPTIM32_Type *LPTIM32x, uint32_t compareVal)
  483. {
  484. MODIFY_REG(LPTIM32x->CCR2, (0xffffffffU << 0U), (compareVal << 0U));
  485. }
  486. /**
  487. * @brief Get Channel 2 Compare Value
  488. * @rmtoll CCR2 FL_LPTIM32_ReadCompareCH2
  489. * @param LPTIM32x LPTIM32 instance
  490. * @retval
  491. */
  492. __STATIC_INLINE uint32_t FL_LPTIM32_ReadCompareCH2(LPTIM32_Type *LPTIM32x)
  493. {
  494. return (uint32_t)(READ_BIT(LPTIM32x->CCR2, (0xffffffffU << 0U)) >> 0U);
  495. }
  496. /**
  497. * @brief Get Channel 1 Capture Value
  498. * @rmtoll CCR1 FL_LPTIM32_ReadCaptureCH1
  499. * @param LPTIM32x LPTIM32 instance
  500. * @retval
  501. */
  502. __STATIC_INLINE uint32_t FL_LPTIM32_ReadCaptureCH1(LPTIM32_Type *LPTIM32x)
  503. {
  504. return (uint32_t)(READ_BIT(LPTIM32x->CCR1, (0xffffffffU << 0U)) >> 0U);
  505. }
  506. /**
  507. * @brief Get Channel 2 Capture Value
  508. * @rmtoll CCR2 FL_LPTIM32_ReadCaptureCH2
  509. * @param LPTIM32x LPTIM32 instance
  510. * @retval
  511. */
  512. __STATIC_INLINE uint32_t FL_LPTIM32_ReadCaptureCH2(LPTIM32_Type *LPTIM32x)
  513. {
  514. return (uint32_t)(READ_BIT(LPTIM32x->CCR2, (0xffffffffU << 0U)) >> 0U);
  515. }
  516. /**
  517. * @brief Enable Capture/Compare Channel1 Interrupt
  518. * @rmtoll IER CCIE FL_LPTIM32_EnableIT_CC
  519. * @param LPTIM32x LPTIM32 instance
  520. * @param channel This parameter can be one of the following values:
  521. * @arg @ref FL_LPTIM32_CHANNEL_1
  522. * @arg @ref FL_LPTIM32_CHANNEL_2
  523. * @retval None
  524. */
  525. __STATIC_INLINE void FL_LPTIM32_EnableIT_CC(LPTIM32_Type *LPTIM32x, uint32_t channel)
  526. {
  527. SET_BIT(LPTIM32x->IER, ((channel & 0x3) << 0x0U));
  528. }
  529. /**
  530. * @brief Enable Counter Overflow Interrupt
  531. * @rmtoll IER OVIE FL_LPTIM32_EnableIT_Update
  532. * @param LPTIM32x LPTIM32 instance
  533. * @retval None
  534. */
  535. __STATIC_INLINE void FL_LPTIM32_EnableIT_Update(LPTIM32_Type *LPTIM32x)
  536. {
  537. SET_BIT(LPTIM32x->IER, LPTIM32_IER_OVIE_Msk);
  538. }
  539. /**
  540. * @brief Enable External Trigger Interrupt
  541. * @rmtoll IER TRIGIE FL_LPTIM32_EnableIT_Trigger
  542. * @param LPTIM32x LPTIM32 instance
  543. * @retval None
  544. */
  545. __STATIC_INLINE void FL_LPTIM32_EnableIT_Trigger(LPTIM32_Type *LPTIM32x)
  546. {
  547. SET_BIT(LPTIM32x->IER, LPTIM32_IER_TRIGIE_Msk);
  548. }
  549. /**
  550. * @brief Enable Channel1 Over-Capture Interrupt
  551. * @rmtoll IER OVRIE FL_LPTIM32_EnableIT_CCOverflow
  552. * @param LPTIM32x LPTIM32 instance
  553. * @param channel This parameter can be one of the following values:
  554. * @arg @ref FL_LPTIM32_CHANNEL_1
  555. * @arg @ref FL_LPTIM32_CHANNEL_2
  556. * @retval None
  557. */
  558. __STATIC_INLINE void FL_LPTIM32_EnableIT_CCOverflow(LPTIM32_Type *LPTIM32x, uint32_t channel)
  559. {
  560. SET_BIT(LPTIM32x->IER, ((channel & 0x3) << 0x8U));
  561. }
  562. /**
  563. * @brief Disable Capture/Compare Channel1 Interrupt
  564. * @rmtoll IER CCIE FL_LPTIM32_DisableIT_CC
  565. * @param LPTIM32x LPTIM32 instance
  566. * @param channel This parameter can be one of the following values:
  567. * @arg @ref FL_LPTIM32_CHANNEL_1
  568. * @arg @ref FL_LPTIM32_CHANNEL_2
  569. * @retval None
  570. */
  571. __STATIC_INLINE void FL_LPTIM32_DisableIT_CC(LPTIM32_Type *LPTIM32x, uint32_t channel)
  572. {
  573. CLEAR_BIT(LPTIM32x->IER, ((channel & 0x3) << 0x0U));
  574. }
  575. /**
  576. * @brief Disable Counter Overflow Interrupt
  577. * @rmtoll IER OVIE FL_LPTIM32_DisableIT_Update
  578. * @param LPTIM32x LPTIM32 instance
  579. * @retval None
  580. */
  581. __STATIC_INLINE void FL_LPTIM32_DisableIT_Update(LPTIM32_Type *LPTIM32x)
  582. {
  583. CLEAR_BIT(LPTIM32x->IER, LPTIM32_IER_OVIE_Msk);
  584. }
  585. /**
  586. * @brief Disable External Trigger Interrupt
  587. * @rmtoll IER TRIGIE FL_LPTIM32_DisableIT_Trigger
  588. * @param LPTIM32x LPTIM32 instance
  589. * @retval None
  590. */
  591. __STATIC_INLINE void FL_LPTIM32_DisableIT_Trigger(LPTIM32_Type *LPTIM32x)
  592. {
  593. CLEAR_BIT(LPTIM32x->IER, LPTIM32_IER_TRIGIE_Msk);
  594. }
  595. /**
  596. * @brief Disable Channel1 Over-Capture Interrupt
  597. * @rmtoll IER OVRIE FL_LPTIM32_DisableIT_CCOverflow
  598. * @param LPTIM32x LPTIM32 instance
  599. * @param channel This parameter can be one of the following values:
  600. * @arg @ref FL_LPTIM32_CHANNEL_1
  601. * @arg @ref FL_LPTIM32_CHANNEL_2
  602. * @retval None
  603. */
  604. __STATIC_INLINE void FL_LPTIM32_DisableIT_CCOverflow(LPTIM32_Type *LPTIM32x, uint32_t channel)
  605. {
  606. CLEAR_BIT(LPTIM32x->IER, ((channel & 0x3) << 0x8U));
  607. }
  608. /**
  609. * @brief Get Capture/Compare Channel1 Interrupt Enable Status
  610. * @rmtoll IER CCIE FL_LPTIM32_IsEnabledIT_CC
  611. * @param LPTIM32x LPTIM32 instance
  612. * @param channel This parameter can be one of the following values:
  613. * @arg @ref FL_LPTIM32_CHANNEL_1
  614. * @arg @ref FL_LPTIM32_CHANNEL_2
  615. * @retval State of bit (1 or 0).
  616. */
  617. __STATIC_INLINE uint32_t FL_LPTIM32_IsEnabledIT_CC(LPTIM32_Type *LPTIM32x, uint32_t channel)
  618. {
  619. return (uint32_t)(READ_BIT(LPTIM32x->IER, ((channel & 0x3) << 0x0U)) == ((channel & 0x3) << 0x0U));
  620. }
  621. /**
  622. * @brief Get Counter Overflow Interrupt Enable Status
  623. * @rmtoll IER OVIE FL_LPTIM32_IsEnabledIT_Update
  624. * @param LPTIM32x LPTIM32 instance
  625. * @retval State of bit (1 or 0).
  626. */
  627. __STATIC_INLINE uint32_t FL_LPTIM32_IsEnabledIT_Update(LPTIM32_Type *LPTIM32x)
  628. {
  629. return (uint32_t)(READ_BIT(LPTIM32x->IER, LPTIM32_IER_OVIE_Msk) == LPTIM32_IER_OVIE_Msk);
  630. }
  631. /**
  632. * @brief Get External Trigger Interrupt Enable Status
  633. * @rmtoll IER TRIGIE FL_LPTIM32_IsEnabledIT_Trigger
  634. * @param LPTIM32x LPTIM32 instance
  635. * @retval State of bit (1 or 0).
  636. */
  637. __STATIC_INLINE uint32_t FL_LPTIM32_IsEnabledIT_Trigger(LPTIM32_Type *LPTIM32x)
  638. {
  639. return (uint32_t)(READ_BIT(LPTIM32x->IER, LPTIM32_IER_TRIGIE_Msk) == LPTIM32_IER_TRIGIE_Msk);
  640. }
  641. /**
  642. * @brief Get Channel1 Over-Capture Interrupt Enable Status
  643. * @rmtoll IER OVRIE FL_LPTIM32_IsEnabledIT_CCOverflow
  644. * @param LPTIM32x LPTIM32 instance
  645. * @param channel This parameter can be one of the following values:
  646. * @arg @ref FL_LPTIM32_CHANNEL_1
  647. * @arg @ref FL_LPTIM32_CHANNEL_2
  648. * @retval State of bit (1 or 0).
  649. */
  650. __STATIC_INLINE uint32_t FL_LPTIM32_IsEnabledIT_CCOverflow(LPTIM32_Type *LPTIM32x, uint32_t channel)
  651. {
  652. return (uint32_t)(READ_BIT(LPTIM32x->IER, ((channel & 0x3) << 0x8U)) == ((channel & 0x3) << 0x8U));
  653. }
  654. /**
  655. * @brief Get Capture/Compare Channel 1 Interrupt Flag
  656. * @rmtoll ISR CCIF FL_LPTIM32_IsActiveFlag_CC
  657. * @param LPTIM32x LPTIM32 instance
  658. * @param channel This parameter can be one of the following values:
  659. * @arg @ref FL_LPTIM32_CHANNEL_1
  660. * @arg @ref FL_LPTIM32_CHANNEL_2
  661. * @retval Returned value can be one of the following values:
  662. */
  663. __STATIC_INLINE uint32_t FL_LPTIM32_IsActiveFlag_CC(LPTIM32_Type *LPTIM32x, uint32_t channel)
  664. {
  665. return (uint32_t)(READ_BIT(LPTIM32x->ISR, ((channel & 0x3) << 0x0U)) == ((channel & 0x3) << 0x0U));
  666. }
  667. /**
  668. * @brief Get External Trigger Interrupt Flag
  669. * @rmtoll ISR OVIF FL_LPTIM32_IsActiveFlag_Update
  670. * @param LPTIM32x LPTIM32 instance
  671. * @retval State of bit (1 or 0).
  672. */
  673. __STATIC_INLINE uint32_t FL_LPTIM32_IsActiveFlag_Update(LPTIM32_Type *LPTIM32x)
  674. {
  675. return (uint32_t)(READ_BIT(LPTIM32x->ISR, LPTIM32_ISR_OVIF_Msk) == (LPTIM32_ISR_OVIF_Msk));
  676. }
  677. /**
  678. * @brief Get External Trigger Interrupt Flag
  679. * @rmtoll ISR TRIGIF FL_LPTIM32_IsActiveFlag_Trigger
  680. * @param LPTIM32x LPTIM32 instance
  681. * @retval State of bit (1 or 0).
  682. */
  683. __STATIC_INLINE uint32_t FL_LPTIM32_IsActiveFlag_Trigger(LPTIM32_Type *LPTIM32x)
  684. {
  685. return (uint32_t)(READ_BIT(LPTIM32x->ISR, LPTIM32_ISR_TRIGIF_Msk) == (LPTIM32_ISR_TRIGIF_Msk));
  686. }
  687. /**
  688. * @brief Get Channel 1 Over-Capture Interrupt Flag
  689. * @rmtoll ISR CAPOVR FL_LPTIM32_IsActiveFlag_CCOverflow
  690. * @param LPTIM32x LPTIM32 instance
  691. * @param channel This parameter can be one of the following values:
  692. * @arg @ref FL_LPTIM32_CHANNEL_1
  693. * @arg @ref FL_LPTIM32_CHANNEL_2
  694. * @retval Returned value can be one of the following values:
  695. */
  696. __STATIC_INLINE uint32_t FL_LPTIM32_IsActiveFlag_CCOverflow(LPTIM32_Type *LPTIM32x, uint32_t channel)
  697. {
  698. return (uint32_t)(READ_BIT(LPTIM32x->ISR, ((channel & 0x3) << 0x8U)) == ((channel & 0x3) << 0x8U));
  699. }
  700. /**
  701. * @brief Clear Capture/Compare Channel 1 Interrupt Flag
  702. * @rmtoll ISR CCIF FL_LPTIM32_ClearFlag_CC
  703. * @param LPTIM32x LPTIM32 instance
  704. * @param channel This parameter can be one of the following values:
  705. * @arg @ref FL_LPTIM32_CHANNEL_1
  706. * @arg @ref FL_LPTIM32_CHANNEL_2
  707. * @retval None
  708. */
  709. __STATIC_INLINE void FL_LPTIM32_ClearFlag_CC(LPTIM32_Type *LPTIM32x, uint32_t channel)
  710. {
  711. WRITE_REG(LPTIM32x->ISR, ((channel & 0x3) << 0x0U));
  712. }
  713. /**
  714. * @brief Clear External Trigger Interrupt Flag
  715. * @rmtoll ISR OVIF FL_LPTIM32_ClearFlag_Update
  716. * @param LPTIM32x LPTIM32 instance
  717. * @retval None
  718. */
  719. __STATIC_INLINE void FL_LPTIM32_ClearFlag_Update(LPTIM32_Type *LPTIM32x)
  720. {
  721. WRITE_REG(LPTIM32x->ISR, LPTIM32_ISR_OVIF_Msk);
  722. }
  723. /**
  724. * @brief Clear External Trigger Interrupt Flag
  725. * @rmtoll ISR TRIGIF FL_LPTIM32_ClearFlag_Trigger
  726. * @param LPTIM32x LPTIM32 instance
  727. * @retval None
  728. */
  729. __STATIC_INLINE void FL_LPTIM32_ClearFlag_Trigger(LPTIM32_Type *LPTIM32x)
  730. {
  731. WRITE_REG(LPTIM32x->ISR, LPTIM32_ISR_TRIGIF_Msk);
  732. }
  733. /**
  734. * @brief Clear Channel 1 Over-Capture Interrupt Flag
  735. * @rmtoll ISR CAPOVR FL_LPTIM32_ClearFlag_CCOverflow
  736. * @param LPTIM32x LPTIM32 instance
  737. * @param channel This parameter can be one of the following values:
  738. * @arg @ref FL_LPTIM32_CHANNEL_1
  739. * @arg @ref FL_LPTIM32_CHANNEL_2
  740. * @retval None
  741. */
  742. __STATIC_INLINE void FL_LPTIM32_ClearFlag_CCOverflow(LPTIM32_Type *LPTIM32x, uint32_t channel)
  743. {
  744. WRITE_REG(LPTIM32x->ISR, ((channel & 0x3) << 0x8U));
  745. }
  746. /**
  747. * @brief Set Auto Reload Value
  748. * @rmtoll ARR FL_LPTIM32_WriteAutoReload
  749. * @param LPTIM32x LPTIM32 instance
  750. * @param autoReload
  751. * @retval None
  752. */
  753. __STATIC_INLINE void FL_LPTIM32_WriteAutoReload(LPTIM32_Type *LPTIM32x, uint32_t autoReload)
  754. {
  755. MODIFY_REG(LPTIM32x->ARR, (0xffffffffU << 0U), (autoReload << 0U));
  756. }
  757. /**
  758. * @brief Get Auto Reload Value
  759. * @rmtoll ARR FL_LPTIM32_ReadAutoReload
  760. * @param LPTIM32x LPTIM32 instance
  761. * @retval
  762. */
  763. __STATIC_INLINE uint32_t FL_LPTIM32_ReadAutoReload(LPTIM32_Type *LPTIM32x)
  764. {
  765. return (uint32_t)(READ_BIT(LPTIM32x->ARR, (0xffffffffU << 0U)) >> 0U);
  766. }
  767. /**
  768. * @brief Set Input Capture Channel Capture Edge
  769. * @rmtoll CCSR CAPCFG FL_LPTIM32_IC_SetCaptureEdge
  770. * @param LPTIM32x LPTIM32 instance
  771. * @param polarity This parameter can be one of the following values:
  772. * @arg @ref FL_LPTIM32_IC_EDGE_RISING
  773. * @arg @ref FL_LPTIM32_IC_EDGE_FALLING
  774. * @arg @ref FL_LPTIM32_IC_EDGE_BOTH
  775. * @param channel This parameter can be one of the following values:
  776. * @arg @ref FL_LPTIM32_CHANNEL_1
  777. * @arg @ref FL_LPTIM32_CHANNEL_2
  778. * @retval None
  779. */
  780. __STATIC_INLINE void FL_LPTIM32_IC_SetCaptureEdge(LPTIM32_Type *LPTIM32x, uint32_t polarity, uint32_t channel)
  781. {
  782. switch(channel)
  783. {
  784. case FL_LPTIM32_CHANNEL_1:
  785. MODIFY_REG(LPTIM32x->CCSR, (0x3U << 8U), (polarity << 0U));
  786. break;
  787. case FL_LPTIM32_CHANNEL_2:
  788. MODIFY_REG(LPTIM32x->CCSR, (0x3U << 10U), (polarity << 2U));
  789. break;
  790. }
  791. }
  792. /**
  793. * @brief Get Input Capture Channel Capture Edge
  794. * @rmtoll CCSR CAPCFG FL_LPTIM32_IC_GetCaptureEdge
  795. * @param LPTIM32x LPTIM32 instance
  796. * @param channel This parameter can be one of the following values:
  797. * @arg @ref FL_LPTIM32_CHANNEL_1
  798. * @arg @ref FL_LPTIM32_CHANNEL_2
  799. * @retval Returned value can be one of the following values:
  800. * @arg @ref FL_LPTIM32_IC_EDGE_RISING
  801. * @arg @ref FL_LPTIM32_IC_EDGE_FALLING
  802. * @arg @ref FL_LPTIM32_IC_EDGE_BOTH
  803. */
  804. __STATIC_INLINE uint32_t FL_LPTIM32_IC_GetCaptureEdge(LPTIM32_Type *LPTIM32x, uint32_t channel)
  805. {
  806. switch(channel)
  807. {
  808. case FL_LPTIM32_CHANNEL_1:
  809. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x3U << 8U)) >> 0U);
  810. case FL_LPTIM32_CHANNEL_2:
  811. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x3U << 10U)) >> 2U);
  812. default:
  813. return 0;
  814. }
  815. }
  816. /**
  817. * @brief Set Channel Output Compare Polarity
  818. * @rmtoll CCSR POLAR FL_LPTIM32_OC_SetPolarity
  819. * @param LPTIM32x LPTIM32 instance
  820. * @param polarity This parameter can be one of the following values:
  821. * @arg @ref FL_LPTIM32_OC_POLARITY_NORMAL
  822. * @arg @ref FL_LPTIM32_OC_POLARITY_INVERT
  823. * @param channel This parameter can be one of the following values:
  824. * @arg @ref FL_LPTIM32_CHANNEL_1
  825. * @arg @ref FL_LPTIM32_CHANNEL_2
  826. * @retval None
  827. */
  828. __STATIC_INLINE void FL_LPTIM32_OC_SetPolarity(LPTIM32_Type *LPTIM32x, uint32_t polarity, uint32_t channel)
  829. {
  830. switch(channel)
  831. {
  832. case FL_LPTIM32_CHANNEL_1:
  833. MODIFY_REG(LPTIM32x->CCSR, (0x1U << 4U), (polarity << 0U));
  834. break;
  835. case FL_LPTIM32_CHANNEL_2:
  836. MODIFY_REG(LPTIM32x->CCSR, (0x1U << 5U), (polarity << 1U));
  837. break;
  838. }
  839. }
  840. /**
  841. * @brief Get Channel Output Compare Polarity
  842. * @rmtoll CCSR POLAR FL_LPTIM32_OC_GetPolarity
  843. * @param LPTIM32x LPTIM32 instance
  844. * @param channel This parameter can be one of the following values:
  845. * @arg @ref FL_LPTIM32_CHANNEL_1
  846. * @arg @ref FL_LPTIM32_CHANNEL_2
  847. * @retval Returned value can be one of the following values:
  848. * @arg @ref FL_LPTIM32_OC_POLARITY_NORMAL
  849. * @arg @ref FL_LPTIM32_OC_POLARITY_INVERT
  850. */
  851. __STATIC_INLINE uint32_t FL_LPTIM32_OC_GetPolarity(LPTIM32_Type *LPTIM32x, uint32_t channel)
  852. {
  853. switch(channel)
  854. {
  855. case FL_LPTIM32_CHANNEL_1:
  856. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x1U << 4U)) >> 0U);
  857. case FL_LPTIM32_CHANNEL_2:
  858. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x1U << 5U)) >> 1U);
  859. default:
  860. return 0;
  861. }
  862. }
  863. /**
  864. * @brief Set Channel Operation Mode
  865. * @rmtoll CCSR CCS FL_LPTIM32_SetChannelMode
  866. * @param LPTIM32x LPTIM32 instance
  867. * @param mode This parameter can be one of the following values:
  868. * @arg @ref FL_LPTIM32_CHANNEL_MODE_DISABLE
  869. * @arg @ref FL_LPTIM32_CHANNEL_MODE_INPUT
  870. * @arg @ref FL_LPTIM32_CHANNEL_MODE_OUTPUT
  871. * @param channel This parameter can be one of the following values:
  872. * @arg @ref FL_LPTIM32_CHANNEL_1
  873. * @arg @ref FL_LPTIM32_CHANNEL_2
  874. * @retval None
  875. */
  876. __STATIC_INLINE void FL_LPTIM32_SetChannelMode(LPTIM32_Type *LPTIM32x, uint32_t mode, uint32_t channel)
  877. {
  878. switch(channel)
  879. {
  880. case FL_LPTIM32_CHANNEL_1:
  881. MODIFY_REG(LPTIM32x->CCSR, (0x3U << 0U), (mode << 0U));
  882. break;
  883. case FL_LPTIM32_CHANNEL_2:
  884. MODIFY_REG(LPTIM32x->CCSR, (0x3U << 2U), (mode << 2U));
  885. break;
  886. }
  887. }
  888. /**
  889. * @brief Get Channel Operation Mode
  890. * @rmtoll CCSR CCS FL_LPTIM32_GetChannelMode
  891. * @param LPTIM32x LPTIM32 instance
  892. * @param channel This parameter can be one of the following values:
  893. * @arg @ref FL_LPTIM32_CHANNEL_1
  894. * @arg @ref FL_LPTIM32_CHANNEL_2
  895. * @retval Returned value can be one of the following values:
  896. * @arg @ref FL_LPTIM32_CHANNEL_MODE_DISABLE
  897. * @arg @ref FL_LPTIM32_CHANNEL_MODE_INPUT
  898. * @arg @ref FL_LPTIM32_CHANNEL_MODE_OUTPUT
  899. */
  900. __STATIC_INLINE uint32_t FL_LPTIM32_GetChannelMode(LPTIM32_Type *LPTIM32x, uint32_t channel)
  901. {
  902. switch(channel)
  903. {
  904. case FL_LPTIM32_CHANNEL_1:
  905. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x3U << 0U)) >> 0U);
  906. case FL_LPTIM32_CHANNEL_2:
  907. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x3U << 2U)) >> 2U);
  908. default:
  909. return 0;
  910. }
  911. }
  912. /**
  913. * @brief Get Channel Captured Edge
  914. * @rmtoll CCSR CAPEDGE FL_LPTIM32_IC_GetCapturedEdge
  915. * @param LPTIM32x LPTIM32 instance
  916. * @param channel This parameter can be one of the following values:
  917. * @arg @ref FL_LPTIM32_CHANNEL_1
  918. * @arg @ref FL_LPTIM32_CHANNEL_2
  919. * @retval Returned value can be one of the following values:
  920. * @arg @ref FL_LPTIM32_IC_CAPTURED_EDGE_RISING
  921. * @arg @ref FL_LPTIM32_IC_CAPTURED_EDGE_FALLING
  922. */
  923. __STATIC_INLINE uint32_t FL_LPTIM32_IC_GetCapturedEdge(LPTIM32_Type *LPTIM32x, uint32_t channel)
  924. {
  925. switch(channel)
  926. {
  927. case FL_LPTIM32_CHANNEL_1:
  928. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x1U << 12U)) >> 0U);
  929. case FL_LPTIM32_CHANNEL_2:
  930. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x1U << 13U)) >> 1U);
  931. default:
  932. return 0;
  933. }
  934. }
  935. /**
  936. * @brief Set Channel Capture Source
  937. * @rmtoll CCSR CAPSSEL FL_LPTIM32_IC_SetCaptureSource
  938. * @param LPTIM32x LPTIM32 instance
  939. * @param source This parameter can be one of the following values:
  940. * @arg @ref FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP0
  941. * @arg @ref FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP1
  942. * @arg @ref FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP2
  943. * @arg @ref FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP3
  944. * @param channel This parameter can be one of the following values:
  945. * @arg @ref FL_LPTIM32_CHANNEL_1
  946. * @arg @ref FL_LPTIM32_CHANNEL_2
  947. * @retval None
  948. */
  949. __STATIC_INLINE void FL_LPTIM32_IC_SetCaptureSource(LPTIM32_Type *LPTIM32x, uint32_t source, uint32_t channel)
  950. {
  951. switch(channel)
  952. {
  953. case FL_LPTIM32_CHANNEL_1:
  954. MODIFY_REG(LPTIM32x->CCSR, (0x3U << 16U), (source << 0U));
  955. break;
  956. case FL_LPTIM32_CHANNEL_2:
  957. MODIFY_REG(LPTIM32x->CCSR, (0x3U << 18U), (source << 2U));
  958. break;
  959. }
  960. }
  961. /**
  962. * @brief Get Channel Capture Source Setting
  963. * @rmtoll CCSR CAPSSEL FL_LPTIM32_IC_GetCaptureSource
  964. * @param LPTIM32x LPTIM32 instance
  965. * @param channel This parameter can be one of the following values:
  966. * @arg @ref FL_LPTIM32_CHANNEL_1
  967. * @arg @ref FL_LPTIM32_CHANNEL_2
  968. * @retval Returned value can be one of the following values:
  969. * @arg @ref FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP0
  970. * @arg @ref FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP1
  971. * @arg @ref FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP2
  972. * @arg @ref FL_LPTIM32_IC_CAPTURE_SOURCE_GROUP3
  973. */
  974. __STATIC_INLINE uint32_t FL_LPTIM32_IC_GetCaptureSource(LPTIM32_Type *LPTIM32x, uint32_t channel)
  975. {
  976. switch(channel)
  977. {
  978. case FL_LPTIM32_CHANNEL_1:
  979. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x1U << 16U)) >> 0U);
  980. case FL_LPTIM32_CHANNEL_2:
  981. return (uint32_t)(READ_BIT(LPTIM32x->CCSR, (0x1U << 18U)) >> 2U);
  982. default:
  983. return 0;
  984. }
  985. }
  986. /**
  987. * @brief Get LPTIM32 32bit Counter Value
  988. * @rmtoll CNT FL_LPTIM32_ReadCounter
  989. * @param LPTIM32x LPTIM32 instance
  990. * @retval
  991. */
  992. __STATIC_INLINE uint32_t FL_LPTIM32_ReadCounter(LPTIM32_Type *LPTIM32x)
  993. {
  994. return (uint32_t)(READ_BIT(LPTIM32x->CNT, (0xffffffffU << 0U)) >> 0U);
  995. }
  996. /**
  997. * @brief Set LPTIM32 32bit Counter Value
  998. * @rmtoll CNT FL_LPTIM32_WriteCounter
  999. * @param LPTIM32x LPTIM32 instance
  1000. * @param value
  1001. * @retval Returned value can be one of the following values:
  1002. */
  1003. __STATIC_INLINE void FL_LPTIM32_WriteCounter(LPTIM32_Type *LPTIM32x, uint32_t value)
  1004. {
  1005. MODIFY_REG(LPTIM32x->CNT, (0xffffffffU << 0U), (value << 0U));
  1006. }
  1007. /**
  1008. * @}
  1009. */
  1010. /** @defgroup LPTIM32_FL_EF_Init Initialization and de-initialization functions
  1011. * @{
  1012. */
  1013. FL_ErrorStatus FL_LPTIM32_DeInit(LPTIM32_Type *LPTIM32x);
  1014. FL_ErrorStatus FL_LPTIM32_Init(LPTIM32_Type *LPTIM32x, FL_LPTIM32_InitTypeDef *initStruct);
  1015. void FL_LPTIM32_StructInit(FL_LPTIM32_InitTypeDef *initStruct);
  1016. FL_ErrorStatus FL_LPTIM32_IC_Init(LPTIM32_Type *LPTIM32x, uint32_t channel, FL_LPTIM32_IC_InitTypeDef *initStruct_IC);
  1017. void FL_LPTIM32_IC_StructInit(FL_LPTIM32_IC_InitTypeDef *initStruct_IC);
  1018. FL_ErrorStatus FL_LPTIM32_OC_Init(LPTIM32_Type *LPTIM32x, uint32_t channel, FL_LPTIM32_OC_InitTypeDef *initStruct_OC);
  1019. void FL_LPTIM32_OC_StructInit(FL_LPTIM32_OC_InitTypeDef *initStruct_OC);
  1020. /**
  1021. * @}
  1022. */
  1023. /**
  1024. * @}
  1025. */
  1026. /**
  1027. * @}
  1028. */
  1029. #ifdef __cplusplus
  1030. }
  1031. #endif
  1032. #endif /* __FM33LC0XX_FL_LPTIM32_H*/
  1033. /*************************Py_Code_Generator Version: 0.1-0.11-0.2 @ 2020-09-23*************************/
  1034. /*************************(C) COPYRIGHT Fudan Microelectronics **** END OF FILE*************************/