From 8117d3f890c61adf8f81444999f5c1ec0f8743c8 Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Fri, 26 Jul 2024 18:19:36 -0700 Subject: [PATCH] fix of port storage --- src/ADC/ADC.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ADC/ADC.c b/src/ADC/ADC.c index e59f6cc..19b9926 100644 --- a/src/ADC/ADC.c +++ b/src/ADC/ADC.c @@ -5,6 +5,10 @@ * description: module_purpose */ +#ifndef __AVR_ATtiny404__ +#define __AVR_ATtiny404__ +#endif + #include "ADC.h" #include "RegEdit.h" #include "avr/io.h" @@ -22,12 +26,13 @@ static bool IsInvalidPin(uint8_t pin_num){ void ADC_Init(uint8_t pin_num) { - //Save the porta status. - porta_out = PORTA.OUT; - porta_dir = PORTA.DIR; if(IsInvalidPin(pin_num)){return;} + //Save the porta status. + //porta_out = PORTA.OUT; + //porta_dir = PORTA.DIR; + //set the direction to input RegEdit_SetBit((void *) &PORTA.DIRCLR, pin_num); @@ -78,8 +83,8 @@ void ADC_Disable() RegEdit_ClearBit((void *) &ADC0.CTRLA, 0); //Restore the port registers - PORTA.OUT = porta_out; - PORTA.DIR = porta_dir; + RegEdit_SetNum((void *) &PORTA.OUT, porta_out); + RegEdit_SetNum((void *) &PORTA.DIR, porta_dir); }