From ef86085343997c1cd3e8b101ffe89e01d63d5d73e79e800bf1adf609182689c0 Mon Sep 17 00:00:00 2001 From: localhorst Date: Sat, 6 Sep 2025 00:52:34 +0200 Subject: [PATCH] switch to PA0 as BTN --- main.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index 711ccfe..8bf2462 100644 --- a/main.c +++ b/main.c @@ -12,11 +12,12 @@ /** @defgroup LED_Masks LED bitmasks for PORTA * @{ */ -#define PA1_SET_MASK 0x02 ///< LED 1–2 -#define PA2_SET_MASK 0x04 ///< LED 3–6 -#define PA3_SET_MASK 0x08 ///< LED 7–8 -#define PA6_SET_MASK 0x40 ///< Switch input (was green LED pin) TODO: Switch to PA0 -#define PA7_SET_MASK 0x80 ///< Red LED +#define BUTTON_PIN_MASK 0x01 // PA0 +#define PA1_SET_MASK 0x02 ///< LED 1–2 +#define PA2_SET_MASK 0x04 ///< LED 3–6 +#define PA3_SET_MASK 0x08 ///< LED 7–8 +#define PA6_SET_MASK 0x40 ///< Green LED pin +#define PA7_SET_MASK 0x80 ///< Red LED /** @} */ #define MAIN_LOOP_SLEEP 10U // Main loop delay in ms (system tick) @@ -50,9 +51,9 @@ int main(void) /*PA6_SET_MASK |*/ // PA6 now input (switch) PA7_SET_MASK); - // Configure PA6 as input with pull-up TODO: Switch to PA0 - VPORTA.DIR &= ~PA6_SET_MASK; // Input - PORTA.PIN6CTRL = PORT_PULLUPEN_bm; // Pull-up enabled + // Configure PA0 as input with pull-up + VPORTA.DIR &= ~BUTTON_PIN_MASK; // Input + PORTA.PIN0CTRL = PORT_PULLUPEN_bm; // Pull-up enabled // --- ensure all LEDs off at startup --- leds_off(); @@ -128,7 +129,7 @@ static void handleSwitch(void) static uint16_t pressTicks = 0; ///< press duration counter static bool prevPressed = false; ///< previous switch state - bool pressed = !(VPORTA.IN & PA6_SET_MASK); // active-low + bool pressed = !(VPORTA.IN & BUTTON_PIN_MASK); // active-low if (pressed) {