#include <aversive.h>
#include <aversive/wait.h>
-#include <scheduler.h>
#include <cirbuf.h>
#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];
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);
}
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)
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);
}