Turn off IR, use HAL in blink and implement some HAL
This commit is contained in:
parent
6c6b7713c8
commit
f67c122a60
|
@ -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
|
* _delay_ms() function will be replaced (it waits too long and the application
|
||||||
cannot be quit while waiting)
|
cannot be quit while waiting)
|
||||||
* add more functions to the hardware abstraction layer
|
* add more functions to the hardware abstraction layer
|
||||||
|
* a mechanism to select which applications to include in the firmware
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,16 @@
|
||||||
|
|
||||||
#include <pentabug/app.h>
|
#include <pentabug/app.h>
|
||||||
#include <pentabug/lifecycle.h>
|
#include <pentabug/lifecycle.h>
|
||||||
|
#include <pentabug/hal.h>
|
||||||
|
|
||||||
static void init(void) {
|
static void init(void) {
|
||||||
_delay_ms(1000);
|
led_on(RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blinker(void) {
|
static void blinker(void) {
|
||||||
PORTD |= 1 << 4;
|
led_inv(RIGHT);
|
||||||
_delay_ms(800);
|
led_inv(LEFT);
|
||||||
test_stop_app();
|
_delay_ms(500);
|
||||||
|
|
||||||
PORTD &= ~(1 << 4);
|
|
||||||
_delay_ms(200);
|
|
||||||
test_stop_app();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER(blinker, init, NULL);
|
REGISTER(blinker, init, NULL);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <pentabug/timer.h>
|
#include <pentabug/timer.h>
|
||||||
|
|
||||||
static uint8_t ir_active = 1;
|
static uint8_t ir_active = 0;
|
||||||
static int int_skip = 0;
|
static int int_skip = 0;
|
||||||
|
|
||||||
static int button_count[2];
|
static int button_count[2];
|
||||||
|
@ -85,3 +85,27 @@ void reset_hw(void) {
|
||||||
DDRD = (1 << 2) | (1 << 4);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user