嵌入式實操——基於RT1170 首板硬體之tempsensor除錯(二十一)

本文主要是透過遷移的思維,記錄本人初次使用NXP MCUXpresso SDK API進行BSP開發

本文主要是描述整合tempsensor模組介面,供應用開發人員使用。這當中有一個重要的功能,就是CPU的結溫達到設定的閾值時,CPU主動復位,本文的閾值的110度。

1。 首先閱讀原理圖

NA

2。 除錯過程

2。 1 tempsensor初始化

/*————————————————————————* * macros * *————————————————————————*/#define DEMO_TMPSNS TMPSNS#define DEMO_LOWALARMTEMP 0U#define DEMO_HIGHALARMTEMP 70#define DEMO_PINICALARMTEMP 110U/** * @brief tempsensor init * * @param [in] void * @param [out] None * * @return * * @history * 1。Date : 2021-5-28 14:7:9 * Author : panzidong * Modification : Created function */void bsp_tempsensor_init(void){ tmpsns_config_t config; TMPSNS_GetDefaultConfig(&config); config。measureMode = kTEMPSENSOR_ContinuousMode; config。frequency = 0x03U; /*設定MCU高溫警告閾值*/ config。highAlarmTemp = DEMO_HIGHALARMTEMP; /*設定MCU低溫警告閾值*/ config。lowAlarmTemp = DEMO_LOWALARMTEMP; /*設定MCU 復位警告閾值*/ config。panicAlarmTemp = DEMO_PINICALARMTEMP; TMPSNS_Init(DEMO_TMPSNS, &config); TMPSNS_StartMeasure(DEMO_TMPSNS); }

2。 2 tempsensor值獲取

** * @brief print mcu tempsensor info * * @param [in] void * @param [out] None * * @return * * @history * 1。Date : 2021-5-28 14:11:18 * Author : panzidong * Modification : Created function */void bsp_dump_tempsensor(void){ float temperature = 0U; /* Get temperature */ temperature = TMPSNS_GetCurrentTemperature(DEMO_TMPSNS); PRINTF(“temperature is %f celsius degree \r\n”, temperature); SDK_DelayAtLeastUs(1000*1000, SystemCoreClock); /* Get current temperature */ temperature = TMPSNS_GetCurrentTemperature(DEMO_TMPSNS); PRINTF(“temperature is %f celsius degree。 \r\n”, temperature);}

3。 總結

NA