You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

824 lines
21 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_dts.c
  4. * @author MCD Application Team
  5. * @brief DTS HAL module driver.
  6. * This file provides firmware functions to manage the following
  7. * functionalities of the DTS peripheral:
  8. * + Initialization and de-initialization functions
  9. * + Start/Stop operation functions in polling mode.
  10. * + Start/Stop operation functions in interrupt mode.
  11. * + Peripheral Control functions
  12. * + Peripheral State functions
  13. *
  14. @verbatim
  15. ================================================================================
  16. ##### DTS Peripheral features #####
  17. ================================================================================
  18. [..]
  19. The STM32h7xx device family integrate one DTS sensor interface :
  20. ##### How to use this driver #####
  21. ================================================================================
  22. [..]
  23. @endverbatim
  24. ******************************************************************************
  25. * @attention
  26. *
  27. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  28. * All rights reserved.</center></h2>
  29. *
  30. * This software component is licensed by ST under BSD 3-Clause license,
  31. * the "License"; You may not use this file except in compliance with the
  32. * License. You may obtain a copy of the License at:
  33. * opensource.org/licenses/BSD-3-Clause
  34. *
  35. ******************************************************************************
  36. */
  37. /* Includes ------------------------------------------------------------------*/
  38. #include "stm32h7xx_hal.h"
  39. /** @addtogroup STM32H7xx_HAL_Driver
  40. * @{
  41. */
  42. #ifdef HAL_DTS_MODULE_ENABLED
  43. #if defined(DTS)
  44. /** @defgroup DTS DTS
  45. * @brief DTS HAL module driver
  46. * @{
  47. */
  48. /* Private typedef -----------------------------------------------------------*/
  49. /* Private define ------------------------------------------------------------*/
  50. /** @addtogroup DTS_Private_Constants
  51. * @{
  52. */
  53. /* @brief Delay for DTS startup time
  54. * @note Delay required to get ready for DTS Block.
  55. * @note Unit: ms
  56. */
  57. #define DTS_DELAY_STARTUP (1UL)
  58. /* @brief DTS measure ready flag time out value.
  59. * @note Maximal measurement time is when LSE is selected as ref_clock and
  60. * maximal sampling time is used, taking calibration into account this
  61. * is equivalent to ~620 us. Use 5 ms as arbitrary timeout
  62. * @note Unit: ms
  63. */
  64. #define TS_TIMEOUT_MS (5UL)
  65. /* Private macro -------------------------------------------------------------*/
  66. /* Private variables ---------------------------------------------------------*/
  67. /* Private function prototypes -----------------------------------------------*/
  68. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  69. static void DTS_ResetCallback(DTS_HandleTypeDef *hdts);
  70. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  71. /* Exported functions --------------------------------------------------------*/
  72. /** @defgroup DTS_Exported_Functions DTS Exported Functions
  73. * @{
  74. */
  75. /** @defgroup DTS_Exported_Functions_Group1 Initialization/de-initialization functions
  76. * @brief Initialization and de-initialization functions.
  77. *
  78. @verbatim
  79. ===============================================================================
  80. ##### Initialization and de-initialization functions #####
  81. ===============================================================================
  82. [..] This section provides functions to initialize and de-initialize comparators
  83. @endverbatim
  84. * @{
  85. */
  86. /**
  87. * @brief Initialize the DTS according to the specified
  88. * parameters in the DTS_InitTypeDef and initialize the associated handle.
  89. * @param hdts DTS handle
  90. * @retval HAL status
  91. */
  92. HAL_StatusTypeDef HAL_DTS_Init(DTS_HandleTypeDef *hdts)
  93. {
  94. /* Check the DTS handle allocation */
  95. if (hdts == NULL)
  96. {
  97. return HAL_ERROR;
  98. }
  99. /* Check the parameters */
  100. assert_param(IS_DTS_ALL_INSTANCE(hdts->Instance));
  101. assert_param(IS_DTS_QUICKMEAS(hdts->Init.QuickMeasure));
  102. assert_param(IS_DTS_REFCLK(hdts->Init.RefClock));
  103. assert_param(IS_DTS_TRIGGERINPUT(hdts->Init.TriggerInput));
  104. assert_param(IS_DTS_SAMPLINGTIME(hdts->Init.SamplingTime));
  105. assert_param(IS_DTS_THRESHOLD(hdts->Init.HighThreshold));
  106. assert_param(IS_DTS_THRESHOLD(hdts->Init.LowThreshold));
  107. if (hdts->State == HAL_DTS_STATE_RESET)
  108. {
  109. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  110. /* Reset interrupt callbacks to legacy weak callbacks */
  111. DTS_ResetCallback(hdts);
  112. if (hdts->MspInitCallback == NULL)
  113. {
  114. hdts->MspInitCallback = HAL_DTS_MspInit;
  115. }
  116. /* Init the low level hardware : GPIO, CLOCK, NVIC */
  117. hdts->MspInitCallback(hdts);
  118. #else
  119. /* Init the low level hardware : GPIO, CLOCK, NVIC */
  120. HAL_DTS_MspInit(hdts);
  121. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  122. }
  123. /* Change the DTS state */
  124. hdts->State = HAL_DTS_STATE_BUSY;
  125. /* Check ramp coefficient */
  126. if (hdts->Instance->RAMPVALR == 0UL)
  127. {
  128. return HAL_ERROR;
  129. }
  130. /* Check factory calibration temperature */
  131. if (hdts->Instance->T0VALR1 == 0UL)
  132. {
  133. return HAL_ERROR;
  134. }
  135. /* Check Quick Measure option is enabled or disabled */
  136. if (hdts->Init.QuickMeasure == DTS_QUICKMEAS_DISABLE)
  137. {
  138. /* Check Reference clock selection */
  139. if (hdts->Init.RefClock == DTS_REFCLKSEL_PCLK)
  140. {
  141. assert_param(IS_DTS_DIVIDER_RATIO_NUMBER(hdts->Init.Divider));
  142. }
  143. /* Quick measurement mode disabled */
  144. CLEAR_BIT(hdts->Instance->CFGR1, DTS_CFGR1_Q_MEAS_OPT);
  145. }
  146. else
  147. {
  148. /* DTS_QUICKMEAS_ENABLE shall be used only when the LSE clock is
  149. selected as reference clock */
  150. if (hdts->Init.RefClock != DTS_REFCLKSEL_LSE)
  151. {
  152. return HAL_ERROR;
  153. }
  154. /* Quick measurement mode enabled - no calibration needed */
  155. SET_BIT(hdts->Instance->CFGR1, DTS_CFGR1_Q_MEAS_OPT);
  156. }
  157. /* set the DTS clk source */
  158. if (hdts->Init.RefClock == DTS_REFCLKSEL_LSE)
  159. {
  160. SET_BIT(hdts->Instance->CFGR1, DTS_CFGR1_REFCLK_SEL);
  161. }
  162. else
  163. {
  164. CLEAR_BIT(hdts->Instance->CFGR1, DTS_CFGR1_REFCLK_SEL);
  165. }
  166. MODIFY_REG(hdts->Instance->CFGR1, DTS_CFGR1_HSREF_CLK_DIV, (hdts->Init.Divider << DTS_CFGR1_HSREF_CLK_DIV_Pos));
  167. MODIFY_REG(hdts->Instance->CFGR1, DTS_CFGR1_TS1_SMP_TIME, hdts->Init.SamplingTime);
  168. MODIFY_REG(hdts->Instance->CFGR1, DTS_CFGR1_TS1_INTRIG_SEL, hdts->Init.TriggerInput);
  169. MODIFY_REG(hdts->Instance->ITR1, DTS_ITR1_TS1_HITTHD, (hdts->Init.HighThreshold << DTS_ITR1_TS1_HITTHD_Pos));
  170. MODIFY_REG(hdts->Instance->ITR1, DTS_ITR1_TS1_LITTHD, hdts->Init.LowThreshold);
  171. /* Change the DTS state */
  172. hdts->State = HAL_DTS_STATE_READY;
  173. return HAL_OK;
  174. }
  175. /**
  176. * @brief DeInitialize the DTS peripheral.
  177. * @note Deinitialization cannot be performed if the DTS configuration is locked.
  178. * To unlock the configuration, perform a system reset.
  179. * @param hdts DTS handle
  180. * @retval HAL status
  181. */
  182. HAL_StatusTypeDef HAL_DTS_DeInit(DTS_HandleTypeDef *hdts)
  183. {
  184. /* Check the DTS handle allocation */
  185. if (hdts == NULL)
  186. {
  187. return HAL_ERROR;
  188. }
  189. /* Check the parameter */
  190. assert_param(IS_DTS_ALL_INSTANCE(hdts->Instance));
  191. /* Set DTS_CFGR register to reset value */
  192. CLEAR_REG(hdts->Instance->CFGR1);
  193. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  194. if (hdts->MspDeInitCallback == NULL)
  195. {
  196. hdts->MspDeInitCallback = HAL_DTS_MspDeInit;
  197. }
  198. /* DeInit the low level hardware: CLOCK, NVIC.*/
  199. hdts->MspDeInitCallback(hdts);
  200. #else
  201. /* DeInit the low level hardware: CLOCK, NVIC.*/
  202. HAL_DTS_MspDeInit(hdts);
  203. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  204. hdts->State = HAL_DTS_STATE_RESET;
  205. return HAL_OK;
  206. }
  207. /**
  208. * @brief Initialize the DTS MSP.
  209. * @param hdts DTS handle
  210. * @retval None
  211. */
  212. __weak void HAL_DTS_MspInit(DTS_HandleTypeDef *hdts)
  213. {
  214. /* Prevent unused argument(s) compilation warning */
  215. UNUSED(hdts);
  216. /* NOTE : This function should not be modified, when the callback is needed,
  217. the HAL_DTS_MspInit could be implemented in the user file
  218. */
  219. }
  220. /**
  221. * @brief DeInitialize the DTS MSP.
  222. * @param hdts DTS handle
  223. * @retval None
  224. */
  225. __weak void HAL_DTS_MspDeInit(DTS_HandleTypeDef *hdts)
  226. {
  227. /* Prevent unused argument(s) compilation warning */
  228. UNUSED(hdts);
  229. /* NOTE : This function should not be modified, when the callback is needed,
  230. the HAL_DTS_MspDeInit could be implemented in the user file
  231. */
  232. }
  233. /**
  234. * @}
  235. */
  236. /** @defgroup DTS_Exported_Functions_Group2 Start-Stop operation functions
  237. * @brief Start-Stop operation functions.
  238. *
  239. @verbatim
  240. ===============================================================================
  241. ##### DTS Start Stop operation functions #####
  242. ===============================================================================
  243. [..] This section provides functions allowing to:
  244. (+) Start a DTS Sensor without interrupt.
  245. (+) Stop a DTS Sensor without interrupt.
  246. (+) Start a DTS Sensor with interrupt generation.
  247. (+) Stop a DTS Sensor with interrupt generation.
  248. @endverbatim
  249. * @{
  250. */
  251. /**
  252. * @brief Start the DTS sensor.
  253. * @param hdts DTS handle
  254. * @retval HAL status
  255. */
  256. HAL_StatusTypeDef HAL_DTS_Start(DTS_HandleTypeDef *hdts)
  257. {
  258. uint32_t Ref_Time;
  259. /* Check the DTS handle allocation */
  260. if (hdts == NULL)
  261. {
  262. return HAL_ERROR;
  263. }
  264. if (hdts->State == HAL_DTS_STATE_READY)
  265. {
  266. hdts->State = HAL_DTS_STATE_BUSY;
  267. /* Enable DTS sensor */
  268. __HAL_DTS_ENABLE(hdts);
  269. /* Get Start Tick*/
  270. Ref_Time = HAL_GetTick();
  271. /* Wait till TS1_RDY flag is set */
  272. while (__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_RDY) == RESET)
  273. {
  274. if ((HAL_GetTick() - Ref_Time) > DTS_DELAY_STARTUP)
  275. {
  276. return HAL_TIMEOUT;
  277. }
  278. }
  279. if (__HAL_DTS_GET_TRIGGER(hdts) == DTS_TRIGGER_HW_NONE)
  280. {
  281. /* Start continuous measures */
  282. SET_BIT(hdts->Instance->CFGR1, DTS_CFGR1_TS1_START);
  283. /* Ensure start is taken into account */
  284. HAL_Delay(TS_TIMEOUT_MS);
  285. }
  286. hdts->State = HAL_DTS_STATE_READY;
  287. }
  288. else
  289. {
  290. return HAL_BUSY;
  291. }
  292. return HAL_OK;
  293. }
  294. /**
  295. * @brief Stop the DTS Sensor.
  296. * @param hdts DTS handle
  297. * @retval HAL status
  298. */
  299. HAL_StatusTypeDef HAL_DTS_Stop(DTS_HandleTypeDef *hdts)
  300. {
  301. /* Check the DTS handle allocation */
  302. if (hdts == NULL)
  303. {
  304. return HAL_ERROR;
  305. }
  306. if (hdts->State == HAL_DTS_STATE_READY)
  307. {
  308. hdts->State = HAL_DTS_STATE_BUSY;
  309. if (__HAL_DTS_GET_TRIGGER(hdts) == DTS_TRIGGER_HW_NONE)
  310. {
  311. CLEAR_BIT(hdts->Instance->CFGR1, DTS_CFGR1_TS1_START);
  312. }
  313. /* Disable the selected DTS sensor */
  314. __HAL_DTS_DISABLE(hdts);
  315. hdts->State = HAL_DTS_STATE_READY;
  316. }
  317. else
  318. {
  319. return HAL_BUSY;
  320. }
  321. return HAL_OK;
  322. }
  323. /**
  324. * @brief Enable the interrupt(s) and start the DTS sensor
  325. * @param hdts DTS handle
  326. * @retval HAL status
  327. */
  328. HAL_StatusTypeDef HAL_DTS_Start_IT(DTS_HandleTypeDef *hdts)
  329. {
  330. uint32_t Ref_Time;
  331. /* Check the DTS handle allocation */
  332. if (hdts == NULL)
  333. {
  334. return HAL_ERROR;
  335. }
  336. if (hdts->State == HAL_DTS_STATE_READY)
  337. {
  338. hdts->State = HAL_DTS_STATE_BUSY;
  339. /* On Asynchronous mode enable the asynchronous IT */
  340. if (hdts->Init.RefClock == DTS_REFCLKSEL_LSE)
  341. {
  342. __HAL_DTS_ENABLE_IT(hdts, DTS_IT_TS1_AITE | DTS_IT_TS1_AITL | DTS_IT_TS1_AITH);
  343. }
  344. else
  345. {
  346. /* Enable the IT(s) */
  347. __HAL_DTS_ENABLE_IT(hdts, DTS_IT_TS1_ITE | DTS_IT_TS1_ITL | DTS_IT_TS1_ITH);
  348. }
  349. /* Enable the selected DTS sensor */
  350. __HAL_DTS_ENABLE(hdts);
  351. /* Get Start Tick*/
  352. Ref_Time = HAL_GetTick();
  353. /* Wait till TS1_RDY flag is set */
  354. while (__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_RDY) == RESET)
  355. {
  356. if ((HAL_GetTick() - Ref_Time) > DTS_DELAY_STARTUP)
  357. {
  358. return HAL_TIMEOUT;
  359. }
  360. }
  361. if (__HAL_DTS_GET_TRIGGER(hdts) == DTS_TRIGGER_HW_NONE)
  362. {
  363. /* Start continuous measures */
  364. SET_BIT(hdts->Instance->CFGR1, DTS_CFGR1_TS1_START);
  365. /* Ensure start is taken into account */
  366. HAL_Delay(TS_TIMEOUT_MS);
  367. }
  368. hdts->State = HAL_DTS_STATE_READY;
  369. }
  370. else
  371. {
  372. return HAL_BUSY;
  373. }
  374. return HAL_OK;
  375. }
  376. /**
  377. * @brief Disable the interrupt(s) and stop the DTS sensor.
  378. * @param hdts DTS handle
  379. * @retval HAL status
  380. */
  381. HAL_StatusTypeDef HAL_DTS_Stop_IT(DTS_HandleTypeDef *hdts)
  382. {
  383. /* Check the DTS handle allocation */
  384. if (hdts == NULL)
  385. {
  386. return HAL_ERROR;
  387. }
  388. if (hdts->State == HAL_DTS_STATE_READY)
  389. {
  390. hdts->State = HAL_DTS_STATE_BUSY;
  391. /* On Asynchronous mode disable the asynchronous IT */
  392. if (hdts->Init.RefClock == DTS_REFCLKSEL_LSE)
  393. {
  394. __HAL_DTS_DISABLE_IT(hdts, DTS_IT_TS1_AITE | DTS_IT_TS1_AITL | DTS_IT_TS1_AITH);
  395. }
  396. else
  397. {
  398. /* Disable the IT(s) */
  399. __HAL_DTS_DISABLE_IT(hdts, DTS_IT_TS1_ITE | DTS_IT_TS1_ITL | DTS_IT_TS1_ITH);
  400. }
  401. if (__HAL_DTS_GET_TRIGGER(hdts) == DTS_TRIGGER_HW_NONE)
  402. {
  403. CLEAR_BIT(hdts->Instance->CFGR1, DTS_CFGR1_TS1_START);
  404. }
  405. /* Disable the selected DTS sensor */
  406. __HAL_DTS_DISABLE(hdts);
  407. hdts->State = HAL_DTS_STATE_READY;
  408. }
  409. else
  410. {
  411. return HAL_BUSY;
  412. }
  413. return HAL_OK;
  414. }
  415. /**
  416. * @brief Get temperature from DTS
  417. * @param hdts DTS handle
  418. * @param Temperature Temperature in deg C
  419. * @note This function retrieves latest available measure
  420. * @retval HAL status
  421. */
  422. HAL_StatusTypeDef HAL_DTS_GetTemperature(DTS_HandleTypeDef *hdts, int32_t *Temperature)
  423. {
  424. uint32_t freq_meas;
  425. uint32_t samples;
  426. uint32_t t0_temp;
  427. uint32_t t0_freq;
  428. uint32_t ramp_coeff;
  429. if (hdts->State == HAL_DTS_STATE_READY)
  430. {
  431. hdts->State = HAL_DTS_STATE_BUSY;
  432. /* Get the total number of samples */
  433. samples = (hdts->Instance->DR & DTS_DR_TS1_MFREQ);
  434. if ((hdts->Init.SamplingTime == 0UL) || (samples == 0UL))
  435. {
  436. hdts->State = HAL_DTS_STATE_READY;
  437. return HAL_ERROR;
  438. }
  439. if ((hdts->Init.RefClock) == DTS_REFCLKSEL_LSE)
  440. {
  441. freq_meas = (LSE_VALUE * samples) / (hdts->Init.SamplingTime >> DTS_CFGR1_TS1_SMP_TIME_Pos); /* On Hz */
  442. }
  443. else
  444. {
  445. freq_meas = (HAL_RCCEx_GetD3PCLK1Freq() * (hdts->Init.SamplingTime >> DTS_CFGR1_TS1_SMP_TIME_Pos)) / samples; /* On Hz */
  446. }
  447. /* Read factory settings */
  448. t0_temp = hdts->Instance->T0VALR1 >> DTS_T0VALR1_TS1_T0_Pos;
  449. if (t0_temp == 0UL)
  450. {
  451. t0_temp = 30UL; /* 30 deg C */
  452. }
  453. else if (t0_temp == 1UL)
  454. {
  455. t0_temp = 110UL; /* 110 deg C */
  456. }
  457. else
  458. {
  459. hdts->State = HAL_DTS_STATE_READY;
  460. return HAL_ERROR;
  461. }
  462. t0_freq = (hdts->Instance->T0VALR1 & DTS_T0VALR1_TS1_FMT0) * 100UL; /* Hz */
  463. ramp_coeff = hdts->Instance->RAMPVALR & DTS_RAMPVALR_TS1_RAMP_COEFF; /* deg C/Hz */
  464. if (ramp_coeff == 0UL)
  465. {
  466. hdts->State = HAL_DTS_STATE_READY;
  467. return HAL_ERROR;
  468. }
  469. /* Figure out the temperature deg C */
  470. *Temperature = (int32_t)t0_temp + (((int32_t)freq_meas - (int32_t)t0_freq) / (int32_t)ramp_coeff);
  471. hdts->State = HAL_DTS_STATE_READY;
  472. }
  473. else
  474. {
  475. return HAL_BUSY;
  476. }
  477. return HAL_OK;
  478. }
  479. /**
  480. * @brief DTS sensor IRQ Handler.
  481. * @param hdts DTS handle
  482. * @retval None
  483. */
  484. void HAL_DTS_IRQHandler(DTS_HandleTypeDef *hdts)
  485. {
  486. /* Check end of measure Asynchronous IT */
  487. if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_AITE)) != RESET)
  488. {
  489. __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_AITE);
  490. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  491. hdts->AsyncEndCallback(hdts);
  492. #else
  493. HAL_DTS_AsyncEndCallback(hdts);
  494. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  495. }
  496. /* Check low threshold Asynchronous IT */
  497. if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_AITL)) != RESET)
  498. {
  499. __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_AITL);
  500. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  501. hdts->AsyncLowCallback(hdts);
  502. #else
  503. HAL_DTS_AsyncLowCallback(hdts);
  504. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  505. }
  506. /* Check high threshold Asynchronous IT */
  507. if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_AITH)) != RESET)
  508. {
  509. __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_AITH);
  510. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  511. hdts->AsyncHighCallback(hdts);
  512. #else
  513. HAL_DTS_AsyncHighCallback(hdts);
  514. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  515. }
  516. /* Check end of measure IT */
  517. if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_ITE)) != RESET)
  518. {
  519. __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_ITE);
  520. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  521. hdts->EndCallback(hdts);
  522. #else
  523. HAL_DTS_EndCallback(hdts);
  524. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  525. }
  526. /* Check low threshold IT */
  527. if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_ITL)) != RESET)
  528. {
  529. __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_ITL);
  530. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  531. hdts->LowCallback(hdts);
  532. #else
  533. HAL_DTS_LowCallback(hdts);
  534. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  535. }
  536. /* Check high threshold IT */
  537. if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_ITH)) != RESET)
  538. {
  539. __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_ITH);
  540. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  541. hdts->HighCallback(hdts);
  542. #else
  543. HAL_DTS_HighCallback(hdts);
  544. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  545. }
  546. }
  547. /**
  548. * @brief DTS Sensor End measure callback.
  549. * @param hdts DTS handle
  550. * @retval None
  551. */
  552. __weak void HAL_DTS_EndCallback(DTS_HandleTypeDef *hdts)
  553. {
  554. /* Prevent unused argument(s) compilation warning */
  555. UNUSED(hdts);
  556. /* NOTE : This function should not be modified, when the callback is needed,
  557. the HAL_DTS_EndCallback should be implemented in the user file
  558. */
  559. }
  560. /**
  561. * @brief DTS Sensor low threshold measure callback.
  562. * @param hdts DTS handle
  563. * @retval None
  564. */
  565. __weak void HAL_DTS_LowCallback(DTS_HandleTypeDef *hdts)
  566. {
  567. /* Prevent unused argument(s) compilation warning */
  568. UNUSED(hdts);
  569. /* NOTE : This function should not be modified, when the callback is needed,
  570. the HAL_DTS_LowCallback should be implemented in the user file
  571. */
  572. }
  573. /**
  574. * @brief DTS Sensor high threshold measure callback.
  575. * @param hdts DTS handle
  576. * @retval None
  577. */
  578. __weak void HAL_DTS_HighCallback(DTS_HandleTypeDef *hdts)
  579. {
  580. /* Prevent unused argument(s) compilation warning */
  581. UNUSED(hdts);
  582. /* NOTE : This function should not be modified, when the callback is needed,
  583. the HAL_DTS_HighCallback should be implemented in the user file
  584. */
  585. }
  586. /**
  587. * @brief DTS Sensor asynchronous end measure callback.
  588. * @param hdts DTS handle
  589. * @retval None
  590. */
  591. __weak void HAL_DTS_AsyncEndCallback(DTS_HandleTypeDef *hdts)
  592. {
  593. /* Prevent unused argument(s) compilation warning */
  594. UNUSED(hdts);
  595. /* NOTE : This function should not be modified, when the callback is needed,
  596. the HAL_DTS_AsyncEndCallback should be implemented in the user file
  597. */
  598. }
  599. /**
  600. * @brief DTS Sensor asynchronous low threshold measure callback.
  601. * @param hdts DTS handle
  602. * @retval None
  603. */
  604. __weak void HAL_DTS_AsyncLowCallback(DTS_HandleTypeDef *hdts)
  605. {
  606. /* Prevent unused argument(s) compilation warning */
  607. UNUSED(hdts);
  608. /* NOTE : This function should not be modified, when the callback is needed,
  609. the HAL_DTS_AsyncLowCallback should be implemented in the user file
  610. */
  611. }
  612. /**
  613. * @brief DTS Sensor asynchronous high threshold measure callback.
  614. * @param hdts DTS handle
  615. * @retval None
  616. */
  617. __weak void HAL_DTS_AsyncHighCallback(DTS_HandleTypeDef *hdts)
  618. {
  619. /* Prevent unused argument(s) compilation warning */
  620. UNUSED(hdts);
  621. /* NOTE : This function should not be modified, when the callback is needed,
  622. the HAL_DTS_AsyncHighCallback should be implemented in the user file
  623. */
  624. }
  625. /**
  626. * @}
  627. */
  628. /** @defgroup DTS_Exported_Functions_Group3 Peripheral State functions
  629. * @brief Peripheral State functions.
  630. *
  631. @verbatim
  632. ===============================================================================
  633. ##### Peripheral State functions #####
  634. ===============================================================================
  635. [..]
  636. This subsection permits to get in run-time the status of the peripheral.
  637. @endverbatim
  638. * @{
  639. */
  640. /**
  641. * @brief Return the DTS handle state.
  642. * @param hdts DTS handle
  643. * @retval HAL state
  644. */
  645. HAL_DTS_StateTypeDef HAL_DTS_GetState(DTS_HandleTypeDef *hdts)
  646. {
  647. /* Check the DTS handle allocation */
  648. if (hdts == NULL)
  649. {
  650. return HAL_DTS_STATE_RESET;
  651. }
  652. /* Return DTS handle state */
  653. return hdts->State;
  654. }
  655. /**
  656. * @}
  657. */
  658. /**
  659. * @}
  660. */
  661. /* Private functions ---------------------------------------------------------*/
  662. /** @defgroup DTS_Private_Functions DTS Private Functions
  663. * @{
  664. */
  665. #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
  666. /**
  667. * @brief Reset interrupt callbacks to the legacy weak callbacks.
  668. * @param hdts pointer to a DTS_HandleTypeDef structure that contains
  669. * the configuration information for DTS module.
  670. * @retval None
  671. */
  672. static void DTS_ResetCallback(DTS_HandleTypeDef *hdts)
  673. {
  674. /* Reset the DTS callback to the legacy weak callbacks */
  675. hdts->DTS_EndCallback = HAL_DTS_EndCallback; /* End measure Callback */
  676. hdts->DTS_LowCallback = HAL_DTS_LowCallback; /* low threshold Callback */
  677. hdts->DTS_HighCallback = HAL_DTS_HighCallback; /* high threshold Callback */
  678. hdts->DTS_AsyncEndCallback = HAL_DTS_AsyncEndCallback; /* Asynchronous end of measure Callback */
  679. hdts->DTS_AsyncLowCallback = HAL_DTS_AsyncLowCallback; /* Asynchronous low threshold Callback */
  680. hdts->DTS_AsyncHighCallback = HAL_DTS_AsyncHighCallback; /* Asynchronous high threshold Callback */
  681. }
  682. #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
  683. /**
  684. * @}
  685. */
  686. /**
  687. * @}
  688. */
  689. #endif /* DTS */
  690. #endif /* HAL_DTS_MODULE_ENABLED */
  691. /**
  692. * @}
  693. */
  694. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/