aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2013-03-08 16:37:18 +0000
committerDimitri Sokolyuk <demon@dim13.org>2013-03-08 16:37:18 +0000
commit83de85e561f24ee330e15be8c51c68d11e60d4ba (patch)
tree7427e652c63c2e3d4788b7e3a70cba71b839c4c1
parent07915966c2c2dee5dcf335148767ff2632fe7d5e (diff)
change heartbeat pattern
-rw-r--r--kernel/heartbeat.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/kernel/heartbeat.c b/kernel/heartbeat.c
index ca0daa2..387161a 100644
--- a/kernel/heartbeat.c
+++ b/kernel/heartbeat.c
@@ -21,27 +21,24 @@
#include "kernel.h"
#include "tasks.h"
-#define PIN PB0
+#define FLASH(on, off) do { \
+ PORTB |= _BV(PB0); \
+ sleep(0, (on)); \
+ PORTB &= ~_BV(PB0); \
+ sleep(0, (off)); \
+} while (0)
void
heartbeat(void *arg)
{
- /* 80bpm: 100ms on, 50ms off, 100ms on, 500ms off */
+ DDRB |= _BV(PB0);
+ PORTB &= ~_BV(PB0);
- DDRB |= _BV(PIN);
- PORTB &= ~_BV(PIN);
+ /* 80 bpm */
for (;;) {
- PORTB |= _BV(PIN);
- sleep(0, 100000);
-
- PORTB &= ~_BV(PIN);
- sleep(0, 50000);
-
- PORTB |= _BV(PIN);
- sleep(0, 100000);
-
- PORTB &= ~_BV(PIN);
- sleep(0, 500000);
+ FLASH(100000, 100000);
+ FLASH(100000, 50000);
+ FLASH( 50000, 350000);
}
}