void nrf5TempProcess(void) { int32_t prevTemperature = sTemperature; uint64_t now; #if SOFTDEVICE_PRESENT now = nrf5AlarmGetCurrentTime(); if (now - sLastReadTimestamp > (TEMP_MEASUREMENT_INTERVAL * US_PER_S)) { (void)sd_temp_get(&sTemperature); sLastReadTimestamp = now; } #else if (NRF_TEMP->EVENTS_DATARDY) { dataReadyEventClear(); sTemperature = nrf_temp_read(); } now = nrf5AlarmGetCurrentTime(); if (now - sLastReadTimestamp > (TEMP_MEASUREMENT_INTERVAL * US_PER_S)) { NRF_TEMP->TASKS_START = 1; sLastReadTimestamp = now; } #endif if (prevTemperature != sTemperature) { nrf_802154_temperature_changed(); } }
int32_t nrf5TempGet(void) { NRF_TEMP->TASKS_START = 1; while (NRF_TEMP->EVENTS_DATARDY == 0) { ; } dataReadyEventClear(); int32_t temperature = nrf_temp_read(); NRF_TEMP->TASKS_STOP = 1; return temperature; }