Disable CPU while Rear Light is not used #3

Merged
localhorst merged 4 commits from feature/power-off into main 2025-10-25 14:49:38 +02:00
Showing only changes of commit 35c66787de - Show all commits
+1 -15
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);