Project

General

Profile

Statistics
| Branch: | Revision:

root / toolbox / led.h @ 94548bf4

History | View | Annotate | Download (688 Bytes)

1 532ba0bd Tom Mullins
#ifndef LED_H
2
#define LED_H
3
4
#include <avr/io.h>
5
6 1085ef77 Tom Mullins
enum color_t {
7
  OFF, RED, YELLOW, GREEN
8
};
9
10 532ba0bd Tom Mullins
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 dc472500 Tom Mullins
/* Starts LED blinking */ 
17 1085ef77 Tom Mullins
void led_blink_start(unsigned int period_ms, char n_times, enum color_t color);
18 dc472500 Tom Mullins
19
/* Returns nonzero if blinking has finished */
20
char led_blink_done();
21
22 94548bf4 Tom Mullins
/* Call this every TICK_MS to handle LED blinking */
23
void led_tick();
24
25 532ba0bd Tom Mullins
#endif