disable battery level LEDs
This commit is contained in:
10
README.md
10
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 |
|
| Signal | PCB Usage | LOW | HIGH |
|
||||||
|--------|-------------------|--------------------------|---------------------------|
|
|--------|-------------------|--------------------------|---------------------------|
|
||||||
| PA6 | Green LED | LED **ON** | LED OFF |
|
| PA6 | Green LED | LED **ON** | LED **OFF** |
|
||||||
| PA7 | Red LED | LED **ON** | LED OFF |
|
| PA7 | Red LED | LED **ON** | LED **OFF** |
|
||||||
| PA1 | LED 1–2 | LED(s) **ON** | LED(s) OFF |
|
| PA1 | LED 1–2 | LED(s) **OFF** | LED(s) **ON** |
|
||||||
| PA2 | LED 3–6 | LED(s) **ON** | LED(s) OFF |
|
| PA2 | LED 3–6 | LED(s) **OFF** | LED(s) **ON** |
|
||||||
| PA3 | LED 7–8 | LED(s) **ON** | LED(s) OFF |
|
| PA3 | LED 7–8 | LED(s) **OFF** | LED(s) **ON** |
|
||||||
| PA0 | Activation Button | Button **pressed** (GND) | Button released (pull-up) |
|
| PA0 | Activation Button | Button **pressed** (GND) | Button released (pull-up) |
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
14
main.c
14
main.c
@ -31,6 +31,7 @@ volatile bool bBtnPressed = false;
|
|||||||
void blinkLed(bool resetCounters);
|
void blinkLed(bool resetCounters);
|
||||||
static inline void leds_off(void);
|
static inline void leds_off(void);
|
||||||
static inline void leds_on(void);
|
static inline void leds_on(void);
|
||||||
|
static void battery_level_indicator(void);
|
||||||
static void handleSwitch(void);
|
static void handleSwitch(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +40,7 @@ static void handleSwitch(void);
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
|
|
||||||
// Configure PA0 as input with pull-up
|
// Configure PA0 as input with pull-up
|
||||||
VPORTA.DIR &= ~BUTTON_PIN_MASK; // Input
|
VPORTA.DIR &= ~BUTTON_PIN_MASK; // Input
|
||||||
@ -47,7 +48,7 @@ int main(void)
|
|||||||
|
|
||||||
// Ensure all LEDs off at startup
|
// Ensure all LEDs off at startup
|
||||||
leds_off();
|
leds_off();
|
||||||
VPORTA.OUT &= (uint8_t)~PA7_SET_MASK;
|
battery_level_indicator(); // TODO: Implement
|
||||||
|
|
||||||
bool bLedEnabledOld = bLedEnabled;
|
bool bLedEnabledOld = bLedEnabled;
|
||||||
|
|
||||||
@ -107,6 +108,15 @@ static inline void leds_on(void)
|
|||||||
VPORTA.OUT |= (PA1_SET_MASK | PA2_SET_MASK | PA3_SET_MASK);
|
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
|
* @brief Handle momentary switch input on PA0
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user