nrf5/hal/timer: Add support for fetching temperature if bluetooth stack is enabled.

This commit is contained in:
Glenn Ruben Bakke 2017-06-05 21:11:44 +02:00 committed by Daniel Tralamazza
parent 4a52f8401b
commit d53596145a
1 changed files with 20 additions and 2 deletions

View File

@ -25,9 +25,17 @@
*/
#include <stdio.h>
#include <stdint.h>
#include "mphalport.h"
#include "hal_temp.h"
#if BLUETOOTH_SD
#include "py/nlr.h"
#include "ble_drv.h"
#include "nrf_soc.h"
#define BLUETOOTH_STACK_ENABLED() (ble_drv_stack_enabled())
#endif // BLUETOOTH_SD
#ifdef HAL_TEMP_MODULE_ENABLED
void hal_temp_init(void) {
@ -35,7 +43,17 @@ void hal_temp_init(void) {
*(uint32_t *) 0x4000C504 = 0;
}
int32_t hal_temp_read(void) {
#if BLUETOOTH_SD
if (BLUETOOTH_STACK_ENABLED() == 1) {
int32_t temp;
(void)sd_temp_get(&temp);
return temp / 4; // resolution of 0.25 degree celsius
}
#endif // BLUETOOTH_SD
int32_t volatile temp;
hal_temp_init();