From 25050d45000355a522cd289bfd84ece295682cfd Mon Sep 17 00:00:00 2001 From: Inamr Date: Wed, 13 Mar 2024 12:13:38 +0100 Subject: [PATCH] Made comments on the code --- prosjekt.X/voltage.c | 5 ++++- prosjekt.X/voltage.h | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/prosjekt.X/voltage.c b/prosjekt.X/voltage.c index 4474dcd..127ef13 100644 --- a/prosjekt.X/voltage.c +++ b/prosjekt.X/voltage.c @@ -1,12 +1,14 @@ #include "voltage.h" +#include "uart.h" void sensor_init(void) { /* Disable digital input buffer */ } void ADC0_init(void) { + /* Initializing ADC0 pin*/ PORTD.PIN6CTRL &= ~PORT_ISC_gm; - PORTD.PIN6CTRL |= PORT_ISC_INPUT_DISABLE_gc; + PORTD.PIN6CTRL |= PORT_ISC_INPUT_DISABLE_gc; /* Disable */ PORTD.PIN6CTRL &= PORT_PULLUPEN_bm; ADC0.CTRLC = ADC_PRESC_DIV4_gc; @@ -30,6 +32,7 @@ uint16_t ADC0_read(void) { } uint8_t voltage_values(void) { + /* Gets values */ uint8_t adcVal = ADC0_read(); VREF.ADC0REF = VREF_REFSEL_VDD_gc; return adcVal; diff --git a/prosjekt.X/voltage.h b/prosjekt.X/voltage.h index 27bc2df..a2fdecd 100644 --- a/prosjekt.X/voltage.h +++ b/prosjekt.X/voltage.h @@ -44,11 +44,16 @@ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +// Initializing of the sensor pins void sensor_init(void); +// Initializing of the ADC0 pins void ADC0_init(void); -void ADC0_start(void); -uint8_t ADC0_read(void); -void voltage_values(void); +// +//void ADC0_start(void); +//Start ADC conversion +uint16_t ADC0_read(void); +// Gets the value from sensor and internal voltage +uint8_t voltage_values(void); #ifdef __cplusplus } #endif /* __cplusplus */