stm32f4xx_hal_lptim.c 53 KB

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