altos: Make sure cc1120 is initialized correctly at startup time
authorKeith Packard <keithp@keithp.com>
Sat, 16 Jun 2012 05:32:10 +0000 (22:32 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 16 Jun 2012 05:32:10 +0000 (22:32 -0700)
Check to make sure it pulls down MISO when CS is enabled.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_cc1120.c

index 5fe314c96130bfa02052134f9e69d89fa764c1eb..63f7cd890ec4c5a0d34d785c9d1485ee48105f05 100644 (file)
@@ -733,8 +733,18 @@ static const struct ao_cmds ao_radio_cmds[] = {
 void
 ao_radio_init(void)
 {
+       int     i;
+
        ao_radio_configured = 0;
        ao_spi_init_cs (AO_CC1120_SPI_CS_PORT, (1 << AO_CC1120_SPI_CS_PIN));
 
+       AO_CC1120_SPI_CS_PORT.bsrr = ((uint32_t) (1 << AO_CC1120_SPI_CS_PIN));
+       for (i = 0; i < 10000; i++) {
+               if ((SPI_2_GPIO.idr & (1 << SPI_2_MISO)) == 0)
+                       break;
+       }
+       AO_CC1120_SPI_CS_PORT.bsrr = (1 << AO_CC1120_SPI_CS_PIN);
+       if (i == 10000)
+               ao_panic(AO_PANIC_SELF_TEST);
        ao_cmd_register(&ao_radio_cmds[0]);
 }