altos: Detect CC120X device type
authorKeith Packard <keithp@keithp.com>
Sun, 19 Sep 2021 21:48:50 +0000 (14:48 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 19 Sep 2021 21:48:50 +0000 (14:48 -0700)
Not that it has any effect on the driver, but maybe it should?

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

index 3ccf121f1a1f3301f0b2e720d2308e78febb5be9..6afa2a2112e9d0c73c0936d7b67f4b5eb8276651 100644 (file)
@@ -25,6 +25,8 @@
 #include <ao_pad.h>
 #endif
 
+static uint8_t cc1201;
+
 static uint8_t ao_radio_mutex;
 
 static uint8_t ao_radio_wake;          /* radio ready. Also used as sleep address */
@@ -663,6 +665,11 @@ static uint8_t     ao_radio_configured = 0;
 static void
 ao_radio_setup(void)
 {
+       uint8_t partnumber = ao_radio_reg_read(CC1200_PARTNUMBER);
+
+       if (partnumber == CC1200_PARTNUMBER_CC1201)
+               cc1201 = 1;
+
        ao_radio_strobe(CC1200_SRES);
 
        ao_radio_set_regs(radio_setup);
@@ -719,8 +726,8 @@ ao_radio_state(void)
        return (ao_radio_status() >> CC1200_STATUS_STATE) & CC1200_STATUS_STATE_MASK;
 }
 
-#if CC1200_DEBUG
-void
+#if CC1200_DEBUG_
+static void
 ao_radio_show_state(char *where)
 {
        printf("%s: state %d len %d rxbytes %d\n",
@@ -1320,7 +1327,7 @@ static void ao_radio_packet(void) {
        ao_radio_send(packet, sizeof (packet));
 }
 
-void
+static void
 ao_radio_test_recv(void)
 {
        static uint8_t  bytes[34];
index 8e17bbd9fb0837b31ac7310ead20c201c0ddecd3..6ab04ecdf87663af8c52b236172bfb01ef71d0d5 100644 (file)
 #define CC1200_FSCAL_CTRL      (CC1200_EXTENDED_BIT | 0x8d)
 #define CC1200_PHASE_ADJUST    (CC1200_EXTENDED_BIT | 0x8e)
 #define CC1200_PARTNUMBER      (CC1200_EXTENDED_BIT | 0x8f)
+#define  CC1200_PARTNUMBER_CC1200      0x20
+#define  CC1200_PARTNUMBER_CC1201      0x21
 #define CC1200_PARTVERSION     (CC1200_EXTENDED_BIT | 0x90)
 #define CC1200_SERIAL_STATUS   (CC1200_EXTENDED_BIT | 0x91)
 #define CC1200_MODEM_STATUS1   (CC1200_EXTENDED_BIT | 0x92)