123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /*********************************************************************
- *
- * 文件名: User_temperature.c
- * 功能描述:设备以及芯片温度查询
- * 作者: 陈俊超
- * 时间:2020-12-11
- *
- ********************************************************************/
- #include "nrf.h"
- #include "nrf_temp.h"
- #include "User_temperature.h"
- /********************** 变量区 **************************************/
- /********************** 函数功能区 **************************************/
- /**********************************************************
- * 函数名字:Acquire_nrf_temp
- * 函数作用:获取NRF内部的温度
- * 函数参数:无
- * 函数返回值:无
- ***********************************************************/
- uint8_t Acquire_nrf_temp(void)
- {
- int32_t volatile temp;
- NRF_TEMP->TASKS_START = 1; /** Start the temperature measurement. */
- /* Busy wait while temperature measurement is not finished, you can skip waiting if you enable interrupt for DATARDY event and read the result in the interrupt. */
- /*lint -e{845} // A zero has been given as right argument to operator '|'" */
- while (NRF_TEMP->EVENTS_DATARDY == 0)
- {
- // Do nothing.
- }
- NRF_TEMP->EVENTS_DATARDY = 0;
- /**@note Workaround for PAN_028 rev2.0A anomaly 29 - TEMP: Stop task clears the TEMP register. */
- temp = (nrf_temp_read() / 4);
- /**@note Workaround for PAN_028 rev2.0A anomaly 30 - TEMP: Temp module analog front end does not power down when DATARDY event occurs. */
- NRF_TEMP->TASKS_STOP = 1; /** Stop the temperature measurement. */
- return temp;
- }
- /**********************************************************
- * 函数名字:User_temperature_init
- * 函数作用:温度查询初始化
- * 函数参数:无
- * 函数返回值:无
- ***********************************************************/
- void User_temperature_init(void)
- {
- nrf_temp_init();
- }
|