From: Olivier Matz Date: Mon, 10 Mar 2014 19:04:44 +0000 (+0100) Subject: use static variables for callout instead of using xbeeboard struct X-Git-Url: http://git.droids-corp.org/?p=protos%2Fxbee-avr.git;a=commitdiff_plain;h=6c945eadabc434b12d6b14c3edb1944bcd0707b0 use static variables for callout instead of using xbeeboard struct --- diff --git a/beep.c b/beep.c index fadd16d..1a31186 100644 --- 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 ba0836e..d64039b 100644 --- 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]; diff --git a/spi_servo.c b/spi_servo.c index 4d4553b..7a85070 100644 --- a/spi_servo.c +++ b/spi_servo.c @@ -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); } diff --git a/xbee_user.c b/xbee_user.c index a4cb84f..859d203 100644 --- a/xbee_user.c +++ b/xbee_user.c @@ -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); }