From cdfa9303a024300141e8b328f81404a9b7466207 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 19 Sep 2021 14:48:50 -0700 Subject: [PATCH] altos: Detect CC120X device type Not that it has any effect on the driver, but maybe it should? Signed-off-by: Keith Packard --- src/drivers/ao_cc1200.c | 13 ++++++++++--- src/drivers/ao_cc1200.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c index 3ccf121f..6afa2a21 100644 --- a/src/drivers/ao_cc1200.c +++ b/src/drivers/ao_cc1200.c @@ -25,6 +25,8 @@ #include #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]; diff --git a/src/drivers/ao_cc1200.h b/src/drivers/ao_cc1200.h index 8e17bbd9..6ab04ecd 100644 --- a/src/drivers/ao_cc1200.h +++ b/src/drivers/ao_cc1200.h @@ -591,6 +591,8 @@ #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) -- 2.30.2