X-Git-Url: http://git.droids-corp.org/?p=protos%2Fxbee-avr.git;a=blobdiff_plain;f=beep.c;h=fadd16d805101a9cbea1b1cbc5b4877c39d7f50e;hp=f34219c020527015b87307c7ab29cf6687b67059;hb=a53014b7f52462e163a7d7ac64866aa75977422f;hpb=8a9ba904e4215b92930a6d71c06c97514bcc6688 diff --git a/beep.c b/beep.c index f34219c..fadd16d 100644 --- a/beep.c +++ b/beep.c @@ -31,13 +31,12 @@ #include #include -#include #include #include "main.h" /* 100 ms */ -#define BEEP_PERIOD (100000UL/SCHEDULER_UNIT) +#define BEEP_PERIOD_MS 100 static struct cirbuf beep_fifo; static char beep_fifo_buf[16]; @@ -54,14 +53,15 @@ union beep_t { static volatile union beep_t current_beep; /* called by the scheduler */ -static void beep_cb(void *arg) +static void beep_cb(struct callout_mgr *cm, struct callout *tim, void *arg) { (void)arg; beep_mask = 0; if (current_beep.len == 0 && current_beep.pause == 0) { if (CIRBUF_GET_LEN(&beep_fifo) == 0) - return; + goto reschedule; + current_beep.u08 = cirbuf_get_head(&beep_fifo); cirbuf_del_head(&beep_fifo); } @@ -75,12 +75,15 @@ static void beep_cb(void *arg) case 3: beep_mask = 8; break; default: break; } - return; + goto reschedule; } if (current_beep.pause > 0) { current_beep.pause --; } + + reschedule: + callout_reschedule(cm, tim, BEEP_PERIOD_MS); } void beep(uint8_t tone, uint8_t len, uint8_t pause) @@ -99,6 +102,7 @@ void beep(uint8_t tone, uint8_t len, uint8_t pause) void beep_init(void) { cirbuf_init(&beep_fifo, beep_fifo_buf, 0, sizeof(beep_fifo_buf)); - scheduler_add_periodical_event_priority(&beep_cb, NULL, - BEEP_PERIOD, BEEP_PRIO); + callout_init(&xbeeboard.beep_timer, beep_cb, NULL, BEEP_PRIO); + callout_schedule(&xbeeboard.intr_cm, &xbeeboard.beep_timer, + BEEP_PERIOD_MS); }