From 0ce7d7bdc3bf9768a1f3967ab991eca1e70ff499 Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Wed, 22 Nov 2023 20:41:38 +0100 Subject: [PATCH] FIX #129: Bug in radio initialization after reset. --- board.c | 7 +++++++ radio.c | 15 +++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/board.c b/board.c index d585e6f..1440a6d 100644 --- a/board.c +++ b/board.c @@ -727,6 +727,13 @@ void BOARD_EEPROM_Init(void) // 0D60..0E27 EEPROM_ReadBuffer(0x0D60, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes)); + for(uint16_t i = 0; i < sizeof(gMR_ChannelAttributes); i++) { + ChannelAttributes_t *att = &gMR_ChannelAttributes[i]; + if(att->__val == 0xff){ + att->__val = 0; + att->band = 0xf; + } + } // 0F30..0F3F EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey)); diff --git a/radio.c b/radio.c index c70655e..9991fd9 100644 --- a/radio.c +++ b/radio.c @@ -141,7 +141,9 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) pInfo->Modulation = MODULATION_AM; - + else + pInfo->Modulation = MODULATION_FM; + RADIO_ConfigureSquelchAndOutputPower(pInfo); } @@ -243,7 +245,10 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure if (tmp > TX_OFFSET_FREQUENCY_DIRECTION_SUB) tmp = 0; pVfo->TX_OFFSET_FREQUENCY_DIRECTION = tmp; - pVfo->Modulation = (data[3] >> 4); + tmp = data[3] >> 4; + if (tmp >= MODULATION_UKNOWN) + tmp = MODULATION_FM; + pVfo->Modulation = tmp; tmp = data[6]; if (tmp >= ARRAY_SIZE(gStepFrequencyTable)) @@ -337,8 +342,10 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure uint32_t Offset; } __attribute__((packed)) info; EEPROM_ReadBuffer(base, &info, sizeof(info)); - - pVfo->freq_config_RX.Frequency = info.Frequency; + if(info.Frequency==0xFFFFFFFF) + pVfo->freq_config_RX.Frequency = frequencyBandTable[band].lower; + else + pVfo->freq_config_RX.Frequency = info.Frequency; if (info.Offset >= 100000000) info.Offset = 1000000;