First commit
This commit is contained in:
16
drivers/temperature/temperature.c
Normal file
16
drivers/temperature/temperature.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "temperature.h"
|
||||
#include <nrfx_temp.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
||||
int temperature_init(void) {
|
||||
nrfx_temp_config_t cfg = NRFX_TEMP_DEFAULT_CONFIG;
|
||||
return nrfx_temp_init(&cfg, NULL);
|
||||
}
|
||||
|
||||
int temperature_get_celsius(int32_t *temp_c) {
|
||||
nrfx_temp_measure();
|
||||
int32_t raw = nrfx_temp_result_get();
|
||||
/* Convert to °C (raw is 0.25 °C per LSB) */
|
||||
*temp_c = raw / 4;
|
||||
return 0;
|
||||
}
|
||||
9
drivers/temperature/temperature.h
Normal file
9
drivers/temperature/temperature.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef TEMPERATURE_H
|
||||
#define TEMPERATURE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int temperature_init(void);
|
||||
int temperature_get_celsius(int32_t *temp_c);
|
||||
|
||||
#endif // TEMPERATURE_H
|
||||
Reference in New Issue
Block a user