@@ -166,13 +166,28 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Configure)
166166 }
167167#endif
168168 if (IS_MR_CHANNEL (Channel )) {
169- Channel = RADIO_FindNextChannel (Channel , RADIO_CHANNEL_UP , false, VFO );
170- if (Channel == 0xFF ) {
171- Channel = gEeprom .FreqChannel [VFO ];
172- gEeprom .ScreenChannel [VFO ] = gEeprom .FreqChannel [VFO ];
169+ uint8_t NextChannel = RADIO_FindNextChannel (Channel , RADIO_CHANNEL_UP , false, VFO );
170+
171+ if (NextChannel == 0xFF ) {
172+ if (gEeprom .VFO_OPEN ) {
173+ Channel = gEeprom .FreqChannel [VFO ];
174+ gEeprom .ScreenChannel [VFO ] = Channel ;
175+ } else {
176+ NextChannel = gEeprom .MrChannel [VFO ];
177+ if (!IS_MR_CHANNEL (NextChannel ) || gMR_ChannelAttributes [NextChannel ] == 0xFF ) {
178+ NextChannel = RADIO_FindNextChannel (MR_CHANNEL_FIRST , RADIO_CHANNEL_UP , false, VFO );
179+ if (NextChannel == 0xFF ) {
180+ NextChannel = MR_CHANNEL_FIRST ;
181+ }
182+ }
183+ gEeprom .MrChannel [VFO ] = NextChannel ;
184+ gEeprom .ScreenChannel [VFO ] = NextChannel ;
185+ Channel = NextChannel ;
186+ }
173187 } else {
174- gEeprom .ScreenChannel [VFO ] = Channel ;
175- gEeprom .MrChannel [VFO ] = Channel ;
188+ gEeprom .ScreenChannel [VFO ] = NextChannel ;
189+ gEeprom .MrChannel [VFO ] = NextChannel ;
190+ Channel = NextChannel ;
176191 }
177192 }
178193 } else {
@@ -181,15 +196,25 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Configure)
181196
182197 Attributes = gMR_ChannelAttributes [Channel ];
183198 if (Attributes == 0xFF ) {
184- uint8_t Index ;
185-
186199 if (IS_MR_CHANNEL (Channel )) {
187- Channel = gEeprom .FreqChannel [VFO ];
188- gEeprom .ScreenChannel [VFO ] = gEeprom .FreqChannel [VFO ];
200+ uint8_t Fallback = RADIO_FindNextChannel (MR_CHANNEL_FIRST , RADIO_CHANNEL_UP , false, VFO );
201+
202+ if (Fallback != 0xFF && gMR_ChannelAttributes [Fallback ] != 0xFF ) {
203+ Channel = Fallback ;
204+ gEeprom .ScreenChannel [VFO ] = Fallback ;
205+ gEeprom .MrChannel [VFO ] = Fallback ;
206+ Attributes = gMR_ChannelAttributes [Channel ];
207+ } else {
208+ Channel = gEeprom .FreqChannel [VFO ];
209+ gEeprom .ScreenChannel [VFO ] = Channel ;
210+ }
211+ }
212+ if (Attributes == 0xFF ) {
213+ uint8_t Index = Channel - FREQ_CHANNEL_FIRST ;
214+
215+ RADIO_InitInfo (pRadio , Channel , Index , gLowerLimitFrequencyBandTable [Index ]);
216+ return ;
189217 }
190- Index = Channel - FREQ_CHANNEL_FIRST ;
191- RADIO_InitInfo (pRadio , Channel , Index , gLowerLimitFrequencyBandTable [Index ]);
192- return ;
193218 }
194219
195220 Band = Attributes & MR_CH_BAND_MASK ;
@@ -853,4 +878,3 @@ void RADIO_SendEndOfTransmission(void)
853878 }
854879 BK4819_ExitDTMF_TX (true);
855880}
856-
0 commit comments