This commit is contained in:
2025-10-25 14:18:03 +02:00
parent c9d30ef44e
commit 35c66787de

16
main.c
View File

@ -43,15 +43,6 @@ void software_reset(void)
{ {
CCP = CCP_IOREG_gc; // unlock protected registers CCP = CCP_IOREG_gc; // unlock protected registers
RSTCTRL.SWRR = 1; // trigger software reset RSTCTRL.SWRR = 1; // trigger software reset
cli(); // disable interrupts
// Unlock protected registers
CCP = CCP_IOREG_gc;
// Enable WDT with shortest period (~8 cycles)
WDT.CTRLA = WDT_PERIOD_8CLK_gc;
while (1) while (1)
; // wait for reset ; // wait for reset
} }
@ -60,6 +51,7 @@ ISR(PORTA_PORT_vect)
{ {
// Clear interrupt flags for PA0 // Clear interrupt flags for PA0
PORTA.INTFLAGS = BUTTON_PIN_MASK; PORTA.INTFLAGS = BUTTON_PIN_MASK;
if (!(VPORTA.IN & BUTTON_PIN_MASK)) // check PA0 low if (!(VPORTA.IN & BUTTON_PIN_MASK)) // check PA0 low
{ {
// Turn off all LEDs // Turn off all LEDs
@ -73,12 +65,6 @@ ISR(PORTA_PORT_vect)
*/ */
int main(void) int main(void)
{ {
bLedEnabled = true;
bBtnPressed = false;
cli(); // disable interrupts
// register8_t backuop_dir = VPORTA.DIR;
// Configure LED pins as outputs // Configure LED pins as outputs
VPORTA.DIR = (PA1_SET_MASK | PA2_SET_MASK | PA3_SET_MASK | PA6_SET_MASK | PA7_SET_MASK); VPORTA.DIR = (PA1_SET_MASK | PA2_SET_MASK | PA3_SET_MASK | PA6_SET_MASK | PA7_SET_MASK);