fsl_tempmon.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright 2018-2021 NXP
  3. * All rights reserved.
  4. *
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_TEMPMON_H_
  9. #define _FSL_TEMPMON_H_
  10. #include "fsl_common.h"
  11. /*!
  12. * @addtogroup tempmon
  13. * @{
  14. */
  15. /*! @file */
  16. /*******************************************************************************
  17. * Definitions
  18. ******************************************************************************/
  19. /*! @name Driver version */
  20. /*@{*/
  21. /*! @brief TEMPMON driver version. */
  22. #define FSL_TEMPMON_DRIVER_VERSION (MAKE_VERSION(2, 1, 1))
  23. /*@}*/
  24. /*! @brief TEMPMON temperature structure. */
  25. typedef struct _tempmon_config
  26. {
  27. uint16_t frequency; /*!< The temperature measure frequency.*/
  28. int8_t highAlarmTemp; /*!< The high alarm temperature.*/
  29. int8_t panicAlarmTemp; /*!< The panic alarm temperature.*/
  30. int8_t lowAlarmTemp; /*!< The low alarm temperature.*/
  31. } tempmon_config_t;
  32. /*! @brief TEMPMON alarm mode. */
  33. typedef enum _tempmon_alarm_mode
  34. {
  35. kTEMPMON_HighAlarmMode = 0U, /*!< The high alarm temperature interrupt mode.*/
  36. kTEMPMON_PanicAlarmMode = 1U, /*!< The panic alarm temperature interrupt mode.*/
  37. kTEMPMON_LowAlarmMode = 2U, /*!< The low alarm temperature interrupt mode.*/
  38. } tempmon_alarm_mode;
  39. /*******************************************************************************
  40. * API
  41. ******************************************************************************/
  42. #if defined(__cplusplus)
  43. extern "C" {
  44. #endif
  45. /*!
  46. * @brief Initializes the TEMPMON module.
  47. *
  48. * @param base TEMPMON base pointer
  49. * @param config Pointer to configuration structure.
  50. */
  51. void TEMPMON_Init(TEMPMON_Type *base, const tempmon_config_t *config);
  52. /*!
  53. * @brief Deinitializes the TEMPMON module.
  54. *
  55. * @param base TEMPMON base pointer
  56. */
  57. void TEMPMON_Deinit(TEMPMON_Type *base);
  58. /*!
  59. * @brief Gets the default configuration structure.
  60. *
  61. * This function initializes the TEMPMON configuration structure to a default value. The default
  62. * values are:
  63. * tempmonConfig->frequency = 0x02U;
  64. * tempmonConfig->highAlarmTemp = 44U;
  65. * tempmonConfig->panicAlarmTemp = 90U;
  66. * tempmonConfig->lowAlarmTemp = 39U;
  67. *
  68. * @param config Pointer to a configuration structure.
  69. */
  70. void TEMPMON_GetDefaultConfig(tempmon_config_t *config);
  71. /*!
  72. * @brief start the temperature measurement process.
  73. *
  74. * @param base TEMPMON base pointer.
  75. */
  76. static inline void TEMPMON_StartMeasure(TEMPMON_Type *base)
  77. {
  78. base->TEMPSENSE0 |= TEMPMON_TEMPSENSE0_MEASURE_TEMP_MASK;
  79. }
  80. /*!
  81. * @brief stop the measurement process.
  82. *
  83. * @param base TEMPMON base pointer
  84. */
  85. static inline void TEMPMON_StopMeasure(TEMPMON_Type *base)
  86. {
  87. base->TEMPSENSE0 &= ~TEMPMON_TEMPSENSE0_MEASURE_TEMP_MASK;
  88. }
  89. /*!
  90. * @brief Get current temperature with the fused temperature calibration data.
  91. *
  92. * @param base TEMPMON base pointer
  93. * @return current temperature with degrees Celsius.
  94. */
  95. float TEMPMON_GetCurrentTemperature(TEMPMON_Type *base);
  96. /*!
  97. * @brief Set the temperature count (raw sensor output) that will generate an alarm interrupt.
  98. *
  99. * @param base TEMPMON base pointer
  100. * @param tempVal The alarm temperature with degrees Celsius
  101. * @param alarmMode The alarm mode.
  102. */
  103. void TEMPMON_SetTempAlarm(TEMPMON_Type *base, int8_t tempVal, tempmon_alarm_mode alarmMode);
  104. #if defined(__cplusplus)
  105. }
  106. #endif
  107. /*! @}*/
  108. #endif /* _FSL_TEMPMON_H_ */