Made it into its own func

This commit is contained in:
Inamr 2024-03-13 11:46:02 +01:00
parent 4105c1ff04
commit efe623936a
3 changed files with 37 additions and 30 deletions

View File

@ -23,8 +23,7 @@ int main() {
stdout = &USART_stream;
while (1) {
uint16_t adcVal = ADC0_read();
VREF.ADC0REF = VREF_REFSEL_VDD_gc;
printf("The values: \n%u , %u\n",VREF_REFSEL_VDD_gc , adcVal);
voltage_values();
//printf("The values: \n%u , %u\n",VREF_REFSEL_VDD_gc , adcVal);
}
}

View File

@ -1,4 +1,5 @@
#include "voltage.h"
void sensor_init(void) {
/* Disable digital input buffer */
}
@ -27,3 +28,9 @@ uint16_t ADC0_read(void) {
ADC0.INTFLAGS = ADC_RESRDY_bm;
return ADC0.RES;
}
uint8_t voltage_values(void) {
uint8_t adcVal = ADC0_read();
VREF.ADC0REF = VREF_REFSEL_VDD_gc;
return adcVal;
}

View File

@ -47,7 +47,8 @@ extern "C" {
void sensor_init(void);
void ADC0_init(void);
void ADC0_start(void);
uint16_t ADC0_read(void);
uint8_t ADC0_read(void);
void voltage_values(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */