Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:01

0001 /*
0002  * Copyright  2018-2021 NXP
0003  * All rights reserved.
0004  *
0005  *
0006  * SPDX-License-Identifier: BSD-3-Clause
0007  */
0008 #ifndef _FSL_TEMPMON_H_
0009 #define _FSL_TEMPMON_H_
0010 
0011 #include "fsl_common.h"
0012 
0013 /*!
0014  * @addtogroup tempmon
0015  * @{
0016  */
0017 
0018 /*! @file */
0019 
0020 /*******************************************************************************
0021  * Definitions
0022  ******************************************************************************/
0023 
0024 /*! @name Driver version */
0025 /*@{*/
0026 /*! @brief TEMPMON driver version. */
0027 #define FSL_TEMPMON_DRIVER_VERSION (MAKE_VERSION(2, 1, 1))
0028 /*@}*/
0029 
0030 /*! @brief TEMPMON temperature structure. */
0031 typedef struct _tempmon_config
0032 {
0033     uint16_t frequency;    /*!< The temperature measure frequency.*/
0034     int8_t highAlarmTemp;  /*!< The high alarm temperature.*/
0035     int8_t panicAlarmTemp; /*!< The panic alarm temperature.*/
0036     int8_t lowAlarmTemp;   /*!< The low alarm temperature.*/
0037 } tempmon_config_t;
0038 
0039 /*! @brief TEMPMON alarm mode. */
0040 typedef enum _tempmon_alarm_mode
0041 {
0042     kTEMPMON_HighAlarmMode  = 0U, /*!< The high alarm temperature interrupt mode.*/
0043     kTEMPMON_PanicAlarmMode = 1U, /*!< The panic alarm temperature interrupt mode.*/
0044     kTEMPMON_LowAlarmMode   = 2U, /*!< The low alarm temperature interrupt mode.*/
0045 } tempmon_alarm_mode;
0046 
0047 /*******************************************************************************
0048  * API
0049  ******************************************************************************/
0050 
0051 #if defined(__cplusplus)
0052 extern "C" {
0053 #endif
0054 
0055 /*!
0056  * @brief Initializes the TEMPMON module.
0057  *
0058  * @param base TEMPMON base pointer
0059  * @param config Pointer to configuration structure.
0060  */
0061 void TEMPMON_Init(TEMPMON_Type *base, const tempmon_config_t *config);
0062 
0063 /*!
0064  * @brief Deinitializes the TEMPMON module.
0065  *
0066  * @param base TEMPMON base pointer
0067  */
0068 void TEMPMON_Deinit(TEMPMON_Type *base);
0069 
0070 /*!
0071  * @brief Gets the default configuration structure.
0072  *
0073  * This function initializes the TEMPMON configuration structure to a default value. The default
0074  * values are:
0075  *   tempmonConfig->frequency = 0x02U;
0076  *   tempmonConfig->highAlarmTemp = 44U;
0077  *   tempmonConfig->panicAlarmTemp = 90U;
0078  *   tempmonConfig->lowAlarmTemp = 39U;
0079  *
0080  * @param config Pointer to a configuration structure.
0081  */
0082 void TEMPMON_GetDefaultConfig(tempmon_config_t *config);
0083 
0084 /*!
0085  * @brief start the temperature measurement process.
0086  *
0087  * @param base TEMPMON base pointer.
0088  */
0089 static inline void TEMPMON_StartMeasure(TEMPMON_Type *base)
0090 {
0091     base->TEMPSENSE0 |= TEMPMON_TEMPSENSE0_MEASURE_TEMP_MASK;
0092 }
0093 
0094 /*!
0095  * @brief stop the measurement process.
0096  *
0097  * @param base TEMPMON base pointer
0098  */
0099 static inline void TEMPMON_StopMeasure(TEMPMON_Type *base)
0100 {
0101     base->TEMPSENSE0 &= ~TEMPMON_TEMPSENSE0_MEASURE_TEMP_MASK;
0102 }
0103 
0104 /*!
0105  * @brief Get current temperature with the fused temperature calibration data.
0106  *
0107  * @param base TEMPMON base pointer
0108  * @return current temperature with degrees Celsius.
0109  */
0110 float TEMPMON_GetCurrentTemperature(TEMPMON_Type *base);
0111 
0112 /*!
0113  * @brief Set the temperature count (raw sensor output) that will generate an alarm interrupt.
0114  *
0115  * @param base TEMPMON base pointer
0116  * @param tempVal The alarm temperature with degrees Celsius
0117  * @param alarmMode The alarm mode.
0118  */
0119 void TEMPMON_SetTempAlarm(TEMPMON_Type *base, int8_t tempVal, tempmon_alarm_mode alarmMode);
0120 
0121 #if defined(__cplusplus)
0122 }
0123 #endif
0124 
0125 /*! @}*/
0126 
0127 #endif /* _FSL_TEMPMON_H_ */