1
0

stm32f4xx_hal_lptim.c 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_lptim.c
  4. * @author MCD Application Team
  5. * @version V1.4.3
  6. * @date 11-December-2015
  7. * @brief LPTIM HAL module driver.
  8. * This file provides firmware functions to manage the following
  9. * functionalities of the Low Power Timer (LPTIM) peripheral:
  10. * + Initialization and de-initialization functions.
  11. * + Start/Stop operation functions in polling mode.
  12. * + Start/Stop operation functions in interrupt mode.
  13. * + Reading operation functions.
  14. * + Peripheral State functions.
  15. *
  16. @verbatim
  17. ==============================================================================
  18. ##### How to use this driver #####
  19. ==============================================================================
  20. [..]
  21. The LPTIM HAL driver can be used as follows:
  22. (#)Initialize the LPTIM low level resources by implementing the
  23. HAL_LPTIM_MspInit():
  24. (##) Enable the LPTIM interface clock using __LPTIMx_CLK_ENABLE().
  25. (##) In case of using interrupts (e.g. HAL_LPTIM_PWM_Start_IT()):
  26. (+++) Configure the LPTIM interrupt priority using HAL_NVIC_SetPriority().
  27. (+++) Enable the LPTIM IRQ handler using HAL_NVIC_EnableIRQ().
  28. (+++) In LPTIM IRQ handler, call HAL_LPTIM_IRQHandler().
  29. (#)Initialize the LPTIM HAL using HAL_LPTIM_Init(). This function
  30. configures mainly:
  31. (##) The instance: LPTIM1.
  32. (##) Clock: the counter clock.
  33. (+++) Source : it can be either the ULPTIM input (IN1) or one of
  34. the internal clock; (APB, LSE, LSI or MSI).
  35. (+++) Prescaler: select the clock divider.
  36. (##) UltraLowPowerClock : To be used only if the ULPTIM is selected
  37. as counter clock source.
  38. (+++) Polarity: polarity of the active edge for the counter unit
  39. if the ULPTIM input is selected.
  40. (+++) SampleTime: clock sampling time to configure the clock glitch
  41. filter.
  42. (##) Trigger: How the counter start.
  43. (+++) Source: trigger can be software or one of the hardware triggers.
  44. (+++) ActiveEdge : only for hardware trigger.
  45. (+++) SampleTime : trigger sampling time to configure the trigger
  46. glitch filter.
  47. (##) OutputPolarity : 2 opposite polarities are possibles.
  48. (##) UpdateMode: specifies whether the update of the autoreload and
  49. the compare values is done immediately or after the end of current
  50. period.
  51. (#)Six modes are available:
  52. (##) PWM Mode: To generate a PWM signal with specified period and pulse,
  53. call HAL_LPTIM_PWM_Start() or HAL_LPTIM_PWM_Start_IT() for interruption
  54. mode.
  55. (##) One Pulse Mode: To generate pulse with specified width in response
  56. to a stimulus, call HAL_LPTIM_OnePulse_Start() or
  57. HAL_LPTIM_OnePulse_Start_IT() for interruption mode.
  58. (##) Set once Mode: In this mode, the output changes the level (from
  59. low level to high level if the output polarity is configured high, else
  60. the opposite) when a compare match occurs. To start this mode, call
  61. HAL_LPTIM_SetOnce_Start() or HAL_LPTIM_SetOnce_Start_IT() for
  62. interruption mode.
  63. (##) Encoder Mode: To use the encoder interface call
  64. HAL_LPTIM_Encoder_Start() or HAL_LPTIM_Encoder_Start_IT() for
  65. interruption mode.
  66. (##) Time out Mode: an active edge on one selected trigger input rests
  67. the counter. The first trigger event will start the timer, any
  68. successive trigger event will reset the counter and the timer will
  69. restart. To start this mode call HAL_LPTIM_TimeOut_Start_IT() or
  70. HAL_LPTIM_TimeOut_Start_IT() for interruption mode.
  71. (##) Counter Mode: counter can be used to count external events on
  72. the LPTIM Input1 or it can be used to count internal clock cycles.
  73. To start this mode, call HAL_LPTIM_Counter_Start() or
  74. HAL_LPTIM_Counter_Start_IT() for interruption mode.
  75. (#) User can stop any process by calling the corresponding API:
  76. HAL_LPTIM_Xxx_Stop() or HAL_LPTIM_Xxx_Stop_IT() if the process is
  77. already started in interruption mode.
  78. (#)Call HAL_LPTIM_DeInit() to deinitialize the LPTIM peripheral.
  79. @endverbatim
  80. ******************************************************************************
  81. * @attention
  82. *
  83. * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  84. *
  85. * Redistribution and use in source and binary forms, with or without modification,
  86. * are permitted provided that the following conditions are met:
  87. * 1. Redistributions of source code must retain the above copyright notice,
  88. * this list of conditions and the following disclaimer.
  89. * 2. Redistributions in binary form must reproduce the above copyright notice,
  90. * this list of conditions and the following disclaimer in the documentation
  91. * and/or other materials provided with the distribution.
  92. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  93. * may be used to endorse or promote products derived from this software
  94. * without specific prior written permission.
  95. *
  96. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  97. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  98. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  99. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  100. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  101. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  102. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  103. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  104. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  105. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  106. *
  107. ******************************************************************************
  108. */
  109. /* Includes ------------------------------------------------------------------*/
  110. #include "stm32f4xx_hal.h"
  111. /** @addtogroup STM32F4xx_HAL_Driver
  112. * @{
  113. */
  114. /** @defgroup LPTIM LPTIM
  115. * @brief LPTIM HAL module driver.
  116. * @{
  117. */
  118. #ifdef HAL_LPTIM_MODULE_ENABLED
  119. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  120. /* Private types -------------------------------------------------------------*/
  121. /** @defgroup LPTIM_Private_Types LPTIM Private Types
  122. * @{
  123. */
  124. /**
  125. * @}
  126. */
  127. /* Private defines -----------------------------------------------------------*/
  128. /** @defgroup LPTIM_Private_Defines LPTIM Private Defines
  129. * @{
  130. */
  131. /**
  132. * @}
  133. */
  134. /* Private variables ---------------------------------------------------------*/
  135. /** @addtogroup LPTIM_Private_Variables LPTIM Private Variables
  136. * @{
  137. */
  138. /**
  139. * @}
  140. */
  141. /* Private constants ---------------------------------------------------------*/
  142. /** @addtogroup LPTIM_Private_Constants LPTIM Private Constants
  143. * @{
  144. */
  145. /**
  146. * @}
  147. */
  148. /* Private macros ------------------------------------------------------------*/
  149. /** @addtogroup LPTIM_Private_Macros LPTIM Private Macros
  150. * @{
  151. */
  152. /**
  153. * @}
  154. */
  155. /* Private function prototypes -----------------------------------------------*/
  156. /** @addtogroup LPTIM_Private_Functions_Prototypes LPTIM Private Functions Prototypes
  157. * @{
  158. */
  159. /**
  160. * @}
  161. */
  162. /* Private functions ---------------------------------------------------------*/
  163. /** @addtogroup LPTIM_Private_Functions LPTIM Private Functions
  164. * @{
  165. */
  166. /**
  167. * @}
  168. */
  169. /* Exported functions ---------------------------------------------------------*/
  170. /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
  171. * @{
  172. */
  173. /** @defgroup LPTIM_Group1 Initialization/de-initialization functions
  174. * @brief Initialization and Configuration functions.
  175. *
  176. @verbatim
  177. ==============================================================================
  178. ##### Initialization and de-initialization functions #####
  179. ==============================================================================
  180. [..] This section provides functions allowing to:
  181. (+) Initialize the LPTIM according to the specified parameters in the
  182. LPTIM_InitTypeDef and creates the associated handle.
  183. (+) DeInitialize the LPTIM peripheral.
  184. (+) Initialize the LPTIM MSP.
  185. (+) DeInitialize LPTIM MSP.
  186. @endverbatim
  187. * @{
  188. */
  189. /**
  190. * @brief Initializes the LPTIM according to the specified parameters in the
  191. * LPTIM_InitTypeDef and creates the associated handle.
  192. * @param hlptim: LPTIM handle
  193. * @retval HAL status
  194. */
  195. HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim)
  196. {
  197. uint32_t tmpcfgr = 0;
  198. /* Check the LPTIM handle allocation */
  199. if(hlptim == NULL)
  200. {
  201. return HAL_ERROR;
  202. }
  203. /* Check the parameters */
  204. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  205. assert_param(IS_LPTIM_CLOCK_SOURCE(hlptim->Init.Clock.Source));
  206. assert_param(IS_LPTIM_CLOCK_PRESCALER(hlptim->Init.Clock.Prescaler));
  207. if ((hlptim->Init.Clock.Source) == LPTIM_CLOCKSOURCE_ULPTIM)
  208. {
  209. assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));
  210. assert_param(IS_LPTIM_CLOCK_SAMPLE_TIME(hlptim->Init.UltraLowPowerClock.SampleTime));
  211. }
  212. assert_param(IS_LPTIM_TRG_SOURCE(hlptim->Init.Trigger.Source));
  213. if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
  214. {
  215. assert_param(IS_LPTIM_TRIG_SAMPLE_TIME(hlptim->Init.Trigger.SampleTime));
  216. assert_param(IS_LPTIM_EXT_TRG_POLARITY(hlptim->Init.Trigger.ActiveEdge));
  217. }
  218. assert_param(IS_LPTIM_OUTPUT_POLARITY(hlptim->Init.OutputPolarity));
  219. assert_param(IS_LPTIM_UPDATE_MODE(hlptim->Init.UpdateMode));
  220. assert_param(IS_LPTIM_COUNTER_SOURCE(hlptim->Init.CounterSource));
  221. if(hlptim->State == HAL_LPTIM_STATE_RESET)
  222. {
  223. /* Allocate lock resource and initialize it */
  224. hlptim->Lock = HAL_UNLOCKED;
  225. /* Init the low level hardware */
  226. HAL_LPTIM_MspInit(hlptim);
  227. }
  228. /* Change the LPTIM state */
  229. hlptim->State = HAL_LPTIM_STATE_BUSY;
  230. /* Get the LPTIMx CFGR value */
  231. tmpcfgr = hlptim->Instance->CFGR;
  232. if ((hlptim->Init.Clock.Source) == LPTIM_CLOCKSOURCE_ULPTIM)
  233. {
  234. tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKPOL | LPTIM_CFGR_CKFLT));
  235. }
  236. if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
  237. {
  238. tmpcfgr &= (uint32_t)(~ (LPTIM_CFGR_TRGFLT | LPTIM_CFGR_TRIGSEL));
  239. }
  240. /* Clear CKSEL, PRESC, TRIGEN, TRGFLT, WAVPOL, PRELOAD & COUNTMODE bits */
  241. tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKSEL | LPTIM_CFGR_TRIGEN | LPTIM_CFGR_PRELOAD |
  242. LPTIM_CFGR_WAVPOL | LPTIM_CFGR_PRESC | LPTIM_CFGR_COUNTMODE ));
  243. /* Set initialization parameters */
  244. tmpcfgr |= (hlptim->Init.Clock.Source |
  245. hlptim->Init.Clock.Prescaler |
  246. hlptim->Init.OutputPolarity |
  247. hlptim->Init.UpdateMode |
  248. hlptim->Init.CounterSource);
  249. if ((hlptim->Init.Clock.Source) == LPTIM_CLOCKSOURCE_ULPTIM)
  250. {
  251. tmpcfgr |= (hlptim->Init.UltraLowPowerClock.Polarity |
  252. hlptim->Init.UltraLowPowerClock.SampleTime);
  253. }
  254. if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
  255. {
  256. /* Enable External trigger and set the trigger source */
  257. tmpcfgr |= (hlptim->Init.Trigger.Source |
  258. hlptim->Init.Trigger.ActiveEdge |
  259. hlptim->Init.Trigger.SampleTime);
  260. }
  261. /* Write to LPTIMx CFGR */
  262. hlptim->Instance->CFGR = tmpcfgr;
  263. /* Change the LPTIM state */
  264. hlptim->State = HAL_LPTIM_STATE_READY;
  265. /* Return function status */
  266. return HAL_OK;
  267. }
  268. /**
  269. * @brief DeInitializes the LPTIM peripheral.
  270. * @param hlptim: LPTIM handle
  271. * @retval HAL status
  272. */
  273. HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim)
  274. {
  275. /* Check the LPTIM handle allocation */
  276. if(hlptim == NULL)
  277. {
  278. return HAL_ERROR;
  279. }
  280. /* Change the LPTIM state */
  281. hlptim->State = HAL_LPTIM_STATE_BUSY;
  282. /* Disable the LPTIM Peripheral Clock */
  283. __HAL_LPTIM_DISABLE(hlptim);
  284. /* DeInit the low level hardware: CLOCK, NVIC.*/
  285. HAL_LPTIM_MspDeInit(hlptim);
  286. /* Change the LPTIM state */
  287. hlptim->State = HAL_LPTIM_STATE_RESET;
  288. /* Release Lock */
  289. __HAL_UNLOCK(hlptim);
  290. /* Return function status */
  291. return HAL_OK;
  292. }
  293. /**
  294. * @brief Initializes the LPTIM MSP.
  295. * @param hlptim: LPTIM handle
  296. * @retval None
  297. */
  298. __weak void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim)
  299. {
  300. /* Prevent unused argument(s) compilation warning */
  301. UNUSED(hlptim);
  302. /* NOTE : This function Should not be modified, when the callback is needed,
  303. the HAL_LPTIM_MspInit could be implemented in the user file
  304. */
  305. }
  306. /**
  307. * @brief DeInitializes LPTIM MSP.
  308. * @param hlptim: LPTIM handle
  309. * @retval None
  310. */
  311. __weak void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim)
  312. {
  313. /* Prevent unused argument(s) compilation warning */
  314. UNUSED(hlptim);
  315. /* NOTE : This function Should not be modified, when the callback is needed,
  316. the HAL_LPTIM_MspDeInit could be implemented in the user file
  317. */
  318. }
  319. /**
  320. * @}
  321. */
  322. /** @defgroup LPTIM_Group2 LPTIM Start-Stop operation functions
  323. * @brief Start-Stop operation functions.
  324. *
  325. @verbatim
  326. ==============================================================================
  327. ##### LPTIM Start Stop operation functions #####
  328. ==============================================================================
  329. [..] This section provides functions allowing to:
  330. (+) Start the PWM mode.
  331. (+) Stop the PWM mode.
  332. (+) Start the One pulse mode.
  333. (+) Stop the One pulse mode.
  334. (+) Start the Set once mode.
  335. (+) Stop the Set once mode.
  336. (+) Start the Encoder mode.
  337. (+) Stop the Encoder mode.
  338. (+) Start the Timeout mode.
  339. (+) Stop the Timeout mode.
  340. (+) Start the Counter mode.
  341. (+) Stop the Counter mode.
  342. @endverbatim
  343. * @{
  344. */
  345. /**
  346. * @brief Starts the LPTIM PWM generation.
  347. * @param hlptim : LPTIM handle
  348. * @param Period : Specifies the Autoreload value.
  349. * This parameter must be a value between 0x0000 and 0xFFFF.
  350. * @param Pulse : Specifies the compare value.
  351. * This parameter must be a value between 0x0000 and 0xFFFF.
  352. * @retval HAL status
  353. */
  354. HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
  355. {
  356. /* Check the parameters */
  357. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  358. assert_param(IS_LPTIM_PERIOD(Period));
  359. assert_param(IS_LPTIM_PULSE(Pulse));
  360. /* Set the LPTIM state */
  361. hlptim->State= HAL_LPTIM_STATE_BUSY;
  362. /* Reset WAVE bit to set PWM mode */
  363. hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;
  364. /* Enable the Peripheral */
  365. __HAL_LPTIM_ENABLE(hlptim);
  366. /* Load the period value in the autoreload register */
  367. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  368. /* Load the pulse value in the compare register */
  369. __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
  370. /* Start timer in continuous mode */
  371. __HAL_LPTIM_START_CONTINUOUS(hlptim);
  372. /* Change the TIM state*/
  373. hlptim->State= HAL_LPTIM_STATE_READY;
  374. /* Return function status */
  375. return HAL_OK;
  376. }
  377. /**
  378. * @brief Stops the LPTIM PWM generation.
  379. * @param hlptim : LPTIM handle
  380. * @retval HAL status
  381. */
  382. HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim)
  383. {
  384. /* Check the parameters */
  385. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  386. /* Set the LPTIM state */
  387. hlptim->State= HAL_LPTIM_STATE_BUSY;
  388. /* Disable the Peripheral */
  389. __HAL_LPTIM_DISABLE(hlptim);
  390. /* Change the TIM state*/
  391. hlptim->State= HAL_LPTIM_STATE_READY;
  392. /* Return function status */
  393. return HAL_OK;
  394. }
  395. /**
  396. * @brief Starts the LPTIM PWM generation in interrupt mode.
  397. * @param hlptim : LPTIM handle
  398. * @param Period : Specifies the Autoreload value.
  399. * This parameter must be a value between 0x0000 and 0xFFFF
  400. * @param Pulse : Specifies the compare value.
  401. * This parameter must be a value between 0x0000 and 0xFFFF
  402. * @retval HAL status
  403. */
  404. HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
  405. {
  406. /* Check the parameters */
  407. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  408. assert_param(IS_LPTIM_PERIOD(Period));
  409. assert_param(IS_LPTIM_PULSE(Pulse));
  410. /* Set the LPTIM state */
  411. hlptim->State= HAL_LPTIM_STATE_BUSY;
  412. /* Reset WAVE bit to set PWM mode */
  413. hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;
  414. /* Enable Autoreload write complete interrupt */
  415. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);
  416. /* Enable Compare write complete interrupt */
  417. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);
  418. /* Enable Autoreload match interrupt */
  419. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);
  420. /* Enable Compare match interrupt */
  421. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);
  422. /* If external trigger source is used, then enable external trigger interrupt */
  423. if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
  424. {
  425. /* Enable external trigger interrupt */
  426. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
  427. }
  428. /* Enable the Peripheral */
  429. __HAL_LPTIM_ENABLE(hlptim);
  430. /* Load the period value in the autoreload register */
  431. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  432. /* Load the pulse value in the compare register */
  433. __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
  434. /* Start timer in continuous mode */
  435. __HAL_LPTIM_START_CONTINUOUS(hlptim);
  436. /* Change the TIM state*/
  437. hlptim->State= HAL_LPTIM_STATE_READY;
  438. /* Return function status */
  439. return HAL_OK;
  440. }
  441. /**
  442. * @brief Stops the LPTIM PWM generation in interrupt mode.
  443. * @param hlptim : LPTIM handle
  444. * @retval HAL status
  445. */
  446. HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim)
  447. {
  448. /* Check the parameters */
  449. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  450. /* Set the LPTIM state */
  451. hlptim->State= HAL_LPTIM_STATE_BUSY;
  452. /* Disable the Peripheral */
  453. __HAL_LPTIM_DISABLE(hlptim);
  454. /* Disable Autoreload write complete interrupt */
  455. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);
  456. /* Disable Compare write complete interrupt */
  457. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);
  458. /* Disable Autoreload match interrupt */
  459. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);
  460. /* Disable Compare match interrupt */
  461. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);
  462. /* If external trigger source is used, then disable external trigger interrupt */
  463. if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
  464. {
  465. /* Disable external trigger interrupt */
  466. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
  467. }
  468. /* Change the TIM state*/
  469. hlptim->State= HAL_LPTIM_STATE_READY;
  470. /* Return function status */
  471. return HAL_OK;
  472. }
  473. /**
  474. * @brief Starts the LPTIM One pulse generation.
  475. * @param hlptim : LPTIM handle
  476. * @param Period : Specifies the Autoreload value.
  477. * This parameter must be a value between 0x0000 and 0xFFFF.
  478. * @param Pulse : Specifies the compare value.
  479. * This parameter must be a value between 0x0000 and 0xFFFF.
  480. * @retval HAL status
  481. */
  482. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
  483. {
  484. /* Check the parameters */
  485. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  486. assert_param(IS_LPTIM_PERIOD(Period));
  487. assert_param(IS_LPTIM_PULSE(Pulse));
  488. /* Set the LPTIM state */
  489. hlptim->State= HAL_LPTIM_STATE_BUSY;
  490. /* Reset WAVE bit to set one pulse mode */
  491. hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;
  492. /* Enable the Peripheral */
  493. __HAL_LPTIM_ENABLE(hlptim);
  494. /* Load the period value in the autoreload register */
  495. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  496. /* Load the pulse value in the compare register */
  497. __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
  498. /* Start timer in continuous mode */
  499. __HAL_LPTIM_START_SINGLE(hlptim);
  500. /* Change the TIM state*/
  501. hlptim->State= HAL_LPTIM_STATE_READY;
  502. /* Return function status */
  503. return HAL_OK;
  504. }
  505. /**
  506. * @brief Stops the LPTIM One pulse generation.
  507. * @param hlptim : LPTIM handle
  508. * @retval HAL status
  509. */
  510. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim)
  511. {
  512. /* Check the parameters */
  513. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  514. /* Set the LPTIM state */
  515. hlptim->State= HAL_LPTIM_STATE_BUSY;
  516. /* Disable the Peripheral */
  517. __HAL_LPTIM_DISABLE(hlptim);
  518. /* Change the TIM state*/
  519. hlptim->State= HAL_LPTIM_STATE_READY;
  520. /* Return function status */
  521. return HAL_OK;
  522. }
  523. /**
  524. * @brief Starts the LPTIM One pulse generation in interrupt mode.
  525. * @param hlptim : LPTIM handle
  526. * @param Period : Specifies the Autoreload value.
  527. * This parameter must be a value between 0x0000 and 0xFFFF.
  528. * @param Pulse : Specifies the compare value.
  529. * This parameter must be a value between 0x0000 and 0xFFFF.
  530. * @retval HAL status
  531. */
  532. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
  533. {
  534. /* Check the parameters */
  535. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  536. assert_param(IS_LPTIM_PERIOD(Period));
  537. assert_param(IS_LPTIM_PULSE(Pulse));
  538. /* Set the LPTIM state */
  539. hlptim->State= HAL_LPTIM_STATE_BUSY;
  540. /* Reset WAVE bit to set one pulse mode */
  541. hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;
  542. /* Enable Autoreload write complete interrupt */
  543. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);
  544. /* Enable Compare write complete interrupt */
  545. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);
  546. /* Enable Autoreload match interrupt */
  547. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);
  548. /* Enable Compare match interrupt */
  549. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);
  550. /* If external trigger source is used, then enable external trigger interrupt */
  551. if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
  552. {
  553. /* Enable external trigger interrupt */
  554. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
  555. }
  556. /* Enable the Peripheral */
  557. __HAL_LPTIM_ENABLE(hlptim);
  558. /* Load the period value in the autoreload register */
  559. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  560. /* Load the pulse value in the compare register */
  561. __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
  562. /* Start timer in continuous mode */
  563. __HAL_LPTIM_START_SINGLE(hlptim);
  564. /* Change the TIM state*/
  565. hlptim->State= HAL_LPTIM_STATE_READY;
  566. /* Return function status */
  567. return HAL_OK;
  568. }
  569. /**
  570. * @brief Stops the LPTIM One pulse generation in interrupt mode.
  571. * @param hlptim : LPTIM handle
  572. * @retval HAL status
  573. */
  574. HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim)
  575. {
  576. /* Check the parameters */
  577. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  578. /* Set the LPTIM state */
  579. hlptim->State= HAL_LPTIM_STATE_BUSY;
  580. /* Disable the Peripheral */
  581. __HAL_LPTIM_DISABLE(hlptim);
  582. /* Disable Autoreload write complete interrupt */
  583. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);
  584. /* Disable Compare write complete interrupt */
  585. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);
  586. /* Disable Autoreload match interrupt */
  587. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);
  588. /* Disable Compare match interrupt */
  589. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);
  590. /* If external trigger source is used, then disable external trigger interrupt */
  591. if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
  592. {
  593. /* Disable external trigger interrupt */
  594. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
  595. }
  596. /* Change the TIM state*/
  597. hlptim->State= HAL_LPTIM_STATE_READY;
  598. /* Return function status */
  599. return HAL_OK;
  600. }
  601. /**
  602. * @brief Starts the LPTIM in Set once mode.
  603. * @param hlptim : LPTIM handle
  604. * @param Period : Specifies the Autoreload value.
  605. * This parameter must be a value between 0x0000 and 0xFFFF.
  606. * @param Pulse : Specifies the compare value.
  607. * This parameter must be a value between 0x0000 and 0xFFFF.
  608. * @retval HAL status
  609. */
  610. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
  611. {
  612. /* Check the parameters */
  613. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  614. assert_param(IS_LPTIM_PERIOD(Period));
  615. assert_param(IS_LPTIM_PULSE(Pulse));
  616. /* Set the LPTIM state */
  617. hlptim->State= HAL_LPTIM_STATE_BUSY;
  618. /* Set WAVE bit to enable the set once mode */
  619. hlptim->Instance->CFGR |= LPTIM_CFGR_WAVE;
  620. /* Enable the Peripheral */
  621. __HAL_LPTIM_ENABLE(hlptim);
  622. /* Load the period value in the autoreload register */
  623. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  624. /* Load the pulse value in the compare register */
  625. __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
  626. /* Start timer in single mode */
  627. __HAL_LPTIM_START_SINGLE(hlptim);
  628. /* Change the TIM state*/
  629. hlptim->State= HAL_LPTIM_STATE_READY;
  630. /* Return function status */
  631. return HAL_OK;
  632. }
  633. /**
  634. * @brief Stops the LPTIM Set once mode.
  635. * @param hlptim : LPTIM handle
  636. * @retval HAL status
  637. */
  638. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim)
  639. {
  640. /* Check the parameters */
  641. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  642. /* Set the LPTIM state */
  643. hlptim->State= HAL_LPTIM_STATE_BUSY;
  644. /* Disable the Peripheral */
  645. __HAL_LPTIM_DISABLE(hlptim);
  646. /* Change the TIM state*/
  647. hlptim->State= HAL_LPTIM_STATE_READY;
  648. /* Return function status */
  649. return HAL_OK;
  650. }
  651. /**
  652. * @brief Starts the LPTIM Set once mode in interrupt mode.
  653. * @param hlptim : LPTIM handle
  654. * @param Period : Specifies the Autoreload value.
  655. * This parameter must be a value between 0x0000 and 0xFFFF.
  656. * @param Pulse : Specifies the compare value.
  657. * This parameter must be a value between 0x0000 and 0xFFFF.
  658. * @retval HAL status
  659. */
  660. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
  661. {
  662. /* Check the parameters */
  663. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  664. assert_param(IS_LPTIM_PERIOD(Period));
  665. assert_param(IS_LPTIM_PULSE(Pulse));
  666. /* Set the LPTIM state */
  667. hlptim->State= HAL_LPTIM_STATE_BUSY;
  668. /* Set WAVE bit to enable the set once mode */
  669. hlptim->Instance->CFGR |= LPTIM_CFGR_WAVE;
  670. /* Enable Autoreload write complete interrupt */
  671. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);
  672. /* Enable Compare write complete interrupt */
  673. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);
  674. /* Enable Autoreload match interrupt */
  675. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);
  676. /* Enable Compare match interrupt */
  677. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);
  678. /* If external trigger source is used, then enable external trigger interrupt */
  679. if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
  680. {
  681. /* Enable external trigger interrupt */
  682. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
  683. }
  684. /* Enable the Peripheral */
  685. __HAL_LPTIM_ENABLE(hlptim);
  686. /* Load the period value in the autoreload register */
  687. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  688. /* Load the pulse value in the compare register */
  689. __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
  690. /* Start timer in single mode */
  691. __HAL_LPTIM_START_SINGLE(hlptim);
  692. /* Change the TIM state*/
  693. hlptim->State= HAL_LPTIM_STATE_READY;
  694. /* Return function status */
  695. return HAL_OK;
  696. }
  697. /**
  698. * @brief Stops the LPTIM Set once mode in interrupt mode.
  699. * @param hlptim : LPTIM handle
  700. * @retval HAL status
  701. */
  702. HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim)
  703. {
  704. /* Check the parameters */
  705. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  706. /* Set the LPTIM state */
  707. hlptim->State= HAL_LPTIM_STATE_BUSY;
  708. /* Disable the Peripheral */
  709. __HAL_LPTIM_DISABLE(hlptim);
  710. /* Disable Autoreload write complete interrupt */
  711. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);
  712. /* Disable Compare write complete interrupt */
  713. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);
  714. /* Disable Autoreload match interrupt */
  715. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);
  716. /* Disable Compare match interrupt */
  717. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);
  718. /* If external trigger source is used, then disable external trigger interrupt */
  719. if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
  720. {
  721. /* Disable external trigger interrupt */
  722. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
  723. }
  724. /* Change the TIM state*/
  725. hlptim->State= HAL_LPTIM_STATE_READY;
  726. /* Return function status */
  727. return HAL_OK;
  728. }
  729. /**
  730. * @brief Starts the Encoder interface.
  731. * @param hlptim : LPTIM handle
  732. * @param Period : Specifies the Autoreload value.
  733. * This parameter must be a value between 0x0000 and 0xFFFF.
  734. * @retval HAL status
  735. */
  736. HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period)
  737. {
  738. uint32_t tmpcfgr = 0;
  739. /* Check the parameters */
  740. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  741. assert_param(IS_LPTIM_PERIOD(Period));
  742. assert_param(hlptim->Init.Clock.Source == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC);
  743. assert_param(hlptim->Init.Clock.Prescaler == LPTIM_PRESCALER_DIV1);
  744. assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));
  745. /* Set the LPTIM state */
  746. hlptim->State= HAL_LPTIM_STATE_BUSY;
  747. /* Get the LPTIMx CFGR value */
  748. tmpcfgr = hlptim->Instance->CFGR;
  749. /* Clear CKPOL bits */
  750. tmpcfgr &= (uint32_t)(~LPTIM_CFGR_CKPOL);
  751. /* Set Input polarity */
  752. tmpcfgr |= hlptim->Init.UltraLowPowerClock.Polarity;
  753. /* Write to LPTIMx CFGR */
  754. hlptim->Instance->CFGR = tmpcfgr;
  755. /* Set ENC bit to enable the encoder interface */
  756. hlptim->Instance->CFGR |= LPTIM_CFGR_ENC;
  757. /* Enable the Peripheral */
  758. __HAL_LPTIM_ENABLE(hlptim);
  759. /* Load the period value in the autoreload register */
  760. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  761. /* Start timer in continuous mode */
  762. __HAL_LPTIM_START_CONTINUOUS(hlptim);
  763. /* Change the TIM state*/
  764. hlptim->State= HAL_LPTIM_STATE_READY;
  765. /* Return function status */
  766. return HAL_OK;
  767. }
  768. /**
  769. * @brief Stops the Encoder interface.
  770. * @param hlptim : LPTIM handle
  771. * @retval HAL status
  772. */
  773. HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim)
  774. {
  775. /* Check the parameters */
  776. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  777. /* Set the LPTIM state */
  778. hlptim->State= HAL_LPTIM_STATE_BUSY;
  779. /* Disable the Peripheral */
  780. __HAL_LPTIM_DISABLE(hlptim);
  781. /* Reset ENC bit to disable the encoder interface */
  782. hlptim->Instance->CFGR &= ~LPTIM_CFGR_ENC;
  783. /* Change the TIM state*/
  784. hlptim->State= HAL_LPTIM_STATE_READY;
  785. /* Return function status */
  786. return HAL_OK;
  787. }
  788. /**
  789. * @brief Starts the Encoder interface in interrupt mode.
  790. * @param hlptim : LPTIM handle
  791. * @param Period : Specifies the Autoreload value.
  792. * This parameter must be a value between 0x0000 and 0xFFFF.
  793. * @retval HAL status
  794. */
  795. HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period)
  796. {
  797. uint32_t tmpcfgr = 0;
  798. /* Check the parameters */
  799. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  800. assert_param(IS_LPTIM_PERIOD(Period));
  801. assert_param(hlptim->Init.Clock.Source == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC);
  802. assert_param(hlptim->Init.Clock.Prescaler == LPTIM_PRESCALER_DIV1);
  803. assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));
  804. /* Set the LPTIM state */
  805. hlptim->State= HAL_LPTIM_STATE_BUSY;
  806. /* Configure edge sensitivity for encoder mode */
  807. /* Get the LPTIMx CFGR value */
  808. tmpcfgr = hlptim->Instance->CFGR;
  809. /* Clear CKPOL bits */
  810. tmpcfgr &= (uint32_t)(~LPTIM_CFGR_CKPOL);
  811. /* Set Input polarity */
  812. tmpcfgr |= hlptim->Init.UltraLowPowerClock.Polarity;
  813. /* Write to LPTIMx CFGR */
  814. hlptim->Instance->CFGR = tmpcfgr;
  815. /* Set ENC bit to enable the encoder interface */
  816. hlptim->Instance->CFGR |= LPTIM_CFGR_ENC;
  817. /* Enable "switch to down direction" interrupt */
  818. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_DOWN);
  819. /* Enable "switch to up direction" interrupt */
  820. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_UP);
  821. /* Enable the Peripheral */
  822. __HAL_LPTIM_ENABLE(hlptim);
  823. /* Load the period value in the autoreload register */
  824. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  825. /* Start timer in continuous mode */
  826. __HAL_LPTIM_START_CONTINUOUS(hlptim);
  827. /* Change the TIM state*/
  828. hlptim->State= HAL_LPTIM_STATE_READY;
  829. /* Return function status */
  830. return HAL_OK;
  831. }
  832. /**
  833. * @brief Stops the Encoder interface in interrupt mode.
  834. * @param hlptim : LPTIM handle
  835. * @retval HAL status
  836. */
  837. HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim)
  838. {
  839. /* Check the parameters */
  840. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  841. /* Set the LPTIM state */
  842. hlptim->State= HAL_LPTIM_STATE_BUSY;
  843. /* Disable the Peripheral */
  844. __HAL_LPTIM_DISABLE(hlptim);
  845. /* Reset ENC bit to disable the encoder interface */
  846. hlptim->Instance->CFGR &= ~LPTIM_CFGR_ENC;
  847. /* Disable "switch to down direction" interrupt */
  848. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_DOWN);
  849. /* Disable "switch to up direction" interrupt */
  850. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_UP);
  851. /* Change the TIM state*/
  852. hlptim->State= HAL_LPTIM_STATE_READY;
  853. /* Return function status */
  854. return HAL_OK;
  855. }
  856. /**
  857. * @brief Starts the Timeout function. The first trigger event will start the
  858. * timer, any successive trigger event will reset the counter and
  859. * the timer restarts.
  860. * @param hlptim : LPTIM handle
  861. * @param Period : Specifies the Autoreload value.
  862. * This parameter must be a value between 0x0000 and 0xFFFF.
  863. * @param Timeout : Specifies the TimeOut value to rest the counter.
  864. * This parameter must be a value between 0x0000 and 0xFFFF.
  865. * @retval HAL status
  866. */
  867. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout)
  868. {
  869. /* Check the parameters */
  870. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  871. assert_param(IS_LPTIM_PERIOD(Period));
  872. assert_param(IS_LPTIM_PULSE(Timeout));
  873. /* Set the LPTIM state */
  874. hlptim->State= HAL_LPTIM_STATE_BUSY;
  875. /* Set TIMOUT bit to enable the timeout function */
  876. hlptim->Instance->CFGR |= LPTIM_CFGR_TIMOUT;
  877. /* Enable the Peripheral */
  878. __HAL_LPTIM_ENABLE(hlptim);
  879. /* Load the period value in the autoreload register */
  880. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  881. /* Load the Timeout value in the compare register */
  882. __HAL_LPTIM_COMPARE_SET(hlptim, Timeout);
  883. /* Start timer in continuous mode */
  884. __HAL_LPTIM_START_CONTINUOUS(hlptim);
  885. /* Change the TIM state*/
  886. hlptim->State= HAL_LPTIM_STATE_READY;
  887. /* Return function status */
  888. return HAL_OK;
  889. }
  890. /**
  891. * @brief Stops the Timeout function.
  892. * @param hlptim : LPTIM handle
  893. * @retval HAL status
  894. */
  895. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim)
  896. {
  897. /* Check the parameters */
  898. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  899. /* Set the LPTIM state */
  900. hlptim->State= HAL_LPTIM_STATE_BUSY;
  901. /* Disable the Peripheral */
  902. __HAL_LPTIM_DISABLE(hlptim);
  903. /* Reset TIMOUT bit to enable the timeout function */
  904. hlptim->Instance->CFGR &= ~LPTIM_CFGR_TIMOUT;
  905. /* Change the TIM state*/
  906. hlptim->State= HAL_LPTIM_STATE_READY;
  907. /* Return function status */
  908. return HAL_OK;
  909. }
  910. /**
  911. * @brief Starts the Timeout function in interrupt mode. The first trigger
  912. * event will start the timer, any successive trigger event will reset
  913. * the counter and the timer restarts.
  914. * @param hlptim : LPTIM handle
  915. * @param Period : Specifies the Autoreload value.
  916. * This parameter must be a value between 0x0000 and 0xFFFF.
  917. * @param Timeout : Specifies the TimeOut value to rest the counter.
  918. * This parameter must be a value between 0x0000 and 0xFFFF.
  919. * @retval HAL status
  920. */
  921. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout)
  922. {
  923. /* Check the parameters */
  924. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  925. assert_param(IS_LPTIM_PERIOD(Period));
  926. assert_param(IS_LPTIM_PULSE(Timeout));
  927. /* Set the LPTIM state */
  928. hlptim->State= HAL_LPTIM_STATE_BUSY;
  929. /* Set TIMOUT bit to enable the timeout function */
  930. hlptim->Instance->CFGR |= LPTIM_CFGR_TIMOUT;
  931. /* Enable Compare match interrupt */
  932. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);
  933. /* Enable the Peripheral */
  934. __HAL_LPTIM_ENABLE(hlptim);
  935. /* Load the period value in the autoreload register */
  936. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  937. /* Load the Timeout value in the compare register */
  938. __HAL_LPTIM_COMPARE_SET(hlptim, Timeout);
  939. /* Start timer in continuous mode */
  940. __HAL_LPTIM_START_CONTINUOUS(hlptim);
  941. /* Change the TIM state*/
  942. hlptim->State= HAL_LPTIM_STATE_READY;
  943. /* Return function status */
  944. return HAL_OK;
  945. }
  946. /**
  947. * @brief Stops the Timeout function in interrupt mode.
  948. * @param hlptim : LPTIM handle
  949. * @retval HAL status
  950. */
  951. HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim)
  952. {
  953. /* Check the parameters */
  954. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  955. /* Set the LPTIM state */
  956. hlptim->State= HAL_LPTIM_STATE_BUSY;
  957. /* Disable the Peripheral */
  958. __HAL_LPTIM_DISABLE(hlptim);
  959. /* Reset TIMOUT bit to enable the timeout function */
  960. hlptim->Instance->CFGR &= ~LPTIM_CFGR_TIMOUT;
  961. /* Disable Compare match interrupt */
  962. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);
  963. /* Change the TIM state*/
  964. hlptim->State= HAL_LPTIM_STATE_READY;
  965. /* Return function status */
  966. return HAL_OK;
  967. }
  968. /**
  969. * @brief Starts the Counter mode.
  970. * @param hlptim : LPTIM handle
  971. * @param Period : Specifies the Autoreload value.
  972. * This parameter must be a value between 0x0000 and 0xFFFF.
  973. * @retval HAL status
  974. */
  975. HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period)
  976. {
  977. /* Check the parameters */
  978. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  979. assert_param(IS_LPTIM_PERIOD(Period));
  980. /* Set the LPTIM state */
  981. hlptim->State= HAL_LPTIM_STATE_BUSY;
  982. /* If clock source is not ULPTIM clock and counter source is external, then it must not be prescaled */
  983. if((hlptim->Init.Clock.Source != LPTIM_CLOCKSOURCE_ULPTIM) && (hlptim->Init.CounterSource == LPTIM_COUNTERSOURCE_EXTERNAL))
  984. {
  985. /* Check if clock is prescaled */
  986. assert_param(IS_LPTIM_CLOCK_PRESCALERDIV1(hlptim->Init.Clock.Prescaler));
  987. /* Set clock prescaler to 0 */
  988. hlptim->Instance->CFGR &= ~LPTIM_CFGR_PRESC;
  989. }
  990. /* Enable the Peripheral */
  991. __HAL_LPTIM_ENABLE(hlptim);
  992. /* Load the period value in the autoreload register */
  993. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  994. /* Start timer in continuous mode */
  995. __HAL_LPTIM_START_CONTINUOUS(hlptim);
  996. /* Change the TIM state*/
  997. hlptim->State= HAL_LPTIM_STATE_READY;
  998. /* Return function status */
  999. return HAL_OK;
  1000. }
  1001. /**
  1002. * @brief Stops the Counter mode.
  1003. * @param hlptim : LPTIM handle
  1004. * @retval HAL status
  1005. */
  1006. HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim)
  1007. {
  1008. /* Check the parameters */
  1009. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  1010. /* Set the LPTIM state */
  1011. hlptim->State= HAL_LPTIM_STATE_BUSY;
  1012. /* Disable the Peripheral */
  1013. __HAL_LPTIM_DISABLE(hlptim);
  1014. /* Change the TIM state*/
  1015. hlptim->State= HAL_LPTIM_STATE_READY;
  1016. /* Return function status */
  1017. return HAL_OK;
  1018. }
  1019. /**
  1020. * @brief Starts the Counter mode in interrupt mode.
  1021. * @param hlptim : LPTIM handle
  1022. * @param Period : Specifies the Autoreload value.
  1023. * This parameter must be a value between 0x0000 and 0xFFFF.
  1024. * @retval HAL status
  1025. */
  1026. HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period)
  1027. {
  1028. /* Check the parameters */
  1029. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  1030. assert_param(IS_LPTIM_PERIOD(Period));
  1031. /* Set the LPTIM state */
  1032. hlptim->State= HAL_LPTIM_STATE_BUSY;
  1033. /* If clock source is not ULPTIM clock and counter source is external, then it must not be prescaled */
  1034. if((hlptim->Init.Clock.Source != LPTIM_CLOCKSOURCE_ULPTIM) && (hlptim->Init.CounterSource == LPTIM_COUNTERSOURCE_EXTERNAL))
  1035. {
  1036. /* Check if clock is prescaled */
  1037. assert_param(IS_LPTIM_CLOCK_PRESCALERDIV1(hlptim->Init.Clock.Prescaler));
  1038. /* Set clock prescaler to 0 */
  1039. hlptim->Instance->CFGR &= ~LPTIM_CFGR_PRESC;
  1040. }
  1041. /* Enable Autoreload write complete interrupt */
  1042. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);
  1043. /* Enable Autoreload match interrupt */
  1044. __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);
  1045. /* Enable the Peripheral */
  1046. __HAL_LPTIM_ENABLE(hlptim);
  1047. /* Load the period value in the autoreload register */
  1048. __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
  1049. /* Start timer in continuous mode */
  1050. __HAL_LPTIM_START_CONTINUOUS(hlptim);
  1051. /* Change the TIM state*/
  1052. hlptim->State= HAL_LPTIM_STATE_READY;
  1053. /* Return function status */
  1054. return HAL_OK;
  1055. }
  1056. /**
  1057. * @brief Stops the Counter mode in interrupt mode.
  1058. * @param hlptim : LPTIM handle
  1059. * @retval HAL status
  1060. */
  1061. HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim)
  1062. {
  1063. /* Check the parameters */
  1064. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  1065. /* Set the LPTIM state */
  1066. hlptim->State= HAL_LPTIM_STATE_BUSY;
  1067. /* Disable the Peripheral */
  1068. __HAL_LPTIM_DISABLE(hlptim);
  1069. /* Disable Autoreload write complete interrupt */
  1070. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);
  1071. /* Disable Autoreload match interrupt */
  1072. __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);
  1073. /* Change the TIM state*/
  1074. hlptim->State= HAL_LPTIM_STATE_READY;
  1075. /* Return function status */
  1076. return HAL_OK;
  1077. }
  1078. /**
  1079. * @}
  1080. */
  1081. /** @defgroup LPTIM_Group3 LPTIM Read operation functions
  1082. * @brief Read operation functions.
  1083. *
  1084. @verbatim
  1085. ==============================================================================
  1086. ##### LPTIM Read operation functions #####
  1087. ==============================================================================
  1088. [..] This section provides LPTIM Reading functions.
  1089. (+) Read the counter value.
  1090. (+) Read the period (Auto-reload) value.
  1091. (+) Read the pulse (Compare)value.
  1092. @endverbatim
  1093. * @{
  1094. */
  1095. /**
  1096. * @brief This function returns the current counter value.
  1097. * @param hlptim: LPTIM handle
  1098. * @retval Counter value.
  1099. */
  1100. uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim)
  1101. {
  1102. /* Check the parameters */
  1103. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  1104. return (hlptim->Instance->CNT);
  1105. }
  1106. /**
  1107. * @brief This function return the current Autoreload (Period) value.
  1108. * @param hlptim: LPTIM handle
  1109. * @retval Autoreload value.
  1110. */
  1111. uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim)
  1112. {
  1113. /* Check the parameters */
  1114. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  1115. return (hlptim->Instance->ARR);
  1116. }
  1117. /**
  1118. * @brief This function return the current Compare (Pulse) value.
  1119. * @param hlptim: LPTIM handle
  1120. * @retval Compare value.
  1121. */
  1122. uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim)
  1123. {
  1124. /* Check the parameters */
  1125. assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
  1126. return (hlptim->Instance->CMP);
  1127. }
  1128. /**
  1129. * @}
  1130. */
  1131. /** @defgroup LPTIM_Group4 LPTIM IRQ handler
  1132. * @brief LPTIM IRQ handler.
  1133. *
  1134. @verbatim
  1135. ==============================================================================
  1136. ##### LPTIM IRQ handler #####
  1137. ==============================================================================
  1138. [..] This section provides LPTIM IRQ handler function.
  1139. @endverbatim
  1140. * @{
  1141. */
  1142. /**
  1143. * @brief This function handles LPTIM interrupt request.
  1144. * @param hlptim: LPTIM handle
  1145. * @retval None
  1146. */
  1147. void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim)
  1148. {
  1149. /* Compare match interrupt */
  1150. if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_CMPM) != RESET)
  1151. {
  1152. if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_CMPM) !=RESET)
  1153. {
  1154. /* Clear Compare match flag */
  1155. __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_CMPM);
  1156. /* Compare match Callback */
  1157. HAL_LPTIM_CompareMatchCallback(hlptim);
  1158. }
  1159. }
  1160. /* Autoreload match interrupt */
  1161. if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_ARRM) != RESET)
  1162. {
  1163. if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_ARRM) !=RESET)
  1164. {
  1165. /* Clear Autoreload match flag */
  1166. __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_ARRM);
  1167. /* Autoreload match Callback */
  1168. HAL_LPTIM_AutoReloadMatchCallback(hlptim);
  1169. }
  1170. }
  1171. /* Trigger detected interrupt */
  1172. if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_EXTTRIG) != RESET)
  1173. {
  1174. if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_EXTTRIG) !=RESET)
  1175. {
  1176. /* Clear Trigger detected flag */
  1177. __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_EXTTRIG);
  1178. /* Trigger detected callback */
  1179. HAL_LPTIM_TriggerCallback(hlptim);
  1180. }
  1181. }
  1182. /* Compare write interrupt */
  1183. if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_CMPOK) != RESET)
  1184. {
  1185. if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_FLAG_CMPM) !=RESET)
  1186. {
  1187. /* Clear Compare write flag */
  1188. __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_CMPOK);
  1189. /* Compare write Callback */
  1190. HAL_LPTIM_CompareWriteCallback(hlptim);
  1191. }
  1192. }
  1193. /* Autoreload write interrupt */
  1194. if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_ARROK) != RESET)
  1195. {
  1196. if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_ARROK) !=RESET)
  1197. {
  1198. /* Clear Autoreload write flag */
  1199. __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_ARROK);
  1200. /* Autoreload write Callback */
  1201. HAL_LPTIM_AutoReloadWriteCallback(hlptim);
  1202. }
  1203. }
  1204. /* Direction counter changed from Down to Up interrupt */
  1205. if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_UP) != RESET)
  1206. {
  1207. if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_UP) !=RESET)
  1208. {
  1209. /* Clear Direction counter changed from Down to Up flag */
  1210. __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_UP);
  1211. /* Direction counter changed from Down to Up Callback */
  1212. HAL_LPTIM_DirectionUpCallback(hlptim);
  1213. }
  1214. }
  1215. /* Direction counter changed from Up to Down interrupt */
  1216. if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_DOWN) != RESET)
  1217. {
  1218. if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_DOWN) !=RESET)
  1219. {
  1220. /* Clear Direction counter changed from Up to Down flag */
  1221. __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_DOWN);
  1222. /* Direction counter changed from Up to Down Callback */
  1223. HAL_LPTIM_DirectionDownCallback(hlptim);
  1224. }
  1225. }
  1226. __HAL_LPTIM_WAKEUPTIMER_EXTI_CLEAR_FLAG();
  1227. }
  1228. /**
  1229. * @brief Compare match callback in non blocking mode
  1230. * @param hlptim : LPTIM handle
  1231. * @retval None
  1232. */
  1233. __weak void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim)
  1234. {
  1235. /* Prevent unused argument(s) compilation warning */
  1236. UNUSED(hlptim);
  1237. /* NOTE : This function Should not be modified, when the callback is needed,
  1238. the HAL_LPTIM_CompareMatchCallback could be implemented in the user file
  1239. */
  1240. }
  1241. /**
  1242. * @brief Autoreload match callback in non blocking mode
  1243. * @param hlptim : LPTIM handle
  1244. * @retval None
  1245. */
  1246. __weak void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim)
  1247. {
  1248. /* Prevent unused argument(s) compilation warning */
  1249. UNUSED(hlptim);
  1250. /* NOTE : This function Should not be modified, when the callback is needed,
  1251. the HAL_LPTIM_AutoReloadMatchCallback could be implemented in the user file
  1252. */
  1253. }
  1254. /**
  1255. * @brief Trigger detected callback in non blocking mode
  1256. * @param hlptim : LPTIM handle
  1257. * @retval None
  1258. */
  1259. __weak void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim)
  1260. {
  1261. /* Prevent unused argument(s) compilation warning */
  1262. UNUSED(hlptim);
  1263. /* NOTE : This function Should not be modified, when the callback is needed,
  1264. the HAL_LPTIM_TriggerCallback could be implemented in the user file
  1265. */
  1266. }
  1267. /**
  1268. * @brief Compare write callback in non blocking mode
  1269. * @param hlptim : LPTIM handle
  1270. * @retval None
  1271. */
  1272. __weak void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim)
  1273. {
  1274. /* Prevent unused argument(s) compilation warning */
  1275. UNUSED(hlptim);
  1276. /* NOTE : This function Should not be modified, when the callback is needed,
  1277. the HAL_LPTIM_CompareWriteCallback could be implemented in the user file
  1278. */
  1279. }
  1280. /**
  1281. * @brief Autoreload write callback in non blocking mode
  1282. * @param hlptim : LPTIM handle
  1283. * @retval None
  1284. */
  1285. __weak void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim)
  1286. {
  1287. /* Prevent unused argument(s) compilation warning */
  1288. UNUSED(hlptim);
  1289. /* NOTE : This function Should not be modified, when the callback is needed,
  1290. the HAL_LPTIM_AutoReloadWriteCallback could be implemented in the user file
  1291. */
  1292. }
  1293. /**
  1294. * @brief Direction counter changed from Down to Up callback in non blocking mode
  1295. * @param hlptim : LPTIM handle
  1296. * @retval None
  1297. */
  1298. __weak void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim)
  1299. {
  1300. /* Prevent unused argument(s) compilation warning */
  1301. UNUSED(hlptim);
  1302. /* NOTE : This function Should not be modified, when the callback is needed,
  1303. the HAL_LPTIM_DirectionUpCallback could be implemented in the user file
  1304. */
  1305. }
  1306. /**
  1307. * @brief Direction counter changed from Up to Down callback in non blocking mode
  1308. * @param hlptim : LPTIM handle
  1309. * @retval None
  1310. */
  1311. __weak void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim)
  1312. {
  1313. /* Prevent unused argument(s) compilation warning */
  1314. UNUSED(hlptim);
  1315. /* NOTE : This function Should not be modified, when the callback is needed,
  1316. the HAL_LPTIM_DirectionDownCallback could be implemented in the user file
  1317. */
  1318. }
  1319. /**
  1320. * @}
  1321. */
  1322. /** @defgroup LPTIM_Group5 Peripheral State functions
  1323. * @brief Peripheral State functions.
  1324. *
  1325. @verbatim
  1326. ==============================================================================
  1327. ##### Peripheral State functions #####
  1328. ==============================================================================
  1329. [..]
  1330. This subsection permits to get in run-time the status of the peripheral.
  1331. @endverbatim
  1332. * @{
  1333. */
  1334. /**
  1335. * @brief Returns the LPTIM state.
  1336. * @param hlptim: LPTIM handle
  1337. * @retval HAL state
  1338. */
  1339. HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim)
  1340. {
  1341. return hlptim->State;
  1342. }
  1343. /**
  1344. * @}
  1345. */
  1346. /**
  1347. * @}
  1348. */
  1349. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  1350. #endif /* HAL_LPTIM_MODULE_ENABLED */
  1351. /**
  1352. * @}
  1353. */
  1354. /**
  1355. * @}
  1356. */
  1357. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/