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 fadd16d..1a31186 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 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 {
 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));
 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 ba0836e..d64039b 100644 (file)
--- a/main.h
+++ b/main.h
@@ -76,9 +76,6 @@ struct xbeeboard {
        char prompt[RDLINE_PROMPT_SIZE];
 
        struct callout_mgr intr_cm;
        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];
 
        /* log */
        uint8_t logs[NB_LOGS+1];
index 4d4553b..7a85070 100644 (file)
@@ -41,6 +41,8 @@ struct spi_servo_rx {
 };
 static struct spi_servo_rx spi_servo_rx;
 
 };
 static struct spi_servo_rx spi_servo_rx;
 
+static struct callout spi_timer;
+
 /*
  * SPI protocol:
  *
 /*
  * SPI protocol:
  *
@@ -187,9 +189,8 @@ void spi_servo_init(void)
 
        SS_HIGH();
 
 
        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);
 }
 
        spi_servo_set_bypass(1);
 }
 
index a4cb84f..859d203 100644 (file)
@@ -56,6 +56,8 @@ int xbee_cmdline_input_enabled = 1;
 /* parameters */
 int xbee_raw = 0;
 
 /* 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;
 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)
 {
 
 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);
                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);
 }
 }