root / toolbox / led.h @ 5e03b78d
History | View | Annotate | Download (688 Bytes)
1 |
#ifndef LED_H
|
---|---|
2 |
#define LED_H
|
3 |
|
4 |
#include <avr/io.h> |
5 |
|
6 |
enum color_t {
|
7 |
OFF, RED, YELLOW, GREEN |
8 |
}; |
9 |
|
10 |
static inline void led_init() {DDRC |= _BV(DDC1) | _BV(DDC0);} |
11 |
static inline void led_off() {PORTC &= ~(_BV(PC1) | _BV(PC0));} |
12 |
static inline void led_red() {PORTC = (PORTC & ~_BV(PC0)) | _BV(PC1);} |
13 |
static inline void led_yellow() {PORTC |= _BV(PC1) | _BV(PC0);} |
14 |
static inline void led_green() {PORTC = (PORTC & ~_BV(PC1)) | _BV(PC0);} |
15 |
|
16 |
/* Starts LED blinking */
|
17 |
void led_blink_start(unsigned int period_ms, char n_times, enum color_t color); |
18 |
|
19 |
/* Returns nonzero if blinking has finished */
|
20 |
char led_blink_done();
|
21 |
|
22 |
/* Call this every TICK_MS to handle LED blinking */
|
23 |
void led_tick();
|
24 |
|
25 |
#endif
|