summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-08-18 18:06:45 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-08-18 18:06:45 +0800
commit75290945b2fd84b3bc108fd46419ee478eaac3ca (patch)
tree67cb175a40e92ea1a4e21d4839e83acdc1083fa0
parent240990305089770785af0fc9d20ce9bf38053eb5 (diff)
downloadfpm-door-lock-75290945b2fd84b3bc108fd46419ee478eaac3ca.tar.gz
Add another LED for the back.HEADmaster
-rw-r--r--main.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/main.c b/main.c
index 116fcc3..caab488 100644
--- a/main.c
+++ b/main.c
@@ -17,9 +17,10 @@
#define PWM_MAX 2550
#define PWM_TOP 19999
-#define LED_PIN PD6
-#define LED_DDR DDRD
-#define LED_PORT PORTD
+#define LED_FPM_PIN PD5
+#define LED_BACK_PIN PD6
+#define LED_DDR DDRD
+#define LED_PORT PORTD
#define PWR_BAT PB2
#define PWR_SRVO PB3
@@ -105,8 +106,9 @@ static inline void unlock(void)
static inline void flash_led(void)
{
- TCCR0A = (1 << COM0A0) | (1 << WGM01);
+ TCCR0A = (1 << COM0A0) | (1 << COM0B0) | (1 << WGM01);
OCR0A = 255;
+ OCR0B = 255;
TCCR0B = (1 << CS02) | (1 << CS00);
}
@@ -114,7 +116,7 @@ static inline void stop_led(void)
{
TCCR0B = 0;
TCCR0A = 0;
- LED_PORT &= ~(1 << LED_PIN);
+ LED_PORT &= ~((1 << LED_FPM_PIN) | (1 << LED_BACK_PIN));
}
static void check_bat(void)
@@ -170,8 +172,8 @@ int main(void)
SRVO_DDR |= (1 << SRVO_PIN);
/* bat check */
- LED_DDR |= (1 << LED_PIN);
- LED_PORT &= ~(1 << LED_PIN);
+ LED_DDR |= (1 << LED_FPM_PIN) | (1 << LED_BACK_PIN);
+ LED_PORT &= ~((1 << LED_FPM_PIN) | (1 << LED_BACK_PIN));
DDRD &= ~(1 << PD2); /* FPM unlock pin */
PORTD |= (1 << PD2); /* FPM unlock pin internal pull-up */