From 91ee8b1af8b802a6d3904454ca1117ba5e1c3a46 Mon Sep 17 00:00:00 2001 From: Elp03 Date: Tue, 9 Apr 2024 14:56:14 +0200 Subject: [PATCH] Add muxpos to internal voltage --- prosjekt.X/voltage.c | 11 ++++++++--- prosjekt.X/voltage.h | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/prosjekt.X/voltage.c b/prosjekt.X/voltage.c index 4175c41..c62d872 100644 --- a/prosjekt.X/voltage.c +++ b/prosjekt.X/voltage.c @@ -36,13 +36,18 @@ uint16_t ADC0_read(void) { uint16_t thermistor_voltage_read() { /* Gets value for the diode */ ADC0.MUXPOS = 0x03; - uint8_t adcVal = ADC0_read(); + uint8_t adc_val = ADC0_read(); - return adcVal; + return adc_val; } uint16_t internal_voltage_read() { /* Gets value for the internal voltage reffreance*/ - return VREF.ADC0REF = VREF_REFSEL_VDD_gc; + VREF.ADC0REF = VREF_REFSEL_VDD_gc; + + ADC0.MUXPOS = 0x44; + uint8_t adc_val = ADC0_read(); + + return adc_val*10; } diff --git a/prosjekt.X/voltage.h b/prosjekt.X/voltage.h index dde41a5..af2e76d 100644 --- a/prosjekt.X/voltage.h +++ b/prosjekt.X/voltage.h @@ -55,7 +55,6 @@ extern "C" { // Gets the value from sensor and internal voltage uint16_t internal_voltage_read(); uint16_t thermistor_voltage_read(); - uint16_t internal_voltage_read(); #ifdef __cplusplus } #endif /* __cplusplus */