diff --git a/README.md b/README.md index ca83fee..edea2fd 100644 --- a/README.md +++ b/README.md @@ -105,11 +105,11 @@ Hardware: FT232 USB-UART adapter connected to UPDI with a 4.7 kΩ resistor. | Signal | PCB Usage | LOW | HIGH | |--------|-------------------|--------------------------|---------------------------| -| PA6 | Green LED | LED **ON** | LED OFF | -| PA7 | Red LED | LED **ON** | LED OFF | -| PA1 | LED 1–2 | LED(s) **ON** | LED(s) OFF | -| PA2 | LED 3–6 | LED(s) **ON** | LED(s) OFF | -| PA3 | LED 7–8 | LED(s) **ON** | LED(s) OFF | +| PA6 | Green LED | LED **ON** | LED **OFF** | +| PA7 | Red LED | LED **ON** | LED **OFF** | +| PA1 | LED 1–2 | LED(s) **OFF** | LED(s) **ON** | +| PA2 | LED 3–6 | LED(s) **OFF** | LED(s) **ON** | +| PA3 | LED 7–8 | LED(s) **OFF** | LED(s) **ON** | | PA0 | Activation Button | Button **pressed** (GND) | Button released (pull-up) | ## License diff --git a/main.c b/main.c index 7e7001c..eacd981 100644 --- a/main.c +++ b/main.c @@ -31,6 +31,7 @@ volatile bool bBtnPressed = false; void blinkLed(bool resetCounters); static inline void leds_off(void); static inline void leds_on(void); +static void battery_level_indicator(void); static void handleSwitch(void); /** @@ -39,7 +40,7 @@ static void handleSwitch(void); int main(void) { // 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); // Configure PA0 as input with pull-up VPORTA.DIR &= ~BUTTON_PIN_MASK; // Input @@ -47,7 +48,7 @@ int main(void) // Ensure all LEDs off at startup leds_off(); - VPORTA.OUT &= (uint8_t)~PA7_SET_MASK; + battery_level_indicator(); // TODO: Implement bool bLedEnabledOld = bLedEnabled; @@ -107,6 +108,15 @@ static inline void leds_on(void) VPORTA.OUT |= (PA1_SET_MASK | PA2_SET_MASK | PA3_SET_MASK); } +/** + * @brief Battery monitoring + */ +static void battery_level_indicator(void) +{ + // TODO: Implement + VPORTA.OUT |= (PA6_SET_MASK | PA7_SET_MASK); // green + red OFF +} + /** * @brief Handle momentary switch input on PA0 *