mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 22:31:25 +03:00
reduce FM radio compile size if only 1 band used
This commit is contained in:
parent
c03ac606f1
commit
9a7e03ced5
@ -346,7 +346,8 @@ void ACTION_Scan(bool bRestart)
|
||||
if (g_current_function != FUNCTION_TRANSMIT)
|
||||
{
|
||||
if (g_fm_radio_mode)
|
||||
{
|
||||
{ // return normal service
|
||||
|
||||
FM_TurnOff();
|
||||
|
||||
g_input_box_index = 0;
|
||||
@ -359,6 +360,8 @@ void ACTION_Scan(bool bRestart)
|
||||
return;
|
||||
}
|
||||
|
||||
// switch to FM radio mode
|
||||
|
||||
g_monitor_enabled = false;
|
||||
|
||||
RADIO_select_vfos();
|
||||
|
10
app/app.c
10
app/app.c
@ -469,11 +469,6 @@ bool APP_start_listening(void)
|
||||
if (g_setting_backlight_on_tx_rx >= 2)
|
||||
backlight_turn_on(backlight_tx_rx_time_500ms);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_radio_mode)
|
||||
BK1080_Init(0, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
// MDC1200_reset_rx();
|
||||
#endif
|
||||
@ -558,6 +553,11 @@ bool APP_start_listening(void)
|
||||
AUDIO_set_mod_mode(g_rx_vfo->am_mode);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_radio_mode)
|
||||
BK1080_Init(0, false); // disable the FM radio audio
|
||||
#endif
|
||||
|
||||
// enable the speaker
|
||||
g_speaker_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
1
app/fm.c
1
app/fm.c
@ -706,6 +706,7 @@ void FM_Start(void)
|
||||
g_fm_scan_state = FM_SCAN_OFF;
|
||||
g_fm_restore_tick_10ms = 0;
|
||||
|
||||
// enable the FM radio chip and audio
|
||||
BK1080_Init(g_eeprom.fm_frequency_playing, true);
|
||||
|
||||
g_speaker_enabled = true;
|
||||
|
@ -104,10 +104,12 @@ uint16_t BK1080_freq_upper;
|
||||
uint16_t BK1080_BaseFrequency;
|
||||
uint16_t BK1080_FrequencyDeviation;
|
||||
|
||||
void BK1080_Init(uint16_t Frequency, bool bDoScan)
|
||||
void BK1080_Init(const uint16_t frequency, const bool initialise)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
#if defined(ENABLE_FMRADIO_64_108)
|
||||
// determine the lower and upper frequency limits
|
||||
BK1080_freq_lower = 0xffff;
|
||||
BK1080_freq_upper = 0;
|
||||
for (i = 0; i < ARRAY_SIZE(FM_RADIO_FREQ_BAND_TABLE); i++)
|
||||
@ -125,9 +127,14 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
|
||||
if (BK1080_freq_upper < upper)
|
||||
BK1080_freq_upper = upper;
|
||||
}
|
||||
#else
|
||||
BK1080_freq_lower = FM_RADIO_FREQ_BAND_TABLE[0].lower;
|
||||
BK1080_freq_upper = FM_RADIO_FREQ_BAND_TABLE[0].upper;
|
||||
#endif
|
||||
|
||||
if (initialise)
|
||||
{ // init and enable the chip
|
||||
|
||||
if (bDoScan)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
||||
|
||||
if (!is_init)
|
||||
@ -149,10 +156,11 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
|
||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, (1u << 9) | (1u << 0));
|
||||
}
|
||||
|
||||
BK1080_SetFrequency(Frequency);
|
||||
BK1080_SetFrequency(frequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
{ // disable the chip
|
||||
|
||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, (1u << 9) | (1u << 6) | (1u << 0)); // 0x0241); // 0000 0010 0100 0001
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
||||
}
|
||||
@ -181,29 +189,31 @@ void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value)
|
||||
|
||||
void BK1080_Mute(bool Mute)
|
||||
{
|
||||
uint16_t val = (1u << 9) | (1u << 0);
|
||||
if (Mute)
|
||||
val |= 1u << 14;
|
||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, val);
|
||||
|
||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, (1u << 9) | (1u << 0) | (Mute ? 1u << 14 : 0u));
|
||||
}
|
||||
|
||||
void BK1080_SetFrequency(uint16_t Frequency)
|
||||
{
|
||||
uint16_t band;
|
||||
uint16_t channel;
|
||||
uint16_t band = 0;
|
||||
|
||||
// #if (ARRAY_SIZE(FM_RADIO_FREQ_BAND_TABLE) > 1) // compiler doesn't like this :(
|
||||
#if defined(ENABLE_FMRADIO_64_108)
|
||||
// determine which band to use
|
||||
for (band = 0; band < ARRAY_SIZE(FM_RADIO_FREQ_BAND_TABLE); band++)
|
||||
if (Frequency >= FM_RADIO_FREQ_BAND_TABLE[band].lower && Frequency < FM_RADIO_FREQ_BAND_TABLE[band].upper)
|
||||
break;
|
||||
|
||||
if (band >= ARRAY_SIZE(FM_RADIO_FREQ_BAND_TABLE))
|
||||
return;
|
||||
|
||||
channel = Frequency - FM_RADIO_FREQ_BAND_TABLE[band].lower; // 100kHz channel spacing
|
||||
{
|
||||
Frequency = BK1080_freq_lower;
|
||||
// return;
|
||||
}
|
||||
|
||||
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, (SEEK_THRESHOLD << 8) | (band << 6) | (CHAN_SPACING << 4) | (VOLUME << 0));
|
||||
#endif
|
||||
|
||||
channel = Frequency - FM_RADIO_FREQ_BAND_TABLE[band].lower; // 100kHz channel spacing
|
||||
|
||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel);
|
||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel | (1u << 15));
|
||||
|
@ -27,7 +27,7 @@ extern uint16_t BK1080_freq_upper;
|
||||
extern uint16_t BK1080_BaseFrequency;
|
||||
extern uint16_t BK1080_FrequencyDeviation;
|
||||
|
||||
void BK1080_Init(uint16_t Frequency, bool bDoScan);
|
||||
void BK1080_Init(const uint16_t frequency, const bool initialise);
|
||||
uint16_t BK1080_ReadRegister(BK1080_Register_t Register);
|
||||
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
|
||||
void BK1080_Mute(bool Mute);
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user