From 4c035bbf161162b0a79751d6c53706e9743a4906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Mon, 21 Aug 2023 12:01:27 +0200 Subject: [PATCH] ttwrplus: enable Tx capability Enabled Tx capability on T-TWR Plus. Since Tx requires the SA8x8 to disable the Rx stage, we check that at least firmware v.1.1.0.r14 is present on the baseband, otherwise we don't initialize the radio. TG-553 --- platform/drivers/baseband/radio_ttwrplus.cpp | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/platform/drivers/baseband/radio_ttwrplus.cpp b/platform/drivers/baseband/radio_ttwrplus.cpp index 3b77a808..01c0da74 100644 --- a/platform/drivers/baseband/radio_ttwrplus.cpp +++ b/platform/drivers/baseband/radio_ttwrplus.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "AT1846S.h" #include "radioUtils.h" @@ -120,6 +121,14 @@ char *radio_getFwVersion() return tx_buf; } +char *radio_getModel() +{ + char *tx_buf = (char *) malloc(sizeof(char) * SA8X8_MSG_SIZE); + radio_uartPrint("AT+MODEL\r\n"); + k_msgq_get(&uart_msgq, tx_buf, K_FOREVER); + return tx_buf; +} + void radio_init(const rtxStatus_t *rtxState) { config = rtxState; @@ -164,8 +173,19 @@ void radio_init(const rtxStatus_t *rtxState) return; } - // Add SA8x8 FW version to Info menu - ui_registerInfoExtraEntry("Radio", radio_getFwVersion); + // A small delay is needed to have SA8x8 ready to serve commands + delayMs(100); + + // Check for minimum supported firmware version. + char *fwVersionStr = radio_getFwVersion(); + uint8_t major = 0, minor = 0, patch = 0, release = 0; + sscanf(fwVersionStr, "sa8x8-fw/v%hhu.%hhu.%hhu.r%hhu", &major, &minor, &patch, &release); + if (major < 1 || (major == 1 && minor < 1) || (major == 1 && minor == 1 && patch == 0 && release < 14)) + { + printk("Error: unsupported baseband firmware, please update!\n"); + return; + } + free(fwVersionStr); // TODO: Implement audio paths configuration @@ -251,8 +271,6 @@ void radio_enableRx() void radio_enableTx() { - // TODO; Do not enable Tx until proven to be safe - return; if(config->txDisable == 1) return; at1846s.setFrequency(config->txFrequency);