File tree Expand file tree Collapse file tree 1 file changed +37
-2
lines changed
ports/nrf/common-hal/microcontroller Expand file tree Collapse file tree 1 file changed +37
-2
lines changed Original file line number Diff line number Diff line change 25
25
*/
26
26
27
27
#include "common-hal/microcontroller/Processor.h"
28
+ #include "py/runtime.h"
29
+
30
+ #ifdef BLUETOOTH_SD
31
+ #include "nrf_sdm.h"
32
+ #endif
33
+
34
+ #include "nrf.h"
28
35
29
- // TODO port common_hal_mcu_processor
30
36
float common_hal_mcu_processor_get_temperature (void ) {
31
- return 0 ;
37
+ int32_t temp = 0 ;
38
+
39
+ #ifdef BLUETOOTH_SD
40
+ uint8_t sd_en = 0 ;
41
+
42
+ (void ) sd_softdevice_is_enabled (& sd_en );
43
+
44
+ if (sd_en ) {
45
+ uint32_t err_code = sd_temp_get (& temp );
46
+ if (err_code != NRF_SUCCESS ) {
47
+ nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_OSError ,
48
+ "Can not get temperature. status: 0x" HEX2_FMT , (uint16_t )err_code ));
49
+
50
+ return 0 ;
51
+ }
52
+ }
53
+ #endif
54
+
55
+ NRF_TEMP -> TASKS_START = 1 ;
56
+
57
+ while (NRF_TEMP -> EVENTS_DATARDY == 0 )
58
+ ;
59
+
60
+ NRF_TEMP -> EVENTS_DATARDY = 0 ;
61
+
62
+ temp = NRF_TEMP -> TEMP ;
63
+
64
+ NRF_TEMP -> TASKS_STOP = 1 ;
65
+
66
+ return temp / 4.0f ;
32
67
}
33
68
34
69
uint32_t common_hal_mcu_processor_get_frequency (void ) {
You can’t perform that action at this time.
0 commit comments