]> git.gag.com Git - fw/altos/blobdiff - src/drivers/ao_cc1200.c
doc: Add 1.9.22 release notes
[fw/altos] / src / drivers / ao_cc1200.c
index 727097441007fee784b2e570fd57d7d315ec7466..b3a1e57551556054a5f9a6cd31a98f6ab36c0484 100644 (file)
@@ -53,7 +53,7 @@ extern const uint32_t ao_radio_cal;
 #define FOSC   40000000
 #endif
 
-#define AO_CC1200_SPI_SPEED    ao_spi_speed(7700000)   /* 7.7MHz max for extended memory reads */
+#define AO_CC1200_SPI_SPEED    ao_spi_speed(AO_CC1200_SPI_BUS, 7700000)        /* 7.7MHz max for extended memory reads */
 
 #define ao_radio_select()      ao_spi_get_mask(AO_CC1200_SPI_CS_PORT,(1 << AO_CC1200_SPI_CS_PIN),AO_CC1200_SPI_BUS,AO_CC1200_SPI_SPEED)
 #define ao_radio_deselect()    ao_spi_put_mask(AO_CC1200_SPI_CS_PORT,(1 << AO_CC1200_SPI_CS_PIN),AO_CC1200_SPI_BUS)
@@ -65,7 +65,7 @@ extern const uint32_t ao_radio_cal;
 static uint8_t
 ao_radio_reg_read(uint16_t addr)
 {
-       uint8_t data[2];
+       uint8_t data[3];
        uint8_t d;
 
 #if CC1200_TRACE
@@ -84,13 +84,12 @@ ao_radio_reg_read(uint16_t addr)
                d = 1;
        }
        ao_radio_select();
-       ao_radio_spi_send(data, d);
-       ao_radio_spi_recv(data, 1);
+       ao_radio_duplex(data, data, d + 1);
        ao_radio_deselect();
 #if CC1200_TRACE
-       printf (" %02x\n", data[0]);
+       printf (" %02x\n", data[d]);
 #endif
-       return data[0];
+       return data[d];
 }
 
 static void
@@ -204,7 +203,6 @@ ao_radio_status(void)
 void
 ao_radio_recv_abort(void)
 {
-       ao_exti_disable(AO_CC1200_INT_PORT, AO_CC1200_INT_PIN);
        ao_radio_abort = 1;
        ao_wakeup(&ao_radio_wake);
 }
@@ -1458,6 +1456,22 @@ static const struct ao_cmds ao_radio_cmds[] = {
        { 0, NULL }
 };
 
+/* Make sure the radio is alive */
+bool
+ao_radio_post(void)
+{
+       uint8_t partnum;
+
+       partnum = ao_radio_reg_read(CC1200_PARTNUMBER);
+       switch (partnum) {
+       case CC1200_PARTNUMBER_CC1200:
+       case CC1200_PARTNUMBER_CC1201:
+               return true;
+       default:
+               return false;
+       }
+}
+
 void
 ao_radio_init(void)
 {