From adb1df0ae200d4aa37fed5a80d5be8cab305b1b3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 23 Jan 2025 09:21:26 -0800 Subject: [PATCH] altos: Add ao_radio_post (power-on self-test) for cc1200 This function checks to make sure the radio chip is present on the SPI bus. Signed-off-by: Keith Packard --- src/drivers/ao_cc1200.c | 16 ++++++++++++++++ src/kernel/ao.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c index ed1d298e..b3a1e575 100644 --- a/src/drivers/ao_cc1200.c +++ b/src/drivers/ao_cc1200.c @@ -1456,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) { diff --git a/src/kernel/ao.h b/src/kernel/ao.h index 0437cb07..1cfe29e9 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -667,6 +667,9 @@ ao_radio_test_on(void); void ao_radio_test_off(void); +bool +ao_radio_post(void); + void ao_radio_init(void); -- 2.47.2