diff --git a/nyx/nyx_gui/thermal/tmp451.c b/nyx/nyx_gui/thermal/tmp451.c index b077a50..79c503d 100644 --- a/nyx/nyx_gui/thermal/tmp451.c +++ b/nyx/nyx_gui/thermal/tmp451.c @@ -50,3 +50,16 @@ u16 tmp451_get_pcb_temp(bool intenger) return temp; } + +void tmp451_init() +{ + // Disable ALARM. + i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CONFIG_REG, 0x80); + + // Set conversion rate to 32/s and make a read to update the reg. + i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CNV_RATE_REG, 9); + tmp451_get_soc_temp(false); + + // Set rate to every 4 seconds. + i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CNV_RATE_REG, 2); +} diff --git a/nyx/nyx_gui/thermal/tmp451.h b/nyx/nyx_gui/thermal/tmp451.h index cd626ac..00a0816 100644 --- a/nyx/nyx_gui/thermal/tmp451.h +++ b/nyx/nyx_gui/thermal/tmp451.h @@ -25,6 +25,10 @@ #define TMP451_PCB_TEMP_REG 0x00 #define TMP451_SOC_TEMP_REG 0x01 + +#define TMP451_CONFIG_REG 0x09 +#define TMP451_CNV_RATE_REG 0x0A + #define TMP451_SOC_TMP_DEC_REG 0x10 #define TMP451_PCB_TMP_DEC_REG 0x15 @@ -33,5 +37,6 @@ // Otherwise it's an integer oC. u16 tmp451_get_soc_temp(bool integer); u16 tmp451_get_pcb_temp(bool integer); +void tmp451_init(); #endif /* __TMP451_H_ */