#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;
}
