mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-27 22:01:26 +03:00
updated MDC1200
This commit is contained in:
parent
25fee556c6
commit
2e0b431fd4
10
Makefile
10
Makefile
@ -12,16 +12,16 @@ ENABLE_OVERLAY := 0
|
||||
ENABLE_LTO := 1
|
||||
# UART Programming 2.9 kB
|
||||
ENABLE_UART := 1
|
||||
ENABLE_UART_DEBUG := 0
|
||||
ENABLE_UART_DEBUG := 1
|
||||
# AirCopy 2.5 kB
|
||||
ENABLE_AIRCOPY := 0
|
||||
ENABLE_AIRCOPY := 1
|
||||
ENABLE_AIRCOPY_REMEMBER_FREQ := 1
|
||||
ENABLE_AIRCOPY_RX_REBOOT := 0
|
||||
# FM Radio 4.2 kB
|
||||
ENABLE_FMRADIO_76_90 := 0
|
||||
ENABLE_FMRADIO_68_108 := 0
|
||||
ENABLE_FMRADIO_76_108 := 0
|
||||
ENABLE_FMRADIO_875_108 := 1
|
||||
ENABLE_FMRADIO_875_108 := 0
|
||||
# NOAA 1.2 kB
|
||||
ENABLE_NOAA := 0
|
||||
# Voice 1.7 kB
|
||||
@ -33,7 +33,7 @@ ENABLE_REDUCE_LOW_MID_TX_POWER := 1
|
||||
# Tx Alarm 0.6 kB
|
||||
ENABLE_ALARM := 0
|
||||
ENABLE_TX1750 := 0
|
||||
# MDC1200 0.892 kB
|
||||
# MDC1200 2.8 kB
|
||||
ENABLE_MDC1200 := 1
|
||||
ENABLE_PWRON_PASSWORD := 0
|
||||
ENABLE_RESET_AES_KEY := 1
|
||||
@ -66,7 +66,7 @@ ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS := 1
|
||||
ENABLE_FASTER_CHANNEL_SCAN := 1
|
||||
ENABLE_COPY_CHAN_TO_VFO_TO_CHAN := 1
|
||||
# Rx Signal Bar 0.4 kB
|
||||
ENABLE_RX_SIGNAL_BAR := 1
|
||||
ENABLE_RX_SIGNAL_BAR := 0
|
||||
# Tx Timeout Bar 0.2 kB
|
||||
ENABLE_TX_TIMEOUT_BAR := 0
|
||||
# Tx Audio Bar 0.3 kB
|
||||
|
3
am_fix.c
3
am_fix.c
@ -449,6 +449,9 @@
|
||||
|
||||
void AM_fix_print_data(const int vfo, char *s)
|
||||
{
|
||||
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
|
||||
return;
|
||||
|
||||
if (s != NULL && vfo >= 0 && vfo < (int)ARRAY_SIZE(gain_table_index))
|
||||
{
|
||||
const unsigned int index = gain_table_index[vfo];
|
||||
|
@ -407,14 +407,16 @@ void AIRCOPY_process_fsk_rx_10ms(void)
|
||||
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
|
||||
|
||||
// fetch RX'ed data
|
||||
for (i = 0; i < 4; i++)
|
||||
{ // fetch RX'ed data
|
||||
const unsigned int count = BK4819_ReadRegister(0x5E) & (7u << 0); // almost full threshold
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
const uint16_t word = BK4819_ReadRegister(0x5F);
|
||||
|
||||
if (g_fsk_write_index < ARRAY_SIZE(g_fsk_buffer))
|
||||
g_fsk_buffer[g_fsk_write_index++] = word;
|
||||
}
|
||||
}
|
||||
|
||||
// REG_0B read only
|
||||
//
|
||||
|
152
app/app.c
152
app/app.c
@ -152,10 +152,19 @@ static void APP_check_for_new_receive(void)
|
||||
g_rx_reception_mode = RX_MODE_DETECTED;
|
||||
|
||||
done:
|
||||
if (g_current_function != FUNCTION_NEW_RECEIVE)
|
||||
// if (g_current_function != FUNCTION_NEW_RECEIVE)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_NEW_RECEIVE);
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
{ // reset the FSK receiver
|
||||
//const uint16_t fsk_reg59 = BK4819_ReadRegister(0x59) & ~((1u << 15) | (1u << 14) | (1u << 12) | (1u << 11));
|
||||
// BK4819_enable_mdc1200_rx(true);
|
||||
//BK4819_WriteRegister(0x59, (1u << 15) | (1u << 14) | fsk_reg59);
|
||||
//BK4819_WriteRegister(0x59, (1u << 12) | fsk_reg59);
|
||||
}
|
||||
#endif
|
||||
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
g_update_rssi = true;
|
||||
}
|
||||
@ -672,7 +681,7 @@ void APP_stop_scan(void)
|
||||
|
||||
g_rx_vfo->freq_config_rx.frequency = g_scan_restore_frequency;
|
||||
|
||||
RADIO_ApplyOffset(g_rx_vfo);
|
||||
RADIO_ApplyOffset(g_rx_vfo, false);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
RADIO_setup_registers(true);
|
||||
}
|
||||
@ -684,7 +693,7 @@ void APP_stop_scan(void)
|
||||
|
||||
if (g_rx_vfo->channel_save > USER_CHANNEL_LAST)
|
||||
{ // frequency mode
|
||||
RADIO_ApplyOffset(g_rx_vfo);
|
||||
RADIO_ApplyOffset(g_rx_vfo, false);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
SETTINGS_save_channel(g_rx_vfo->channel_save, g_eeprom.rx_vfo, g_rx_vfo, 1);
|
||||
return;
|
||||
@ -720,7 +729,7 @@ static void APP_next_freq(void)
|
||||
if (new_band != old_band)
|
||||
{ // original slow method
|
||||
|
||||
RADIO_ApplyOffset(g_rx_vfo);
|
||||
RADIO_ApplyOffset(g_rx_vfo, false);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
@ -865,7 +874,7 @@ static void APP_next_channel(void)
|
||||
static void APP_toggle_dual_watch_vfo(void)
|
||||
{
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("dual watch\r\n");
|
||||
UART_SendText("dual wot\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -1008,7 +1017,7 @@ void APP_process_radio_interrupts(void)
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("squelch closed\r\n");
|
||||
UART_SendText("sq close\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1017,130 +1026,12 @@ void APP_process_radio_interrupts(void)
|
||||
g_squelch_open = true;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("squelch opened\r\n");
|
||||
UART_SendText("sq open\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
{
|
||||
const uint16_t rx_sync_flags = BK4819_ReadRegister(0x0B);
|
||||
const uint16_t fsk_reg59 = BK4819_ReadRegister(0x59) & ~((1u << 15) | (1u << 14) | (1u << 12) | (1u << 11));
|
||||
|
||||
const bool rx_sync_neg = (rx_sync_flags & (1u << 7)) ? true : false;
|
||||
const bool rx_sync_pos = (rx_sync_flags & (1u << 6)) ? true : false;
|
||||
const bool rx_sync = (interrupt_bits & BK4819_REG_02_FSK_RX_SYNC) ? true : false;
|
||||
const bool rx_finished = (interrupt_bits & BK4819_REG_02_FSK_RX_FINISHED) ? true : false;
|
||||
const bool rx_fifo_almost_full = (interrupt_bits & BK4819_REG_02_FSK_FIFO_ALMOST_FULL) ? true : false;
|
||||
|
||||
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
|
||||
|
||||
if (rx_sync_neg)
|
||||
{ // RX sync neg found
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("fsk rx sync neg\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (rx_sync_pos)
|
||||
{ // RX sync pos found
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("fsk rx sync pos\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (rx_sync)
|
||||
{
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("fsk rx sync\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (rx_fifo_almost_full)
|
||||
{
|
||||
uint8_t buffer[sizeof(mdc1200_sync_suc_xor) + 14];
|
||||
unsigned int i;
|
||||
uint8_t op;
|
||||
uint8_t arg;
|
||||
uint16_t unit_id;
|
||||
|
||||
const unsigned int sync_size = (fsk_reg59 & (1u << 3)) ? 4 : 2;
|
||||
// const unsigned int size = 1 + ((BK4819_ReadRegister(0x5D) >> 8) & 0xffff);
|
||||
const unsigned int size = sizeof(buffer) - sync_size;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("fsk rx almost full\r\n");
|
||||
#endif
|
||||
|
||||
// 40 C4 B0 32 BA F9 33 18 35 08 83 F6 0C C9
|
||||
// 0100000011000100101100000011001010111010111110010011001100011000001101010000100010000011111101100000110011001001
|
||||
|
||||
// 0100000011000100101100000011001010111010111110010011001100011000001101010000100010000011111101100000000011110101
|
||||
// 1011111100111011010011111100110101000101000001101100110011100111110010101111011101111100000010011111111100001010
|
||||
|
||||
// BF 3B 4F CD 45 06 CC E7 CA F7 7C 09 FF 0A
|
||||
|
||||
{ // fetch RX'ed data .. 16-bits at a time
|
||||
|
||||
unsigned int k = 0;
|
||||
|
||||
// precede the data with the missing sync pattern
|
||||
for (i = 0; i < sync_size; i++)
|
||||
buffer[k++] = mdc1200_sync_suc_xor[i] ^ (rx_sync_neg ? 0x00 : 0xFF);
|
||||
|
||||
for (i = 0; i < (size / 2); i++)
|
||||
{
|
||||
const uint16_t word = BK4819_ReadRegister(0x5F);
|
||||
buffer[k++] = (word >> 0) & 0xff;
|
||||
buffer[k++] = (word >> 8) & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
// clear FIFO's then enable RX
|
||||
BK4819_WriteRegister(0x59, (1u << 15) | (1u << 14) | fsk_reg59);
|
||||
BK4819_WriteRegister(0x59, (1u << 12) | fsk_reg59);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("fsk rx ");
|
||||
for (i = 0; i < sizeof(buffer); i++)
|
||||
UART_printf(" %02X", buffer[i]);
|
||||
UART_SendText("\r\n");
|
||||
#endif
|
||||
|
||||
if (!g_squelch_open)
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off
|
||||
|
||||
if (MDC1200_process_rx(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
// (sync_flags & (1u << 7)) ? true : false, // true if the sync pattern is bit inverted
|
||||
&op,
|
||||
&arg,
|
||||
&unit_id))
|
||||
{
|
||||
g_beep_to_play = BEEP_880HZ_60MS_TRIPLE_BEEP;
|
||||
|
||||
// TODO: display the packet
|
||||
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("MDC1200 op %02X arg %02X id %04X\r\n", op, arg, unit_id);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (rx_finished)
|
||||
{
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("fsk rx finished\r\n");
|
||||
#endif
|
||||
|
||||
BK4819_WriteRegister(0x59, (1u << 15) | (1u << 14) | fsk_reg59);
|
||||
BK4819_WriteRegister(0x59, (1u << 12) | fsk_reg59);
|
||||
}
|
||||
}
|
||||
MDC1200_process_rx(interrupt_bits);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -2234,6 +2125,13 @@ void APP_time_slice_500ms(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
if (mdc1200_rx_ready_tick_500ms > 0)
|
||||
if (--mdc1200_rx_ready_tick_500ms == 0)
|
||||
if (g_center_line == CENTER_LINE_MDC1200)
|
||||
g_center_line = CENTER_LINE_NONE;
|
||||
#endif
|
||||
|
||||
if (g_dtmf_rx_live_timeout > 0)
|
||||
{
|
||||
#ifdef ENABLE_RX_SIGNAL_BAR
|
||||
@ -2588,7 +2486,7 @@ void APP_channel_next(const bool remember_current, const scan_state_dir_t scan_d
|
||||
}
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("APP_channel_next %u\r\n", g_scan_next_channel);
|
||||
// UART_printf("APP_channel_next %u\r\n", g_scan_next_channel);
|
||||
#endif
|
||||
|
||||
if (g_scan_next_channel <= USER_CHANNEL_LAST)
|
||||
|
14
app/main.c
14
app/main.c
@ -128,7 +128,7 @@ void toggle_chan_scanlist(void)
|
||||
g_eeprom.tx_vfo = vfo;
|
||||
|
||||
RADIO_select_vfos();
|
||||
RADIO_ApplyOffset(g_tx_vfo);
|
||||
RADIO_ApplyOffset(g_tx_vfo, false);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo);
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
@ -845,17 +845,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
|
||||
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, 1);
|
||||
|
||||
RADIO_ApplyOffset(g_tx_vfo);
|
||||
if (!g_tx_vfo->frequency_reverse)
|
||||
{
|
||||
g_tx_vfo->p_rx = &g_tx_vfo->freq_config_rx;
|
||||
g_tx_vfo->p_tx = &g_tx_vfo->freq_config_tx;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_tx_vfo->p_rx = &g_tx_vfo->freq_config_tx;
|
||||
g_tx_vfo->p_tx = &g_tx_vfo->freq_config_rx;
|
||||
}
|
||||
RADIO_ApplyOffset(g_tx_vfo, true);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf("save chan\r\n");
|
||||
|
@ -292,10 +292,10 @@ void BK4819_DisableAGC(void)
|
||||
// <7:5> LNA Gain
|
||||
// 7 = 0dB
|
||||
// 6 = -2dB
|
||||
// 5 = -4dB
|
||||
// 5 = -4dB <<<
|
||||
// 4 = -6dB
|
||||
// 3 = -9dB
|
||||
// 2 = -14dB <<<
|
||||
// 2 = -14dB
|
||||
// 1 = -19dB
|
||||
// 0 = -24dB
|
||||
//
|
||||
@ -321,13 +321,14 @@ void BK4819_DisableAGC(void)
|
||||
BK4819_WriteRegister(0x10, 0x007A); // 000000 00 011 11 010
|
||||
BK4819_WriteRegister(0x14, 0x0019); // 000000 00 000 11 001
|
||||
|
||||
// undocumented ?
|
||||
// ??
|
||||
BK4819_WriteRegister(0x49, 0x2A38);
|
||||
BK4819_WriteRegister(0x7B, 0x8420);
|
||||
}
|
||||
|
||||
void BK4819_EnableAGC(void)
|
||||
{
|
||||
#ifndef ENABLE_AM_FIX
|
||||
void BK4819_EnableAGC(void)
|
||||
{
|
||||
// TODO: See if this attenuates overloading
|
||||
// signals as well as boosting weak ones
|
||||
//
|
||||
@ -375,7 +376,8 @@ void BK4819_EnableAGC(void)
|
||||
|
||||
for (unsigned int i = 0; i < 8; i++)
|
||||
BK4819_WriteRegister(0x06, ((i & 7u) << 13) | (0x4A << 7) | (0x36 << 0));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void BK4819_set_GPIO_pin(bk4819_gpio_pin_t Pin, bool bSet)
|
||||
{
|
||||
@ -1939,6 +1941,9 @@ void BK4819_reset_fsk(void)
|
||||
|
||||
BK4819_WriteRegister(0x02, 0); // clear interrupt flags
|
||||
|
||||
// set the almost full threshold
|
||||
BK4819_WriteRegister(0x5E, (64u << 3) | (1u << 0)); // 0 ~ 127, 0 ~ 7
|
||||
|
||||
// set the packet size
|
||||
BK4819_WriteRegister(0x5D, ((packet_size - 1) << 8));
|
||||
|
||||
@ -2141,7 +2146,7 @@ void BK4819_reset_fsk(void)
|
||||
(3u << 8) | // 0 FSK RX gain
|
||||
// 0 ~ 3
|
||||
//
|
||||
(3u << 6) | // 0 ???
|
||||
(0u << 6) | // 0 ???
|
||||
// 0 ~ 3
|
||||
//
|
||||
(0u << 4) | // 0 FSK preamble type selection
|
||||
@ -2177,11 +2182,16 @@ void BK4819_reset_fsk(void)
|
||||
BK4819_WriteRegister(0x5B, ((uint16_t)mdc1200_sync_suc_xor[2] << 8) | (mdc1200_sync_suc_xor[3] << 0));
|
||||
|
||||
// disable CRC
|
||||
BK4819_WriteRegister(0x5C, 0x5625);
|
||||
BK4819_WriteRegister(0x5C, 0x5625); // 010101100 0 100101
|
||||
// BK4819_WriteRegister(0x5C, 0xAA30); // 101010100 0 110000
|
||||
|
||||
{ // packet size .. 14 bytes - size of a single mdc1200 packet
|
||||
uint16_t size = sizeof(mdc1200_sync_suc_xor) + 14;
|
||||
// set the almost full threshold
|
||||
BK4819_WriteRegister(0x5E, (64u << 3) | (1u << 0)); // 0 ~ 127, 0 ~ 7
|
||||
|
||||
{ // packet size .. sync + 14 bytes - size of a single mdc1200 packet
|
||||
uint16_t size = sizeof(mdc1200_sync_suc_xor) + (MDC1200_FEC_K * 2);
|
||||
size -= (fsk_reg59 & (1u << 3)) ? 4 : 2;
|
||||
size = ((size + 1) / 2) * 2; // round up to even, else FSK RX doesn't work
|
||||
BK4819_WriteRegister(0x5D, ((size - 1) << 8));
|
||||
}
|
||||
|
||||
@ -2250,7 +2260,7 @@ void BK4819_reset_fsk(void)
|
||||
|
||||
const uint16_t tx_dev = BK4819_ReadRegister(0x40);
|
||||
// BK4819_WriteRegister(0x40, (0u << 12) | (1232 << 0)); // 000 0 010011010000
|
||||
BK4819_WriteRegister(0x40, (tx_dev & 0xf000) | (1050 << 0)); // reduce the deviation a little
|
||||
BK4819_WriteRegister(0x40, (tx_dev & 0xf000) | (1000 << 0)); // reduce the deviation a little
|
||||
|
||||
// REG_2B 0
|
||||
//
|
||||
@ -2294,7 +2304,7 @@ void BK4819_reset_fsk(void)
|
||||
(1u << 1) | // enable TX DSP
|
||||
(0u << 0)); // disable RX DSP
|
||||
|
||||
SYSTEM_DelayMs(20);
|
||||
SYSTEM_DelayMs(10);
|
||||
|
||||
// *******************************************
|
||||
|
||||
@ -2464,8 +2474,8 @@ void BK4819_reset_fsk(void)
|
||||
//
|
||||
// disable CRC
|
||||
//
|
||||
// BK4819_WriteRegister(0x5C, 0xAA30); // 101010100 0 110000
|
||||
BK4819_WriteRegister(0x5C, 0); // setting to '0' doesn't make any difference !
|
||||
// BK4819_WriteRegister(0x5C, 0x5625); // 010101100 0 100101
|
||||
BK4819_WriteRegister(0x5C, 0xAA30); // 101010100 0 110000
|
||||
|
||||
{ // load the entire packet data into the TX FIFO buffer
|
||||
unsigned int i;
|
||||
@ -2477,7 +2487,7 @@ void BK4819_reset_fsk(void)
|
||||
// enable tx interrupt
|
||||
BK4819_WriteRegister(0x3F, BK4819_REG_3F_FSK_TX_FINISHED);
|
||||
|
||||
// enable TX
|
||||
// enable FSK TX
|
||||
BK4819_WriteRegister(0x59, (1u << 11) | fsk_reg59);
|
||||
|
||||
{ // packet time is ..
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
@ -265,12 +265,11 @@ void FUNCTION_Select(function_type_t Function)
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = true;
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
g_alarm_tone_counter_10ms = 0;
|
||||
#endif
|
||||
|
||||
g_speaker_enabled = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -280,7 +279,10 @@ void FUNCTION_Select(function_type_t Function)
|
||||
{
|
||||
#ifdef ENABLE_MDC1200
|
||||
if (g_current_vfo->mdc1200_mode == MDC1200_MODE_BOT || g_current_vfo->mdc1200_mode == MDC1200_MODE_BOTH)
|
||||
{
|
||||
SYSTEM_DelayMs(150);
|
||||
BK4819_send_MDC1200(MDC1200_OP_CODE_PTT_ID, 0x80, g_eeprom.mdc1200_id);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
|
||||
|
6
main.c
6
main.c
@ -65,9 +65,11 @@ void Main(void)
|
||||
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE;
|
||||
|
||||
SYSTICK_Init();
|
||||
|
||||
#ifdef ENABLE_UART
|
||||
UART_Init();
|
||||
#endif
|
||||
|
||||
BOARD_Init();
|
||||
|
||||
#if defined(ENABLE_UART)
|
||||
@ -91,11 +93,11 @@ void Main(void)
|
||||
BK4819_Init();
|
||||
|
||||
#if defined(ENABLE_UART)
|
||||
UART_printf("bk4819 id %04X rev %04X\r\n", BK4819_ReadRegister(0x00), BK4819_ReadRegister(0x01));
|
||||
UART_printf("BK4819 id %04X rev %04X\r\n", BK4819_ReadRegister(0x00), BK4819_ReadRegister(0x01));
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
mdc1200_init();
|
||||
MDC1200_init();
|
||||
#endif
|
||||
|
||||
BOARD_ADC_GetBatteryInfo(&g_usb_current_voltage, &g_usb_current);
|
||||
|
217
mdc1200.c
217
mdc1200.c
@ -1,6 +1,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/crc.h"
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
#include "driver/uart.h"
|
||||
@ -8,8 +9,6 @@
|
||||
#include "mdc1200.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define FEC_K 7 // R=1/2 K=7 convolutional coder
|
||||
|
||||
// **********************************************************
|
||||
|
||||
// pre-amble and sync pattern
|
||||
@ -136,7 +135,7 @@ void error_correction(void *data)
|
||||
uint8_t syn;
|
||||
uint8_t *data8 = (uint8_t *)data;
|
||||
|
||||
for (i = 0, shift_reg = 0, syn = 0; i < FEC_K; i++)
|
||||
for (i = 0, shift_reg = 0, syn = 0; i < MDC1200_FEC_K; i++)
|
||||
{
|
||||
const uint8_t bi = data8[i];
|
||||
int bit_num;
|
||||
@ -147,7 +146,7 @@ void error_correction(void *data)
|
||||
|
||||
shift_reg = (shift_reg << 1) | ((bi >> bit_num) & 1u);
|
||||
b = ((shift_reg >> 6) ^ (shift_reg >> 5) ^ (shift_reg >> 2) ^ (shift_reg >> 0)) & 1u;
|
||||
syn = (syn << 1) | (((b ^ (data8[i + FEC_K] >> bit_num)) & 1u) ? 1u : 0u);
|
||||
syn = (syn << 1) | (((b ^ (data8[i + MDC1200_FEC_K] >> bit_num)) & 1u) ? 1u : 0u);
|
||||
|
||||
if (syn & 0x80) k++;
|
||||
if (syn & 0x20) k++;
|
||||
@ -205,7 +204,7 @@ bool decode_data(void *data)
|
||||
unsigned int i;
|
||||
unsigned int k;
|
||||
unsigned int m;
|
||||
uint8_t deinterleaved[(FEC_K * 2) * 8]; // temp individual bit storage
|
||||
uint8_t deinterleaved[(MDC1200_FEC_K * 2) * 8]; // temp individual bit storage
|
||||
|
||||
// interleave order
|
||||
// 0, 16, 32, 48, 64, 80, 96,
|
||||
@ -228,7 +227,7 @@ bool decode_data(void *data)
|
||||
// de-interleave the received bits
|
||||
for (i = 0, k = 0; i < 16; i++)
|
||||
{
|
||||
for (m = 0; m < FEC_K; m++)
|
||||
for (m = 0; m < MDC1200_FEC_K; m++)
|
||||
{
|
||||
const unsigned int n = (m * 16) + i;
|
||||
deinterleaved[k++] = (data8[n >> 3] >> ((7 - n) & 7u)) & 1u;
|
||||
@ -236,7 +235,7 @@ bool decode_data(void *data)
|
||||
}
|
||||
|
||||
// copy the de-interleaved bits back into the data buffer
|
||||
for (i = 0, m = 0; i < (FEC_K * 2); i++)
|
||||
for (i = 0, m = 0; i < (MDC1200_FEC_K * 2); i++)
|
||||
{
|
||||
unsigned int k;
|
||||
uint8_t b = 0;
|
||||
@ -302,7 +301,7 @@ uint8_t * encode_data(void *data)
|
||||
{ // add the FEC bits to the end of the data
|
||||
unsigned int i;
|
||||
uint8_t shift_reg = 0;
|
||||
for (i = 0; i < FEC_K; i++)
|
||||
for (i = 0; i < MDC1200_FEC_K; i++)
|
||||
{
|
||||
unsigned int bit_num;
|
||||
const uint8_t bi = data8[i];
|
||||
@ -312,7 +311,7 @@ uint8_t * encode_data(void *data)
|
||||
shift_reg = (shift_reg << 1) | ((bi >> bit_num) & 1u);
|
||||
bo |= (((shift_reg >> 6) ^ (shift_reg >> 5) ^ (shift_reg >> 2) ^ (shift_reg >> 0)) & 1u) << bit_num;
|
||||
}
|
||||
data8[FEC_K + i] = bo;
|
||||
data8[MDC1200_FEC_K + i] = bo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,7 +319,7 @@ uint8_t * encode_data(void *data)
|
||||
/*
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
{
|
||||
const unsigned int size = FEC_K * 2;
|
||||
const unsigned int size = MDC1200_FEC_K * 2;
|
||||
unsigned int i;
|
||||
UART_printf("mdc1200 tx1 %u ", size);
|
||||
for (i = 0; i < size; i++)
|
||||
@ -333,7 +332,7 @@ uint8_t * encode_data(void *data)
|
||||
|
||||
unsigned int i;
|
||||
unsigned int k;
|
||||
uint8_t interleaved[(FEC_K * 2) * 8]; // temp individual bit storage
|
||||
uint8_t interleaved[(MDC1200_FEC_K * 2) * 8]; // temp individual bit storage
|
||||
|
||||
// interleave order
|
||||
// 0, 16, 32, 48, 64, 80, 96,
|
||||
@ -354,7 +353,7 @@ uint8_t * encode_data(void *data)
|
||||
// 15, 31, 47, 63, 79, 95, 111
|
||||
|
||||
// bit interleaver
|
||||
for (i = 0, k = 0; i < (FEC_K * 2); i++)
|
||||
for (i = 0, k = 0; i < (MDC1200_FEC_K * 2); i++)
|
||||
{
|
||||
unsigned int bit_num;
|
||||
const uint8_t b = data8[i];
|
||||
@ -368,7 +367,7 @@ uint8_t * encode_data(void *data)
|
||||
}
|
||||
|
||||
// copy the interleaved bits back to the data buffer
|
||||
for (i = 0, k = 0; i < (FEC_K * 2); i++)
|
||||
for (i = 0, k = 0; i < (MDC1200_FEC_K * 2); i++)
|
||||
{
|
||||
int bit_num;
|
||||
uint8_t b = 0;
|
||||
@ -379,7 +378,7 @@ uint8_t * encode_data(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
return data8 + (FEC_K * 2);
|
||||
return data8 + (MDC1200_FEC_K * 2);
|
||||
}
|
||||
|
||||
unsigned int MDC1200_encode_single_packet(void *data, const uint8_t op, const uint8_t arg, const uint16_t unit_id)
|
||||
@ -483,7 +482,7 @@ void MDC1200_reset_rx(void)
|
||||
memset(&rx, 0, sizeof(rx));
|
||||
}
|
||||
|
||||
bool MDC1200_process_rx(
|
||||
bool MDC1200_process_rx_data(
|
||||
const void *buffer,
|
||||
const unsigned int size,
|
||||
//const bool inverted,
|
||||
@ -494,30 +493,30 @@ bool MDC1200_process_rx(
|
||||
const uint8_t *buffer8 = (const uint8_t *)buffer;
|
||||
unsigned int index;
|
||||
|
||||
// FB 72 40 99 A7
|
||||
// FB 72 40 99 A7 BF 3B 4F CD 45 06 CC D1 CC D1 CC D1 CC 2B
|
||||
// FB 72 40 99 A7 BA 24 FC F8 43 05 CA D1 CC FF 1B FF 1B 2B
|
||||
// 04 8D BF 66 58 sync
|
||||
// FB 72 40 99 A7 inverted sync
|
||||
//
|
||||
// 04 8D BF 66 58 40 C4 B0 32 BA F9 33 18 35 08 83 F6 0C 36 .. 80 87 20 23 2C AE 22 10 26 0F 02 A4 08 24
|
||||
// 04 8D BF 66 58 45 DB 03 07 BC FA 35 2E 33 0E 83 0E 83 69 .. 86 92 02 05 28 AC 26 34 22 0B 02 0B 02 4E
|
||||
|
||||
memset(&rx, 0, sizeof(rx));
|
||||
|
||||
for (index = 0; index < size; index++)
|
||||
{
|
||||
unsigned int i;
|
||||
int bit;
|
||||
|
||||
const uint8_t rx_byte = buffer8[index];
|
||||
|
||||
for (bit = 7; bit >= 0; bit--)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
rx.prev_bit = rx.bit;
|
||||
|
||||
rx.bit = (rx_byte >> bit) & 1u;
|
||||
|
||||
rx.xor_bit = (rx.xor_bit ^ rx.bit) & 1u;
|
||||
if (rx.stage > 0 && rx.inverted_sync)
|
||||
rx.xor_bit ^= 1u;
|
||||
rx.xor_bit = (rx.xor_bit ^ rx.bit) & 1u; // toggle our bit if the rx bit is high
|
||||
|
||||
rx.shift_reg = (rx.shift_reg << 1) | (rx.xor_bit & 1u);
|
||||
rx.shift_reg = (rx.shift_reg << 1) | rx.xor_bit;
|
||||
rx.bit_count++;
|
||||
|
||||
// *********
|
||||
@ -527,7 +526,7 @@ bool MDC1200_process_rx(
|
||||
|
||||
const unsigned int sync_bit_ok_threshold = 32;
|
||||
|
||||
if (rx.bit_count >= sync_bit_ok_threshold)
|
||||
if (rx.bit_count >= 40)
|
||||
{
|
||||
// 40-bit sync pattern
|
||||
uint64_t sync_nor = 0x07092a446fu; // normal
|
||||
@ -546,16 +545,23 @@ bool MDC1200_process_rx(
|
||||
nor_count = 40 - nor_count;
|
||||
inv_count = 40 - inv_count;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_SendText("mdc1200 rx sync pat ");
|
||||
// for (i = 64; i > 0; i--)
|
||||
// UART_printf("%u", (uint8_t)((rx.shift_reg >> (i - 1))) & 1u);
|
||||
// UART_SendText("\r\n");
|
||||
#endif
|
||||
|
||||
if (nor_count >= sync_bit_ok_threshold || inv_count >= sync_bit_ok_threshold)
|
||||
{ // good enough
|
||||
|
||||
rx.inverted_sync = (inv_count > nor_count) ? true : false;
|
||||
rx.data_index = 0;
|
||||
rx.bit_count = 0;
|
||||
rx.stage++;
|
||||
rx.stage = 1;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("mdc1200 rx sync %s\r\n", rx.inverted_sync ? "inv" : "nor");
|
||||
//UART_printf("mdc1200 rx sync %s\r\n", rx.inverted_sync ? "inv" : "nor");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -568,15 +574,13 @@ bool MDC1200_process_rx(
|
||||
|
||||
rx.bit_count = 0;
|
||||
|
||||
// 07 09 2A 44 6F 94 9C 22 20 32 A4 1A 37 1E 3A 00 98 2C 84
|
||||
|
||||
rx.data[rx.data_index++] = rx.shift_reg & 0xff; // save the last 8 bits
|
||||
|
||||
if (rx.data_index < (FEC_K * 2))
|
||||
if (rx.data_index < (MDC1200_FEC_K * 2))
|
||||
continue;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("mdc1200 rx ");
|
||||
UART_SendText("mdc1200 dec ");
|
||||
for (i = 0; i < rx.data_index; i++)
|
||||
UART_printf(" %02X", rx.data[i]);
|
||||
UART_SendText("\r\n");
|
||||
@ -587,7 +591,7 @@ bool MDC1200_process_rx(
|
||||
MDC1200_reset_rx();
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("mdc1200 rx decode error\r\n");
|
||||
UART_SendText("mdc1200 dec err\r\n");
|
||||
#endif
|
||||
|
||||
continue;
|
||||
@ -596,10 +600,10 @@ bool MDC1200_process_rx(
|
||||
// extract the info from the packet
|
||||
*op = rx.data[0];
|
||||
*arg = rx.data[1];
|
||||
*unit_id = ((uint16_t)rx.data[3] << 8) | (rx.data[2] << 0);
|
||||
*unit_id = ((uint16_t)rx.data[2] << 8) | (rx.data[3] << 0);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("mdc1200 rx op %02X arg %02X id %04X\r\n", *op, *arg, *unit_id);
|
||||
//UART_printf("mdc1200 op %02X arg %02X id %04X\r\n", *op, *arg, *unit_id);
|
||||
#endif
|
||||
|
||||
// reset the detector
|
||||
@ -614,6 +618,149 @@ bool MDC1200_process_rx(
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t mdc1200_rx_buffer[sizeof(mdc1200_sync_suc_xor) + (MDC1200_FEC_K * 2)];
|
||||
unsigned int mdc1200_rx_buffer_index = 0;
|
||||
|
||||
uint8_t mdc1200_op;
|
||||
uint8_t mdc1200_arg;
|
||||
uint16_t mdc1200_unit_id;
|
||||
uint8_t mdc1200_rx_ready_tick_500ms;
|
||||
|
||||
void MDC1200_process_rx(const uint16_t interrupt_bits)
|
||||
{
|
||||
const uint16_t rx_sync_flags = BK4819_ReadRegister(0x0B);
|
||||
const uint16_t fsk_reg59 = BK4819_ReadRegister(0x59) & ~((1u << 15) | (1u << 14) | (1u << 12) | (1u << 11));
|
||||
|
||||
const bool rx_sync = (interrupt_bits & BK4819_REG_02_FSK_RX_SYNC) ? true : false;
|
||||
const bool rx_sync_neg = (rx_sync_flags & (1u << 7)) ? true : false;
|
||||
const bool rx_sync_pos = (rx_sync_flags & (1u << 6)) ? true : false;
|
||||
const bool rx_fifo_almost_full = (interrupt_bits & BK4819_REG_02_FSK_FIFO_ALMOST_FULL) ? true : false;
|
||||
const bool rx_finished = (interrupt_bits & BK4819_REG_02_FSK_RX_FINISHED) ? true : false;
|
||||
|
||||
const unsigned int sync_size = (fsk_reg59 & (1u << 3)) ? 4 : 2;
|
||||
|
||||
if (rx_sync)
|
||||
{
|
||||
// BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
|
||||
|
||||
//mdc1200_rx_ready = false;
|
||||
|
||||
mdc1200_rx_buffer_index = 0;
|
||||
|
||||
{ // precede the data with the missing sync pattern (it's not part of the packet data)
|
||||
unsigned int i;
|
||||
memset(mdc1200_rx_buffer, 0, sizeof(mdc1200_rx_buffer));
|
||||
for (i = 0; i < sync_size; i++)
|
||||
mdc1200_rx_buffer[mdc1200_rx_buffer_index++] = mdc1200_sync_suc_xor[i] ^ (rx_sync_neg ? 0xFF : 0x00);
|
||||
}
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("mdc1200 syn");
|
||||
#endif
|
||||
|
||||
if (rx_sync_neg)
|
||||
{ // RX sync neg found
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("-");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (rx_sync_pos)
|
||||
{ // RX sync pos found
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("+");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (rx_fifo_almost_full)
|
||||
{
|
||||
unsigned int i;
|
||||
const unsigned int count = BK4819_ReadRegister(0x5E) & (7u << 0); // almost full threshold
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("mdc1200 full %2u %2u ", mdc1200_rx_buffer_index, count);
|
||||
#endif
|
||||
|
||||
// fetch RX'ed data
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
const uint16_t word = BK4819_ReadRegister(0x5F) ^ (rx_sync_neg ? 0xFFFF : 0x0000);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf(" %04X", word);
|
||||
#endif
|
||||
|
||||
if (mdc1200_rx_buffer_index < sizeof(mdc1200_rx_buffer))
|
||||
mdc1200_rx_buffer[mdc1200_rx_buffer_index++] = (word >> 0) & 0xff;
|
||||
|
||||
if (mdc1200_rx_buffer_index < sizeof(mdc1200_rx_buffer))
|
||||
mdc1200_rx_buffer[mdc1200_rx_buffer_index++] = (word >> 8) & 0xff;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("\r\n");
|
||||
#endif
|
||||
|
||||
if (mdc1200_rx_buffer_index >= sizeof(mdc1200_rx_buffer))
|
||||
{
|
||||
BK4819_WriteRegister(0x59, (1u << 15) | (1u << 14) | fsk_reg59);
|
||||
BK4819_WriteRegister(0x59, (1u << 12) | fsk_reg59);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
{
|
||||
unsigned int i;
|
||||
UART_SendText("mdc1200 ");
|
||||
for (i = 0; i < mdc1200_rx_buffer_index; i++)
|
||||
UART_printf(" %02X", mdc1200_rx_buffer[i]);
|
||||
UART_SendText("\r\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// if (!g_squelch_open)
|
||||
// BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off
|
||||
|
||||
if (MDC1200_process_rx_data(
|
||||
mdc1200_rx_buffer,
|
||||
mdc1200_rx_buffer_index,
|
||||
// (sync_flags & (1u << 7)) ? true : false, // true if the sync pattern is bit inverted
|
||||
&mdc1200_op,
|
||||
&mdc1200_arg,
|
||||
&mdc1200_unit_id))
|
||||
{
|
||||
mdc1200_rx_ready_tick_500ms = 2 * 6; // 6 seconds
|
||||
|
||||
g_update_display = true;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("MDC1200 op %02X arg %02X id %04X\r\n", mdc1200_op, mdc1200_arg, mdc1200_unit_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
mdc1200_rx_buffer_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (rx_finished)
|
||||
{
|
||||
mdc1200_rx_buffer_index = 0;
|
||||
|
||||
// if (!g_squelch_open)
|
||||
// BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off
|
||||
|
||||
BK4819_WriteRegister(0x59, (1u << 15) | (1u << 14) | fsk_reg59);
|
||||
BK4819_WriteRegister(0x59, (1u << 12) | fsk_reg59);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("mdc1200 fin\r\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// **********************************************************
|
||||
|
||||
/*
|
||||
@ -625,7 +772,7 @@ void test(void)
|
||||
}
|
||||
*/
|
||||
|
||||
void mdc1200_init(void)
|
||||
void MDC1200_init(void)
|
||||
{
|
||||
memcpy(mdc1200_sync_suc_xor, mdc1200_sync, sizeof(mdc1200_sync));
|
||||
xor_modulation(mdc1200_sync_suc_xor, sizeof(mdc1200_sync_suc_xor));
|
||||
|
19
mdc1200.h
19
mdc1200.h
@ -5,6 +5,8 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MDC1200_FEC_K 7 // R=1/2 K=7 convolutional coder
|
||||
|
||||
// 0x00 (0x81) emergency alarm
|
||||
// 0x20 (0x00) emergency alarm ack
|
||||
//
|
||||
@ -90,18 +92,15 @@ typedef enum mdc1200_op_code_e mdc1200_op_code_t;
|
||||
extern const uint8_t mdc1200_sync[5];
|
||||
extern uint8_t mdc1200_sync_suc_xor[sizeof(mdc1200_sync)];
|
||||
|
||||
extern uint8_t mdc1200_op;
|
||||
extern uint8_t mdc1200_arg;
|
||||
extern uint16_t mdc1200_unit_id;
|
||||
extern uint8_t mdc1200_rx_ready_tick_500ms;
|
||||
|
||||
unsigned int MDC1200_encode_single_packet(void *data, const uint8_t op, const uint8_t arg, const uint16_t unit_id);
|
||||
//unsigned int MDC1200_encode_double_packet(void *data, const uint8_t op, const uint8_t arg, const uint16_t unit_id, const uint8_t b0, const uint8_t b1, const uint8_t b2, const uint8_t b3);
|
||||
|
||||
void MDC1200_reset_rx(void);
|
||||
bool MDC1200_process_rx(
|
||||
const void *buffer,
|
||||
const unsigned int size,
|
||||
//const bool inverted,
|
||||
uint8_t *op,
|
||||
uint8_t *arg,
|
||||
uint16_t *unit_id);
|
||||
|
||||
void mdc1200_init(void);
|
||||
void MDC1200_process_rx(const uint16_t interrupt_bits);
|
||||
void MDC1200_init(void);
|
||||
|
||||
#endif
|
||||
|
29
radio.c
29
radio.c
@ -366,24 +366,13 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
|
||||
p_vfo->tx_offset_freq = FREQUENCY_floor_to_step(p_vfo->tx_offset_freq + (p_vfo->step_freq / 2), p_vfo->step_freq, 0, p_vfo->tx_offset_freq + p_vfo->step_freq);
|
||||
}
|
||||
|
||||
RADIO_ApplyOffset(p_vfo);
|
||||
RADIO_ApplyOffset(p_vfo, true);
|
||||
|
||||
// channel name
|
||||
memset(p_vfo->name, 0, sizeof(p_vfo->name));
|
||||
if (Channel <= USER_CHANNEL_LAST)
|
||||
EEPROM_ReadBuffer(0x0F50 + (Channel * 16), p_vfo->name, 10); // only 10 bytes used
|
||||
|
||||
if (!p_vfo->frequency_reverse)
|
||||
{
|
||||
p_vfo->p_rx = &p_vfo->freq_config_rx;
|
||||
p_vfo->p_tx = &p_vfo->freq_config_tx;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_vfo->p_rx = &p_vfo->freq_config_tx;
|
||||
p_vfo->p_tx = &p_vfo->freq_config_rx;
|
||||
}
|
||||
|
||||
if (p_vfo->am_mode)
|
||||
{ // freq/chan is in AM mode
|
||||
// disable stuff, even though it can all still be used with AM ???
|
||||
@ -583,7 +572,7 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo)
|
||||
// *******************************
|
||||
}
|
||||
|
||||
void RADIO_ApplyOffset(vfo_info_t *p_vfo)
|
||||
void RADIO_ApplyOffset(vfo_info_t *p_vfo, const bool set_pees)
|
||||
{
|
||||
uint32_t Frequency = p_vfo->freq_config_rx.frequency;
|
||||
|
||||
@ -606,6 +595,20 @@ void RADIO_ApplyOffset(vfo_info_t *p_vfo)
|
||||
Frequency = FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper;
|
||||
|
||||
p_vfo->freq_config_tx.frequency = Frequency;
|
||||
|
||||
if (set_pees)
|
||||
{
|
||||
if (!p_vfo->frequency_reverse)
|
||||
{
|
||||
p_vfo->p_rx = &p_vfo->freq_config_rx;
|
||||
p_vfo->p_tx = &p_vfo->freq_config_tx;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_vfo->p_rx = &p_vfo->freq_config_tx;
|
||||
p_vfo->p_tx = &p_vfo->freq_config_rx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void RADIO_SelectCurrentVfo(void)
|
||||
|
2
radio.h
2
radio.h
@ -147,7 +147,7 @@ uint8_t RADIO_FindNextChannel(uint8_t ChNum, scan_state_dir_t Direction, bool b
|
||||
void RADIO_InitInfo(vfo_info_t *p_vfo, const uint8_t ChannelSave, const uint32_t Frequency);
|
||||
void RADIO_configure_channel(const unsigned int VFO, const unsigned int configure);
|
||||
void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo);
|
||||
void RADIO_ApplyOffset(vfo_info_t *p_vfo);
|
||||
void RADIO_ApplyOffset(vfo_info_t *p_vfo, const bool set_pees);
|
||||
void RADIO_select_vfos(void);
|
||||
void RADIO_setup_registers(bool switch_to_function_foreground);
|
||||
#ifdef ENABLE_NOAA
|
||||
|
58
ui/main.c
58
ui/main.c
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
|
||||
#pragma GCC diagnostic pop
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h> // abs()
|
||||
@ -34,6 +34,9 @@
|
||||
#include "font.h"
|
||||
#include "functions.h"
|
||||
#include "helper/battery.h"
|
||||
#ifdef ENABLE_MDC1200
|
||||
#include "mdc1200.h"
|
||||
#endif
|
||||
#include "misc.h"
|
||||
#include "radio.h"
|
||||
#include "settings.h"
|
||||
@ -43,7 +46,7 @@
|
||||
#include "ui/menu.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
center_line_t center_line = CENTER_LINE_NONE;
|
||||
center_line_t g_center_line = CENTER_LINE_NONE;
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
@ -86,7 +89,7 @@ void draw_bar(uint8_t *line, const int len, const int max_width)
|
||||
if (g_current_function != FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN)
|
||||
return false;
|
||||
|
||||
if (center_line != CENTER_LINE_NONE && center_line != CENTER_LINE_TX_TIMEOUT)
|
||||
if (g_center_line != CENTER_LINE_NONE && g_center_line != CENTER_LINE_TX_TIMEOUT)
|
||||
return false;
|
||||
|
||||
if (g_eeprom.tx_timeout_timer == 0)
|
||||
@ -178,7 +181,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
|
||||
if (g_current_function != FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN)
|
||||
return false;
|
||||
|
||||
if (center_line != CENTER_LINE_NONE && center_line != CENTER_LINE_AUDIO_BAR)
|
||||
if (g_center_line != CENTER_LINE_NONE && g_center_line != CENTER_LINE_AUDIO_BAR)
|
||||
return false;
|
||||
|
||||
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE)
|
||||
@ -304,7 +307,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
|
||||
void UI_update_rssi(const int16_t rssi, const int vfo)
|
||||
{
|
||||
#ifdef ENABLE_RX_SIGNAL_BAR
|
||||
if (center_line == CENTER_LINE_RSSI)
|
||||
if (g_center_line == CENTER_LINE_RSSI)
|
||||
{ // optional larger RSSI dBm, S-point and bar level
|
||||
if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR)
|
||||
{
|
||||
@ -434,7 +437,7 @@ void UI_DisplayMain(void)
|
||||
char str[22];
|
||||
unsigned int vfo_num;
|
||||
|
||||
center_line = CENTER_LINE_NONE;
|
||||
g_center_line = CENTER_LINE_NONE;
|
||||
|
||||
// #ifdef SINGLE_VFO_CHAN
|
||||
// const bool single_vfo = (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? true : false;
|
||||
@ -548,7 +551,7 @@ void UI_DisplayMain(void)
|
||||
str[16] = 0;
|
||||
UI_PrintString(str, 2, 0, 2 + (vfo_num * 3), 8);
|
||||
|
||||
center_line = CENTER_LINE_IN_USE;
|
||||
g_center_line = CENTER_LINE_IN_USE;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -665,7 +668,7 @@ void UI_DisplayMain(void)
|
||||
{ // user entering a frequency
|
||||
UI_DisplayFrequency(g_input_box, 32, line, true, false);
|
||||
|
||||
// center_line = CENTER_LINE_IN_USE;
|
||||
// g_center_line = CENTER_LINE_IN_USE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -906,7 +909,9 @@ void UI_DisplayMain(void)
|
||||
UI_PrintStringSmall("SCR", LCD_WIDTH + 106, 0, line + 1);
|
||||
}
|
||||
|
||||
if (center_line == CENTER_LINE_NONE)
|
||||
if (g_center_line == CENTER_LINE_NONE &&
|
||||
g_screen_to_display == DISPLAY_MAIN &&
|
||||
g_dtmf_call_state == DTMF_CALL_STATE_NONE)
|
||||
{ // we're free to use the middle line
|
||||
|
||||
const bool rx = (g_current_function == FUNCTION_RECEIVE ||
|
||||
@ -917,7 +922,7 @@ void UI_DisplayMain(void)
|
||||
// show the TX timeout count down
|
||||
if (UI_DisplayTXCountdown(false))
|
||||
{
|
||||
center_line = CENTER_LINE_TX_TIMEOUT;
|
||||
g_center_line = CENTER_LINE_TX_TIMEOUT;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -926,7 +931,21 @@ void UI_DisplayMain(void)
|
||||
// show the TX audio level
|
||||
if (UI_DisplayAudioBar(false))
|
||||
{
|
||||
center_line = CENTER_LINE_AUDIO_BAR;
|
||||
g_center_line = CENTER_LINE_AUDIO_BAR;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
if (mdc1200_rx_ready_tick_500ms > 0)
|
||||
{
|
||||
g_center_line = CENTER_LINE_MDC1200;
|
||||
sprintf(str, "MDC1200 %02X %02X %04X", mdc1200_op, mdc1200_arg, mdc1200_unit_id);
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
UI_PrintStringSmallBold(str, 2, 0, 3);
|
||||
#else
|
||||
UI_PrintStringSmall(str, 2, 0, 3);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -935,10 +954,7 @@ void UI_DisplayMain(void)
|
||||
// show the AM-FIX debug data
|
||||
if (rx && g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_am_fix)
|
||||
{
|
||||
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
|
||||
return;
|
||||
|
||||
center_line = CENTER_LINE_AM_FIX_DATA;
|
||||
g_center_line = CENTER_LINE_AM_FIX_DATA;
|
||||
AM_fix_print_data(g_eeprom.rx_vfo, str);
|
||||
UI_PrintStringSmall(str, 2, 0, 3);
|
||||
}
|
||||
@ -949,7 +965,7 @@ void UI_DisplayMain(void)
|
||||
// show the RX RSSI dBm, S-point and signal strength bar graph
|
||||
if (rx && g_setting_rssi_bar)
|
||||
{
|
||||
center_line = CENTER_LINE_RSSI;
|
||||
g_center_line = CENTER_LINE_RSSI;
|
||||
UI_DisplayRSSIBar(g_current_rssi[g_eeprom.rx_vfo], false);
|
||||
}
|
||||
else
|
||||
@ -966,7 +982,7 @@ void UI_DisplayMain(void)
|
||||
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
|
||||
return;
|
||||
|
||||
center_line = CENTER_LINE_DTMF_DEC;
|
||||
g_center_line = CENTER_LINE_DTMF_DEC;
|
||||
|
||||
strcpy(str, "DTMF ");
|
||||
strcat(str, g_dtmf_rx_live + idx);
|
||||
@ -981,7 +997,7 @@ void UI_DisplayMain(void)
|
||||
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
|
||||
return;
|
||||
|
||||
center_line = CENTER_LINE_DTMF_DEC;
|
||||
g_center_line = CENTER_LINE_DTMF_DEC;
|
||||
|
||||
strcpy(str, "DTMF ");
|
||||
strcat(str, g_dtmf_rx + idx);
|
||||
@ -996,7 +1012,7 @@ void UI_DisplayMain(void)
|
||||
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
|
||||
return;
|
||||
|
||||
center_line = CENTER_LINE_CHARGE_DATA;
|
||||
g_center_line = CENTER_LINE_CHARGE_DATA;
|
||||
|
||||
sprintf(str, "Charge %u.%02uV %u%%",
|
||||
g_battery_voltage_average / 100, g_battery_voltage_average % 100,
|
||||
|
@ -25,11 +25,12 @@ enum center_line_e {
|
||||
CENTER_LINE_RSSI,
|
||||
CENTER_LINE_AM_FIX_DATA,
|
||||
CENTER_LINE_DTMF_DEC,
|
||||
CENTER_LINE_CHARGE_DATA
|
||||
CENTER_LINE_CHARGE_DATA,
|
||||
CENTER_LINE_MDC1200
|
||||
};
|
||||
typedef enum center_line_e center_line_t;
|
||||
|
||||
extern center_line_t center_line;
|
||||
extern center_line_t g_center_line;
|
||||
|
||||
#ifdef ENABLE_TX_TIMEOUT_BAR
|
||||
bool UI_DisplayTXCountdown(const bool now);
|
||||
|
Loading…
x
Reference in New Issue
Block a user