From f67c122a60b1abc44b16d1ede66c6ee5954d3811 Mon Sep 17 00:00:00 2001 From: Thammi Date: Tue, 27 Aug 2013 00:54:30 +0200 Subject: [PATCH] Turn off IR, use HAL in blink and implement some HAL --- firmware/README.md | 1 + firmware/apps/blinker.c | 13 +++++-------- firmware/lib/hal.c | 26 +++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/firmware/README.md b/firmware/README.md index 63df181..d0a41ab 100644 --- a/firmware/README.md +++ b/firmware/README.md @@ -47,4 +47,5 @@ call the REGISTER() macro to define the entry point to your application. * _delay_ms() function will be replaced (it waits too long and the application cannot be quit while waiting) * add more functions to the hardware abstraction layer +* a mechanism to select which applications to include in the firmware diff --git a/firmware/apps/blinker.c b/firmware/apps/blinker.c index 0580f90..f7d604c 100644 --- a/firmware/apps/blinker.c +++ b/firmware/apps/blinker.c @@ -6,19 +6,16 @@ #include #include +#include static void init(void) { - _delay_ms(1000); + led_on(RIGHT); } static void blinker(void) { - PORTD |= 1 << 4; - _delay_ms(800); - test_stop_app(); - - PORTD &= ~(1 << 4); - _delay_ms(200); - test_stop_app(); + led_inv(RIGHT); + led_inv(LEFT); + _delay_ms(500); } REGISTER(blinker, init, NULL); diff --git a/firmware/lib/hal.c b/firmware/lib/hal.c index 3c8908d..444873d 100644 --- a/firmware/lib/hal.c +++ b/firmware/lib/hal.c @@ -9,7 +9,7 @@ #include -static uint8_t ir_active = 1; +static uint8_t ir_active = 0; static int int_skip = 0; static int button_count[2]; @@ -85,3 +85,27 @@ void reset_hw(void) { DDRD = (1 << 2) | (1 << 4); } +void led_on(uint8_t led) { + if(led == RIGHT) { + PORTC &= ~(1 << 2); + } else { + PORTD &= ~(1 << 4); + } +} + +void led_off(uint8_t led) { + if(led == RIGHT) { + PORTC |= 1 << 2; + } else { + PORTD |= 1 << 4; + } +} + +void led_inv(uint8_t led) { + if(led == RIGHT) { + PORTC ^= 1 << 2; + } else { + PORTD ^= 1 << 4; + } +} +