]> git.droids-corp.org - protos/xbee-avr.git/commitdiff
use static variables for callout instead of using xbeeboard struct
authorOlivier Matz <zer0@droids-corp.org>
Mon, 10 Mar 2014 19:04:44 +0000 (20:04 +0100)
committerOlivier Matz <zer0@droids-corp.org>
Mon, 10 Mar 2014 19:04:53 +0000 (20:04 +0100)
beep.c
main.h
spi_servo.c
xbee_user.c

diff --git a/beep.c b/beep.c
index fadd16d805101a9cbea1b1cbc5b4877c39d7f50e..1a31186da2a2e4ed573f865d37a8edc804bf5a7c 100644 (file)
--- a/beep.c
+++ b/beep.c
@@ -42,6 +42,8 @@ static struct cirbuf beep_fifo;
 static char beep_fifo_buf[16];
 volatile uint8_t beep_mask = 1; /* init beep */
 
+static struct callout beep_timer;
+
 union beep_t {
        uint8_t u08;
        struct {
@@ -102,7 +104,6 @@ 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));
-       callout_init(&xbeeboard.beep_timer, beep_cb, NULL, BEEP_PRIO);
-       callout_schedule(&xbeeboard.intr_cm, &xbeeboard.beep_timer,
-               BEEP_PERIOD_MS);
+       callout_init(&beep_timer, beep_cb, NULL, BEEP_PRIO);
+       callout_schedule(&xbeeboard.intr_cm, &beep_timer, BEEP_PERIOD_MS);
 }
diff --git a/main.h b/main.h
index ba0836e13998da3cc695e62444f9575a835744df..d64039b72663064b07d87b8e4735be7c4e454e8f 100644 (file)
--- a/main.h
+++ b/main.h
@@ -76,9 +76,6 @@ struct xbeeboard {
        char prompt[RDLINE_PROMPT_SIZE];
 
        struct callout_mgr intr_cm;
-       struct callout spi_timer;
-       struct callout beep_timer;
-       struct callout xbee_rx_poll_timer;
 
        /* log */
        uint8_t logs[NB_LOGS+1];
index 4d4553b5bca6d37a0ea1a1b0def46390827a5148..7a85070a762bdcd84c9667d3597c044aa056f3b6 100644 (file)
@@ -41,6 +41,8 @@ struct spi_servo_rx {
 };
 static struct spi_servo_rx spi_servo_rx;
 
+static struct callout spi_timer;
+
 /*
  * SPI protocol:
  *
@@ -187,9 +189,8 @@ void spi_servo_init(void)
 
        SS_HIGH();
 
-       callout_init(&xbeeboard.spi_timer, spi_servo_cb, NULL, SPI_PRIO);
-       callout_schedule(&xbeeboard.intr_cm,
-               &xbeeboard.spi_timer, 0); /* immediate */
+       callout_init(&spi_timer, spi_servo_cb, NULL, SPI_PRIO);
+       callout_schedule(&xbeeboard.intr_cm, &spi_timer, 0); /* immediate */
        spi_servo_set_bypass(1);
 }
 
index a4cb84f54499d859567f758b681c492f58f39892..859d203526109593a78ec6660fffcee4b95d717d 100644 (file)
@@ -56,6 +56,8 @@ int xbee_cmdline_input_enabled = 1;
 /* parameters */
 int xbee_raw = 0;
 
+static struct callout xbee_rx_poll_timer;
+
 static void __hexdump(const void *buf, unsigned int len)
 {
        unsigned int i, out, ofs;
@@ -544,8 +546,8 @@ void xbee_stdin_disable(void)
 
 void xbeeapp_init(void)
 {
-       callout_init(&xbeeboard.xbee_rx_poll_timer, xbee_rx_poll_timer_cb,
+       callout_init(&xbee_rx_poll_timer, xbee_rx_poll_timer_cb,
                NULL, XBEE_PRIO);
-       callout_schedule(&xbeeboard.intr_cm,
-               &xbeeboard.xbee_rx_poll_timer, XBEE_POLL_TIMER_MS);
+       callout_schedule(&xbeeboard.intr_cm, &xbee_rx_poll_timer,
+               XBEE_POLL_TIMER_MS);
 }