git.droids-corp.org
/
protos
/
xbee-avr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove mainloop callout manager (all is handled under intr)
[protos/xbee-avr.git]
/
beep.c
diff --git
a/beep.c
b/beep.c
index
f34219c
..
fadd16d
100644
(file)
--- a/
beep.c
+++ b/
beep.c
@@
-31,13
+31,12
@@
#include <aversive.h>
#include <aversive/wait.h>
#include <aversive.h>
#include <aversive/wait.h>
-#include <scheduler.h>
#include <cirbuf.h>
#include "main.h"
/* 100 ms */
#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 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 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)
{
(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);
}
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;
}
case 3: beep_mask = 8; break;
default: break;
}
-
return
;
+
goto reschedule
;
}
if (current_beep.pause > 0) {
current_beep.pause --;
}
}
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(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));
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);
}
}