fix of port storage
This commit is contained in:
parent
6ecbe2f48a
commit
8117d3f890
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue