diff options
author | Keith Packard <keithp@keithp.com> | 2012-06-15 22:32:10 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-06-15 22:32:10 -0700 |
commit | 1b7e4c29bf9608bfc972ae28b53cc823f4c37f92 (patch) | |
tree | 90bb9bde9b1d8bd764bae9525b94234afc43d16f /src/drivers/ao_cc1120.c | |
parent | 27c95adf35e646840b9bd562497eea0dc96bb9bb (diff) |
altos: Make sure cc1120 is initialized correctly at startup time
Check to make sure it pulls down MISO when CS is enabled.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/drivers/ao_cc1120.c')
-rw-r--r-- | src/drivers/ao_cc1120.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index 5fe314c9..63f7cd89 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -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]); } |