Turn off IR, use HAL in blink and implement some HAL

This commit is contained in:
Thammi 2013-08-27 00:54:30 +02:00
parent 6c6b7713c8
commit f67c122a60
3 changed files with 31 additions and 9 deletions

View File

@ -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

View File

@ -6,19 +6,16 @@
#include <pentabug/app.h>
#include <pentabug/lifecycle.h>
#include <pentabug/hal.h>
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);

View File

@ -9,7 +9,7 @@
#include <pentabug/timer.h>
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;
}
}