STM32H735xx HAL User Manual
stm32h7xx_hal_dts.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32h7xx_hal_dts.c
00004   * @author  MCD Application Team
00005   * @brief   DTS HAL module driver.
00006   *          This file provides firmware functions to manage the following
00007   *          functionalities of the DTS peripheral:
00008   *           + Initialization and de-initialization functions
00009   *           + Start/Stop operation functions in polling mode.
00010   *           + Start/Stop operation functions in interrupt mode.
00011   *           + Peripheral Control functions
00012   *           + Peripheral State functions
00013   *
00014   ******************************************************************************
00015   * @attention
00016   *
00017   * Copyright (c) 2017 STMicroelectronics.
00018   * All rights reserved.
00019   *
00020   * This software is licensed under terms that can be found in the LICENSE file
00021   * in the root directory of this software component.
00022   * If no LICENSE file comes with this software, it is provided AS-IS.
00023   *
00024   ******************************************************************************
00025   @verbatim
00026 ================================================================================
00027           ##### DTS Peripheral features #####
00028 ================================================================================
00029 
00030   [..]
00031       The STM32h7xx device family integrate one DTS sensor interface :
00032 
00033 
00034             ##### How to use this driver #####
00035 ================================================================================
00036   [..]
00037 
00038 
00039   @endverbatim
00040   ******************************************************************************
00041   */
00042 
00043 /* Includes ------------------------------------------------------------------*/
00044 #include "stm32h7xx_hal.h"
00045 
00046 /** @addtogroup STM32H7xx_HAL_Driver
00047   * @{
00048   */
00049 
00050 #ifdef HAL_DTS_MODULE_ENABLED
00051 
00052 #if defined(DTS)
00053 
00054 /** @defgroup DTS DTS
00055   * @brief DTS HAL module driver
00056   * @{
00057   */
00058 
00059 /* Private typedef -----------------------------------------------------------*/
00060 /* Private define ------------------------------------------------------------*/
00061 /** @addtogroup DTS_Private_Constants
00062   * @{
00063   */
00064 
00065 /* @brief Delay for DTS startup time
00066  * @note  Delay required to get ready for DTS Block.
00067  * @note  Unit: ms
00068  */
00069 #define DTS_DELAY_STARTUP (1UL)
00070 
00071 /* @brief DTS measure ready flag time out value.
00072  * @note  Maximal measurement time is when LSE is selected as ref_clock and
00073  *        maximal sampling time is used, taking calibration into account this
00074  *        is equivalent to ~620 us. Use 5 ms as arbitrary timeout
00075  * @note Unit: ms
00076  */
00077 #define TS_TIMEOUT_MS     (5UL)
00078 
00079 /**
00080   * @}
00081   */
00082 
00083 /* Private macro -------------------------------------------------------------*/
00084 /* Private variables ---------------------------------------------------------*/
00085 /* Private function prototypes -----------------------------------------------*/
00086 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00087 static void DTS_ResetCallback(DTS_HandleTypeDef *hdts);
00088 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00089 /* Exported functions --------------------------------------------------------*/
00090 
00091 /** @defgroup DTS_Exported_Functions DTS Exported Functions
00092   * @{
00093   */
00094 
00095 /** @defgroup DTS_Exported_Functions_Group1 Initialization/de-initialization functions
00096  *  @brief    Initialization and de-initialization functions.
00097  *
00098 @verbatim
00099  ===============================================================================
00100               ##### Initialization and de-initialization functions #####
00101  ===============================================================================
00102     [..]  This section provides functions to initialize and de-initialize comparators
00103 
00104 @endverbatim
00105   * @{
00106   */
00107 
00108 /**
00109   * @brief  Initialize the DTS according to the specified
00110   *         parameters in the DTS_InitTypeDef and initialize the associated handle.
00111   * @param  hdts  DTS handle
00112   * @retval HAL status
00113   */
00114 HAL_StatusTypeDef HAL_DTS_Init(DTS_HandleTypeDef *hdts)
00115 {
00116   /* Check the DTS handle allocation */
00117   if (hdts == NULL)
00118   {
00119     return HAL_ERROR;
00120   }
00121 
00122   /* Check the parameters */
00123   assert_param(IS_DTS_ALL_INSTANCE(hdts->Instance));
00124   assert_param(IS_DTS_QUICKMEAS(hdts->Init.QuickMeasure));
00125   assert_param(IS_DTS_REFCLK(hdts->Init.RefClock));
00126   assert_param(IS_DTS_TRIGGERINPUT(hdts->Init.TriggerInput));
00127   assert_param(IS_DTS_SAMPLINGTIME(hdts->Init.SamplingTime));
00128   assert_param(IS_DTS_THRESHOLD(hdts->Init.HighThreshold));
00129   assert_param(IS_DTS_THRESHOLD(hdts->Init.LowThreshold));
00130 
00131   if (hdts->State == HAL_DTS_STATE_RESET)
00132   {
00133 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00134     /* Reset interrupt callbacks to legacy weak callbacks */
00135     DTS_ResetCallback(hdts);
00136 
00137     if (hdts->MspInitCallback == NULL)
00138     {
00139       hdts->MspInitCallback = HAL_DTS_MspInit;
00140     }
00141 
00142     /* Init the low level hardware : GPIO, CLOCK, NVIC */
00143     hdts->MspInitCallback(hdts);
00144 #else
00145     /* Init the low level hardware : GPIO, CLOCK, NVIC */
00146     HAL_DTS_MspInit(hdts);
00147 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00148   }
00149 
00150   /* Change the DTS state */
00151   hdts->State = HAL_DTS_STATE_BUSY;
00152 
00153   /* Check ramp coefficient */
00154   if (hdts->Instance->RAMPVALR == 0UL)
00155   {
00156     return HAL_ERROR;
00157   }
00158 
00159   /* Check factory calibration temperature  */
00160   if (hdts->Instance->T0VALR1 == 0UL)
00161   {
00162     return HAL_ERROR;
00163   }
00164 
00165   /* Check Quick Measure option is enabled or disabled */
00166   if (hdts->Init.QuickMeasure == DTS_QUICKMEAS_DISABLE)
00167   {
00168     /* Check Reference clock selection */
00169     if (hdts->Init.RefClock == DTS_REFCLKSEL_PCLK)
00170     {
00171       assert_param(IS_DTS_DIVIDER_RATIO_NUMBER(hdts->Init.Divider));
00172     }
00173     /* Quick measurement mode disabled */
00174     CLEAR_BIT(hdts->Instance->CFGR1, DTS_CFGR1_Q_MEAS_OPT);
00175   }
00176   else
00177   {
00178     /* DTS_QUICKMEAS_ENABLE shall be used only when the LSE clock is
00179        selected as reference clock */
00180     if (hdts->Init.RefClock != DTS_REFCLKSEL_LSE)
00181     {
00182       return HAL_ERROR;
00183     }
00184 
00185     /* Quick measurement mode enabled - no calibration needed */
00186     SET_BIT(hdts->Instance->CFGR1, DTS_CFGR1_Q_MEAS_OPT);
00187   }
00188 
00189   /* set the DTS clk source */
00190   if (hdts->Init.RefClock == DTS_REFCLKSEL_LSE)
00191   {
00192     SET_BIT(hdts->Instance->CFGR1, DTS_CFGR1_REFCLK_SEL);
00193   }
00194   else
00195   {
00196     CLEAR_BIT(hdts->Instance->CFGR1, DTS_CFGR1_REFCLK_SEL);
00197   }
00198 
00199   MODIFY_REG(hdts->Instance->CFGR1, DTS_CFGR1_HSREF_CLK_DIV, (hdts->Init.Divider << DTS_CFGR1_HSREF_CLK_DIV_Pos));
00200   MODIFY_REG(hdts->Instance->CFGR1, DTS_CFGR1_TS1_SMP_TIME, hdts->Init.SamplingTime);
00201   MODIFY_REG(hdts->Instance->CFGR1, DTS_CFGR1_TS1_INTRIG_SEL, hdts->Init.TriggerInput);
00202   MODIFY_REG(hdts->Instance->ITR1, DTS_ITR1_TS1_HITTHD, (hdts->Init.HighThreshold << DTS_ITR1_TS1_HITTHD_Pos));
00203   MODIFY_REG(hdts->Instance->ITR1, DTS_ITR1_TS1_LITTHD, hdts->Init.LowThreshold);
00204 
00205   /* Change the DTS state */
00206   hdts->State = HAL_DTS_STATE_READY;
00207 
00208   return HAL_OK;
00209 }
00210 
00211 /**
00212   * @brief  DeInitialize the DTS peripheral.
00213   * @note   Deinitialization cannot be performed if the DTS configuration is locked.
00214   *         To unlock the configuration, perform a system reset.
00215   * @param  hdts  DTS handle
00216   * @retval HAL status
00217   */
00218 HAL_StatusTypeDef HAL_DTS_DeInit(DTS_HandleTypeDef *hdts)
00219 {
00220   /* Check the DTS handle allocation */
00221   if (hdts == NULL)
00222   {
00223     return HAL_ERROR;
00224   }
00225 
00226   /* Check the parameter */
00227   assert_param(IS_DTS_ALL_INSTANCE(hdts->Instance));
00228 
00229   /* Set DTS_CFGR register to reset value */
00230   CLEAR_REG(hdts->Instance->CFGR1);
00231 
00232 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00233   if (hdts->MspDeInitCallback == NULL)
00234   {
00235     hdts->MspDeInitCallback = HAL_DTS_MspDeInit;
00236   }
00237 
00238   /* DeInit the low level hardware: CLOCK, NVIC.*/
00239   hdts->MspDeInitCallback(hdts);
00240 #else
00241   /* DeInit the low level hardware: CLOCK, NVIC.*/
00242   HAL_DTS_MspDeInit(hdts);
00243 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00244 
00245   hdts->State = HAL_DTS_STATE_RESET;
00246 
00247   return HAL_OK;
00248 }
00249 
00250 /**
00251   * @brief  Initialize the DTS MSP.
00252   * @param  hdts  DTS handle
00253   * @retval None
00254   */
00255 __weak void HAL_DTS_MspInit(DTS_HandleTypeDef *hdts)
00256 {
00257   /* Prevent unused argument(s) compilation warning */
00258   UNUSED(hdts);
00259 
00260   /* NOTE : This function should not be modified, when the callback is needed,
00261   the HAL_DTS_MspInit could be implemented in the user file
00262   */
00263 }
00264 
00265 /**
00266   * @brief  DeInitialize the DTS MSP.
00267   * @param  hdts  DTS handle
00268   * @retval None
00269   */
00270 __weak void HAL_DTS_MspDeInit(DTS_HandleTypeDef *hdts)
00271 {
00272   /* Prevent unused argument(s) compilation warning */
00273   UNUSED(hdts);
00274 
00275   /* NOTE : This function should not be modified, when the callback is needed,
00276   the HAL_DTS_MspDeInit could be implemented in the user file
00277   */
00278 }
00279 
00280 /**
00281   * @}
00282   */
00283 
00284 /** @defgroup DTS_Exported_Functions_Group2 Start-Stop operation functions
00285  *  @brief   Start-Stop operation functions.
00286  *
00287 @verbatim
00288  ===============================================================================
00289                       ##### DTS Start Stop operation functions #####
00290  ===============================================================================
00291     [..]  This section provides functions allowing to:
00292       (+) Start a DTS Sensor without interrupt.
00293       (+) Stop a DTS Sensor without interrupt.
00294       (+) Start a DTS Sensor with interrupt generation.
00295       (+) Stop a DTS Sensor with interrupt generation.
00296 
00297 @endverbatim
00298   * @{
00299   */
00300 
00301 /**
00302   * @brief  Start the DTS sensor.
00303   * @param  hdts  DTS handle
00304   * @retval HAL status
00305   */
00306 HAL_StatusTypeDef HAL_DTS_Start(DTS_HandleTypeDef *hdts)
00307 {
00308   uint32_t Ref_Time;
00309 
00310   /* Check the DTS handle allocation */
00311   if (hdts == NULL)
00312   {
00313     return HAL_ERROR;
00314   }
00315 
00316   if (hdts->State == HAL_DTS_STATE_READY)
00317   {
00318     hdts->State = HAL_DTS_STATE_BUSY;
00319 
00320     /* Enable DTS sensor */
00321     __HAL_DTS_ENABLE(hdts);
00322 
00323     /* Get Start Tick*/
00324     Ref_Time = HAL_GetTick();
00325 
00326     /* Wait till TS1_RDY flag is set */
00327     while (__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_RDY) == RESET)
00328     {
00329       if ((HAL_GetTick() - Ref_Time) > DTS_DELAY_STARTUP)
00330       {
00331         return HAL_TIMEOUT;
00332       }
00333     }
00334 
00335     if (__HAL_DTS_GET_TRIGGER(hdts) == DTS_TRIGGER_HW_NONE)
00336     {
00337       /* Start continuous measures */
00338       SET_BIT(hdts->Instance->CFGR1, DTS_CFGR1_TS1_START);
00339 
00340       /* Ensure start is taken into account */
00341       HAL_Delay(TS_TIMEOUT_MS);
00342     }
00343 
00344     hdts->State = HAL_DTS_STATE_READY;
00345   }
00346   else
00347   {
00348     return HAL_BUSY;
00349   }
00350 
00351   return HAL_OK;
00352 }
00353 
00354 /**
00355   * @brief  Stop the DTS Sensor.
00356   * @param  hdts  DTS handle
00357   * @retval HAL status
00358   */
00359 HAL_StatusTypeDef HAL_DTS_Stop(DTS_HandleTypeDef *hdts)
00360 {
00361   /* Check the DTS handle allocation */
00362   if (hdts == NULL)
00363   {
00364     return HAL_ERROR;
00365   }
00366 
00367   if (hdts->State == HAL_DTS_STATE_READY)
00368   {
00369     hdts->State = HAL_DTS_STATE_BUSY;
00370 
00371     if (__HAL_DTS_GET_TRIGGER(hdts) == DTS_TRIGGER_HW_NONE)
00372     {
00373       CLEAR_BIT(hdts->Instance->CFGR1, DTS_CFGR1_TS1_START);
00374     }
00375 
00376     /* Disable the selected DTS sensor */
00377     __HAL_DTS_DISABLE(hdts);
00378 
00379     hdts->State = HAL_DTS_STATE_READY;
00380   }
00381   else
00382   {
00383     return HAL_BUSY;
00384   }
00385 
00386   return HAL_OK;
00387 }
00388 
00389 /**
00390   * @brief  Enable the interrupt(s) and start the DTS sensor
00391   * @param  hdts  DTS handle
00392   * @retval HAL status
00393   */
00394 HAL_StatusTypeDef HAL_DTS_Start_IT(DTS_HandleTypeDef *hdts)
00395 {
00396   uint32_t Ref_Time;
00397 
00398   /* Check the DTS handle allocation */
00399   if (hdts == NULL)
00400   {
00401     return HAL_ERROR;
00402   }
00403 
00404   if (hdts->State == HAL_DTS_STATE_READY)
00405   {
00406     hdts->State = HAL_DTS_STATE_BUSY;
00407 
00408     /* On Asynchronous mode enable the asynchronous IT */
00409     if (hdts->Init.RefClock == DTS_REFCLKSEL_LSE)
00410     {
00411       __HAL_DTS_ENABLE_IT(hdts, DTS_IT_TS1_AITE | DTS_IT_TS1_AITL | DTS_IT_TS1_AITH);
00412     }
00413     else
00414     {
00415       /* Enable the IT(s) */
00416       __HAL_DTS_ENABLE_IT(hdts, DTS_IT_TS1_ITE | DTS_IT_TS1_ITL | DTS_IT_TS1_ITH);
00417     }
00418 
00419     /* Enable the selected DTS sensor */
00420     __HAL_DTS_ENABLE(hdts);
00421 
00422     /* Get Start Tick*/
00423     Ref_Time = HAL_GetTick();
00424 
00425     /* Wait till TS1_RDY flag is set */
00426     while (__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_RDY) == RESET)
00427     {
00428       if ((HAL_GetTick() - Ref_Time) > DTS_DELAY_STARTUP)
00429       {
00430         return HAL_TIMEOUT;
00431       }
00432     }
00433 
00434     if (__HAL_DTS_GET_TRIGGER(hdts) == DTS_TRIGGER_HW_NONE)
00435     {
00436       /* Start continuous measures */
00437       SET_BIT(hdts->Instance->CFGR1, DTS_CFGR1_TS1_START);
00438 
00439       /* Ensure start is taken into account */
00440       HAL_Delay(TS_TIMEOUT_MS);
00441     }
00442 
00443     hdts->State = HAL_DTS_STATE_READY;
00444   }
00445   else
00446   {
00447     return HAL_BUSY;
00448   }
00449 
00450   return HAL_OK;
00451 }
00452 
00453 /**
00454   * @brief  Disable the interrupt(s) and stop the DTS sensor.
00455   * @param  hdts  DTS handle
00456   * @retval HAL status
00457   */
00458 HAL_StatusTypeDef HAL_DTS_Stop_IT(DTS_HandleTypeDef *hdts)
00459 {
00460   /* Check the DTS handle allocation */
00461   if (hdts == NULL)
00462   {
00463     return HAL_ERROR;
00464   }
00465 
00466   if (hdts->State == HAL_DTS_STATE_READY)
00467   {
00468     hdts->State = HAL_DTS_STATE_BUSY;
00469 
00470     /* On Asynchronous mode disable the asynchronous IT */
00471     if (hdts->Init.RefClock == DTS_REFCLKSEL_LSE)
00472     {
00473       __HAL_DTS_DISABLE_IT(hdts, DTS_IT_TS1_AITE | DTS_IT_TS1_AITL | DTS_IT_TS1_AITH);
00474     }
00475     else
00476     {
00477       /* Disable the IT(s) */
00478       __HAL_DTS_DISABLE_IT(hdts, DTS_IT_TS1_ITE | DTS_IT_TS1_ITL | DTS_IT_TS1_ITH);
00479     }
00480 
00481     if (__HAL_DTS_GET_TRIGGER(hdts) == DTS_TRIGGER_HW_NONE)
00482     {
00483       CLEAR_BIT(hdts->Instance->CFGR1, DTS_CFGR1_TS1_START);
00484     }
00485 
00486     /* Disable the selected DTS sensor */
00487     __HAL_DTS_DISABLE(hdts);
00488 
00489     hdts->State = HAL_DTS_STATE_READY;
00490   }
00491   else
00492   {
00493     return HAL_BUSY;
00494   }
00495 
00496   return HAL_OK;
00497 }
00498 
00499 /**
00500   * @brief  Get temperature from DTS
00501   * @param  hdts         DTS handle
00502   * @param  Temperature  Temperature in deg C
00503   * @note This function retrieves latest available measure
00504   * @retval HAL status
00505   */
00506 HAL_StatusTypeDef HAL_DTS_GetTemperature(DTS_HandleTypeDef *hdts, int32_t *Temperature)
00507 {
00508   uint32_t freq_meas;
00509   uint32_t samples;
00510   uint32_t t0_temp;
00511   uint32_t t0_freq;
00512   uint32_t ramp_coeff;
00513 
00514   if (hdts->State == HAL_DTS_STATE_READY)
00515   {
00516     hdts->State = HAL_DTS_STATE_BUSY;
00517 
00518     /* Get the total number of samples */
00519     samples = (hdts->Instance->DR & DTS_DR_TS1_MFREQ);
00520 
00521     if ((hdts->Init.SamplingTime == 0UL) || (samples == 0UL))
00522     {
00523       hdts->State = HAL_DTS_STATE_READY;
00524       return HAL_ERROR;
00525     }
00526 
00527     if ((hdts->Init.RefClock) == DTS_REFCLKSEL_LSE)
00528     {
00529       freq_meas = (LSE_VALUE * samples) / (hdts->Init.SamplingTime >> DTS_CFGR1_TS1_SMP_TIME_Pos); /* On Hz */
00530     }
00531     else
00532     {
00533       freq_meas = (HAL_RCCEx_GetD3PCLK1Freq() * (hdts->Init.SamplingTime >> DTS_CFGR1_TS1_SMP_TIME_Pos)) / samples; /* On Hz */
00534     }
00535 
00536     /* Read factory settings */
00537     t0_temp = hdts->Instance->T0VALR1 >> DTS_T0VALR1_TS1_T0_Pos;
00538 
00539     if (t0_temp == 0UL)
00540     {
00541       t0_temp = 30UL; /* 30 deg C */
00542     }
00543     else if (t0_temp == 1UL)
00544     {
00545       t0_temp = 110UL; /* 110 deg C */
00546     }
00547     else
00548     {
00549       hdts->State = HAL_DTS_STATE_READY;
00550       return HAL_ERROR;
00551     }
00552 
00553     t0_freq = (hdts->Instance->T0VALR1 & DTS_T0VALR1_TS1_FMT0) * 100UL; /* Hz */
00554 
00555     ramp_coeff = hdts->Instance->RAMPVALR & DTS_RAMPVALR_TS1_RAMP_COEFF; /* deg C/Hz */
00556 
00557     if (ramp_coeff == 0UL)
00558     {
00559       hdts->State = HAL_DTS_STATE_READY;
00560       return HAL_ERROR;
00561     }
00562 
00563     /* Figure out the temperature deg C */
00564     *Temperature = (int32_t)t0_temp + (((int32_t)freq_meas - (int32_t)t0_freq) / (int32_t)ramp_coeff);
00565 
00566     hdts->State = HAL_DTS_STATE_READY;
00567   }
00568   else
00569   {
00570     return HAL_BUSY;
00571   }
00572 
00573   return HAL_OK;
00574 }
00575 
00576 /**
00577   * @brief  DTS sensor IRQ Handler.
00578   * @param  hdts  DTS handle
00579   * @retval None
00580   */
00581 void HAL_DTS_IRQHandler(DTS_HandleTypeDef *hdts)
00582 {
00583   /* Check end of measure Asynchronous IT */
00584   if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_AITE)) != RESET)
00585   {
00586       __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_AITE);
00587 
00588 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00589       hdts->AsyncEndCallback(hdts);
00590 #else
00591       HAL_DTS_AsyncEndCallback(hdts);
00592 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00593   }
00594 
00595   /* Check low threshold Asynchronous IT */
00596   if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_AITL)) != RESET)
00597   {
00598       __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_AITL);
00599 
00600 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00601       hdts->AsyncLowCallback(hdts);
00602 #else
00603       HAL_DTS_AsyncLowCallback(hdts);
00604 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00605   }
00606 
00607   /* Check high threshold Asynchronous IT */
00608   if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_AITH)) != RESET)
00609   {
00610       __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_AITH);
00611 
00612 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00613       hdts->AsyncHighCallback(hdts);
00614 #else
00615       HAL_DTS_AsyncHighCallback(hdts);
00616 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00617   }
00618 
00619   /* Check end of measure IT */
00620   if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_ITE)) != RESET)
00621   {
00622       __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_ITE);
00623 
00624 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00625       hdts->EndCallback(hdts);
00626 #else
00627       HAL_DTS_EndCallback(hdts);
00628 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00629   }
00630 
00631   /* Check low threshold IT */
00632   if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_ITL)) != RESET)
00633   {
00634       __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_ITL);
00635 
00636 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00637       hdts->LowCallback(hdts);
00638 #else
00639       HAL_DTS_LowCallback(hdts);
00640 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00641   }
00642 
00643   /* Check high threshold IT */
00644   if ((__HAL_DTS_GET_FLAG(hdts, DTS_FLAG_TS1_ITH)) != RESET)
00645   {
00646       __HAL_DTS_CLEAR_FLAG(hdts, DTS_FLAG_TS1_ITH);
00647 
00648 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00649       hdts->HighCallback(hdts);
00650 #else
00651       HAL_DTS_HighCallback(hdts);
00652 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00653   }
00654 }
00655 
00656 /**
00657   * @brief  DTS Sensor End measure callback.
00658   * @param  hdts  DTS handle
00659   * @retval None
00660   */
00661 __weak void HAL_DTS_EndCallback(DTS_HandleTypeDef *hdts)
00662 {
00663   /* Prevent unused argument(s) compilation warning */
00664   UNUSED(hdts);
00665 
00666   /* NOTE : This function should not be modified, when the callback is needed,
00667   the HAL_DTS_EndCallback should be implemented in the user file
00668   */
00669 }
00670 
00671 /**
00672   * @brief  DTS Sensor low threshold measure callback.
00673   * @param  hdts  DTS handle
00674   * @retval None
00675   */
00676 __weak void HAL_DTS_LowCallback(DTS_HandleTypeDef *hdts)
00677 {
00678   /* Prevent unused argument(s) compilation warning */
00679   UNUSED(hdts);
00680 
00681   /* NOTE : This function should not be modified, when the callback is needed,
00682   the HAL_DTS_LowCallback should be implemented in the user file
00683   */
00684 }
00685 
00686 /**
00687   * @brief  DTS Sensor high threshold measure callback.
00688   * @param  hdts  DTS handle
00689   * @retval None
00690   */
00691 __weak void HAL_DTS_HighCallback(DTS_HandleTypeDef *hdts)
00692 {
00693   /* Prevent unused argument(s) compilation warning */
00694   UNUSED(hdts);
00695 
00696   /* NOTE : This function should not be modified, when the callback is needed,
00697   the HAL_DTS_HighCallback should be implemented in the user file
00698   */
00699 }
00700 
00701 /**
00702   * @brief  DTS Sensor asynchronous end measure callback.
00703   * @param  hdts  DTS handle
00704   * @retval None
00705   */
00706 __weak void HAL_DTS_AsyncEndCallback(DTS_HandleTypeDef *hdts)
00707 {
00708   /* Prevent unused argument(s) compilation warning */
00709   UNUSED(hdts);
00710 
00711   /* NOTE : This function should not be modified, when the callback is needed,
00712   the HAL_DTS_AsyncEndCallback should be implemented in the user file
00713   */
00714 }
00715 
00716 /**
00717   * @brief  DTS Sensor asynchronous low threshold measure callback.
00718   * @param  hdts  DTS handle
00719   * @retval None
00720   */
00721 __weak void HAL_DTS_AsyncLowCallback(DTS_HandleTypeDef *hdts)
00722 {
00723   /* Prevent unused argument(s) compilation warning */
00724   UNUSED(hdts);
00725 
00726   /* NOTE : This function should not be modified, when the callback is needed,
00727   the HAL_DTS_AsyncLowCallback should be implemented in the user file
00728   */
00729 }
00730 
00731 /**
00732   * @brief  DTS Sensor asynchronous high threshold measure callback.
00733   * @param  hdts  DTS handle
00734   * @retval None
00735   */
00736 __weak void HAL_DTS_AsyncHighCallback(DTS_HandleTypeDef *hdts)
00737 {
00738   /* Prevent unused argument(s) compilation warning */
00739   UNUSED(hdts);
00740 
00741   /* NOTE : This function should not be modified, when the callback is needed,
00742   the HAL_DTS_AsyncHighCallback should be implemented in the user file
00743   */
00744 }
00745 
00746 /**
00747   * @}
00748   */
00749 
00750 /** @defgroup DTS_Exported_Functions_Group3 Peripheral State functions
00751  *  @brief   Peripheral State functions.
00752  *
00753 @verbatim
00754  ===============================================================================
00755                       ##### Peripheral State functions #####
00756  ===============================================================================
00757     [..]
00758     This subsection permits to get in run-time the status of the peripheral.
00759 
00760 @endverbatim
00761   * @{
00762   */
00763 
00764 /**
00765   * @brief  Return the DTS handle state.
00766   * @param  hdts  DTS handle
00767   * @retval HAL state
00768   */
00769 HAL_DTS_StateTypeDef HAL_DTS_GetState(DTS_HandleTypeDef *hdts)
00770 {
00771   /* Check the DTS handle allocation */
00772   if (hdts == NULL)
00773   {
00774     return HAL_DTS_STATE_RESET;
00775   }
00776 
00777   /* Return DTS handle state */
00778   return hdts->State;
00779 }
00780 /**
00781   * @}
00782   */
00783 
00784 /**
00785   * @}
00786   */
00787 
00788 /* Private functions ---------------------------------------------------------*/
00789 
00790 /** @defgroup DTS_Private_Functions DTS Private Functions
00791   * @{
00792   */
00793 #if (USE_HAL_DTS_REGISTER_CALLBACKS == 1)
00794 /**
00795   * @brief  Reset interrupt callbacks to the legacy weak callbacks.
00796   * @param  hdts pointer to a DTS_HandleTypeDef structure that contains
00797   *                the configuration information for DTS module.
00798   * @retval None
00799   */
00800 static void DTS_ResetCallback(DTS_HandleTypeDef *hdts)
00801 {
00802   /* Reset the DTS callback to the legacy weak callbacks */
00803   hdts->DTS_EndCallback       = HAL_DTS_EndCallback;        /* End measure Callback                 */
00804   hdts->DTS_LowCallback       = HAL_DTS_LowCallback;        /* low threshold Callback               */
00805   hdts->DTS_HighCallback      = HAL_DTS_HighCallback;       /* high threshold Callback              */
00806   hdts->DTS_AsyncEndCallback  = HAL_DTS_AsyncEndCallback;   /* Asynchronous end of measure Callback */
00807   hdts->DTS_AsyncLowCallback  = HAL_DTS_AsyncLowCallback;   /* Asynchronous low threshold Callback  */
00808   hdts->DTS_AsyncHighCallback = HAL_DTS_AsyncHighCallback;  /* Asynchronous high threshold Callback */
00809 }
00810 #endif /* USE_HAL_DTS_REGISTER_CALLBACKS */
00811 /**
00812   * @}
00813   */
00814 
00815 /**
00816   * @}
00817   */
00818 
00819 #endif /* DTS */
00820 
00821 #endif /* HAL_DTS_MODULE_ENABLED */
00822 
00823 /**
00824   * @}
00825   */
00826