feat: enhance error handling and add device error reporting for radio operations

This commit is contained in:
2025-08-07 15:36:20 +08:00
parent 72299b62ce
commit 7637906efe
6 changed files with 101 additions and 47 deletions

View File

@ -32,17 +32,18 @@ constexpr t GENERIC_ERR_BASE = 0x120;
constexpr t AGAIN = GENERIC_ERR_BASE + 1; /*!< Operation failed, retry */
constexpr t BUSY = GENERIC_ERR_BASE + 2; /*!< Busy */
constexpr t SPI_ERR_BASE = 0x1'2000;
constexpr t RADIO_TRANS_ERR_BASE = 0x1'2000;
// A transaction from host took too long to complete and triggered an internal watchdog.
// The watchdog mechanism can be disabled by host; it is meant to ensure all outcomes are flagged to the host MCU.
constexpr t SPI_TIMEOUT = SPI_ERR_BASE + 2;
constexpr t RADIO_TRANS_TIMEOUT = RADIO_TRANS_ERR_BASE + 2;
// Processor was unable to process command either because of an invalid opcode or
// because an incorrect number of parameters has been provided.
constexpr t SPI_CMD_INVALID = SPI_ERR_BASE + 3;
constexpr t RADIO_TRANS_CMD_PROC_ERR = RADIO_TRANS_ERR_BASE + 3;
// The command was successfully processed, however the chip could not execute the command;
// for instance it was unable to enter the specified device mode or send the requested data
constexpr t SPI_CMD_FAILED = SPI_ERR_BASE + 4;
constexpr t SPI_INVALID_RADIO_STATE = SPI_ERR_BASE + 5; /*!< Radio is in an invalid state for the requested operation */
constexpr t RADIO_TRANS_FAIL_TO_EXE = RADIO_TRANS_ERR_BASE + 4;
/*!< Radio is in an expected state (not necessary an error) */
constexpr t RADIO_TRANS_INVALID_RADIO_STATE = RADIO_TRANS_ERR_BASE + 5;
constexpr t RADIO_ERR_BASE = 0x1'3000;
constexpr t RADIO_CHIP_NOT_FOUND = RADIO_ERR_BASE + 1;
@ -75,10 +76,10 @@ constexpr auto error_table = std::to_array<std::tuple<t, const char *>>(
APP_ERR_TBL_IT(AGAIN),
APP_ERR_TBL_IT(BUSY),
APP_ERR_TBL_IT(SPI_TIMEOUT),
APP_ERR_TBL_IT(SPI_CMD_INVALID),
APP_ERR_TBL_IT(SPI_CMD_FAILED),
APP_ERR_TBL_IT(SPI_INVALID_RADIO_STATE),
APP_ERR_TBL_IT(RADIO_TRANS_TIMEOUT),
APP_ERR_TBL_IT(RADIO_TRANS_CMD_PROC_ERR),
APP_ERR_TBL_IT(RADIO_TRANS_FAIL_TO_EXE),
APP_ERR_TBL_IT(RADIO_TRANS_INVALID_RADIO_STATE),
APP_ERR_TBL_IT(RADIO_CHIP_NOT_FOUND),
APP_ERR_TBL_IT(RADIO_INVALID_TCXO_VOLTAGE),