diff --git a/am_fix.c b/am_fix.c index 1ade88c..4be5dd8 100644 --- a/am_fix.c +++ b/am_fix.c @@ -51,10 +51,10 @@ // <7:5> = LNA Gain // 7 = 0dB // 6 = -2dB - // 5 = -4dB + // 5 = -4dB < original value // 4 = -6dB // 3 = -9dB - // 2 = -14dB < original value + // 2 = -14dB // 1 = -19dB // 0 = -24dB // @@ -112,7 +112,6 @@ static const unsigned int original_index = 1; #else - {0x0000, -98}, // 1 .. 0 0 0 0 .. -33dB -24dB -8dB -33dB .. -98dB {0x0008, -96}, // 2 .. 0 0 1 0 .. -33dB -24dB -6dB -33dB .. -96dB {0x0100, -95}, // 3 .. 1 0 0 0 .. -30dB -24dB -8dB -33dB .. -95dB @@ -192,26 +191,26 @@ {0x03D3, -20}, // 77 .. 3 6 2 3 .. 0dB -2dB -3dB -15dB .. -20dB {0x03BB, -19}, // 78 .. 3 5 3 3 .. 0dB -4dB 0dB -15dB .. -19dB {0x037C, -18}, // 79 .. 3 3 3 4 .. 0dB -9dB 0dB -9dB .. -18dB - {0x035E, -17}, // 80 .. 3 2 3 6 .. 0dB -14dB 0dB -3dB .. -17dB original + {0x03CC, -17}, // 80 .. 3 6 1 4 .. 0dB -2dB -6dB -9dB .. -17dB {0x03C5, -16}, // 81 .. 3 6 0 5 .. 0dB -2dB -8dB -6dB .. -16dB {0x03EC, -15}, // 82 .. 3 7 1 4 .. 0dB 0dB -6dB -9dB .. -15dB {0x035F, -14}, // 83 .. 3 2 3 7 .. 0dB -14dB 0dB 0dB .. -14dB - {0x03C6, -13}, // 84 .. 3 6 0 6 .. 0dB -2dB -8dB -3dB .. -13dB - {0x0377, -12}, // 85 .. 3 3 2 7 .. 0dB -9dB -3dB 0dB .. -12dB + {0x03BC, -13}, // 84 .. 3 5 3 4 .. 0dB -4dB 0dB -9dB .. -13dB + {0x038F, -12}, // 85 .. 3 4 1 7 .. 0dB -6dB -6dB 0dB .. -12dB {0x03E6, -11}, // 86 .. 3 7 0 6 .. 0dB 0dB -8dB -3dB .. -11dB - {0x03BD, -10}, // 87 .. 3 5 3 5 .. 0dB -4dB 0dB -6dB .. -10dB - {0x03F5, -9}, // 88 .. 3 7 2 5 .. 0dB 0dB -3dB -6dB .. -9dB - {0x03DD, -8}, // 89 .. 3 6 3 5 .. 0dB -2dB 0dB -6dB .. -8dB - {0x03B7, -7}, // 90 .. 3 5 2 7 .. 0dB -4dB -3dB 0dB .. -7dB - {0x03F6, -6}, // 91 .. 3 7 2 6 .. 0dB 0dB -3dB -3dB .. -6dB - {0x03D7, -5}, // 92 .. 3 6 2 7 .. 0dB -2dB -3dB 0dB .. -5dB - {0x03BF, -4}, // 93 .. 3 5 3 7 .. 0dB -4dB 0dB 0dB .. -4dB - {0x03F7, -3}, // 94 .. 3 7 2 7 .. 0dB 0dB -3dB 0dB .. -3dB - {0x03DF, -2}, // 95 .. 3 6 3 7 .. 0dB -2dB 0dB 0dB .. -2dB - {0x03FF, 0} // 96 .. 3 7 3 7 .. 0dB 0dB 0dB 0dB .. 0dB + {0x03AF, -10}, // 87 .. 3 5 1 7 .. 0dB -4dB -6dB 0dB .. -10dB + {0x03F5, -9 }, // 88 .. 3 7 2 5 .. 0dB 0dB -3dB -6dB .. -9dB + {0x03D6, -8 }, // 89 .. 3 6 2 6 .. 0dB -2dB -3dB -3dB .. -8dB + {0x03BE, -7 }, // 90 .. 3 5 3 6 .. 0dB -4dB 0dB -3dB .. -7dB original + {0x03F6, -6 }, // 91 .. 3 7 2 6 .. 0dB 0dB -3dB -3dB .. -6dB + {0x03DE, -5 }, // 92 .. 3 6 3 6 .. 0dB -2dB 0dB -3dB .. -5dB + {0x03BF, -4 }, // 93 .. 3 5 3 7 .. 0dB -4dB 0dB 0dB .. -4dB + {0x03F7, -3 }, // 94 .. 3 7 2 7 .. 0dB 0dB -3dB 0dB .. -3dB + {0x03DF, -2 }, // 95 .. 3 6 3 7 .. 0dB -2dB 0dB 0dB .. -2dB + {0x03FF, 0 }, // 96 .. 3 7 3 7 .. 0dB 0dB 0dB 0dB .. 0dB }; - static const unsigned int original_index = 80; + static const unsigned int original_index = 90; #endif diff --git a/app/app.c b/app/app.c index 4a10376..bf07c90 100644 --- a/app/app.c +++ b/app/app.c @@ -68,8 +68,9 @@ #include "ui/ui.h" // original QS front end register settings +// 0x03BE 00000 011 101 11 110 const uint8_t orig_lna_short = 3; // 0dB -const uint8_t orig_lna = 2; // -14dB +const uint8_t orig_lna = 5; // -4dB const uint8_t orig_mixer = 3; // 0dB const uint8_t orig_pga = 6; // -3dB @@ -570,19 +571,28 @@ bool APP_start_listening(function_type_t Function, const bool reset_am_fix) AM_fix_10ms(chan); } else + { BK4819_WriteRegister(0x13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0)); + } } #else (void)reset_am_fix; #endif // AF gain - original QS values - BK4819_WriteRegister(0x48, - (11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference - ( 0u << 10) | // AF Rx Gain-1 - (g_eeprom.volume_gain << 4) | // AF Rx Gain-2 - (g_eeprom.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2) - + if (g_rx_vfo->am_mode) + { + BK4819_WriteRegister(0x48, 0xB3A8); + } + else + { + BK4819_WriteRegister(0x48, + (11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference + ( 0u << 10) | // AF Rx Gain-1 + (g_eeprom.volume_gain << 4) | // AF Rx Gain-2 + (g_eeprom.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2) + } + #ifdef ENABLE_VOICE #ifdef MUTE_AUDIO_FOR_VOICE if (g_voice_write_index == 0) diff --git a/driver/bk4819.c b/driver/bk4819.c index 99f7861..3e1a85a 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -53,8 +53,8 @@ void BK4819_Init(void) BK4819_WriteRegister(0x37, 0x1D0F); BK4819_WriteRegister(0x36, 0x0022); -// BK4819_DisableAGC(); - BK4819_EnableAGC(); + BK4819_DisableAGC(); +// BK4819_EnableAGC(); BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable @@ -312,7 +312,7 @@ void BK4819_DisableAGC(void) // 1 = -27dB // 0 = -33dB // - BK4819_WriteRegister(0x13, (3u << 8) | (2u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110 + BK4819_WriteRegister(0x13, (3u << 8) | (5u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110 BK4819_WriteRegister(0x12, 0x037B); // 000000 11 011 11 011 BK4819_WriteRegister(0x11, 0x027B); // 000000 10 011 11 011 BK4819_WriteRegister(0x10, 0x007A); // 000000 00 011 11 010 @@ -351,7 +351,7 @@ void BK4819_EnableAGC(void) (5u << 3) | // 5 DC Filter band width for Tx (MIC In) (6u << 0)); // 6 DC Filter band width for Rx (I.F In) - BK4819_WriteRegister(0x13, (3u << 8) | (2u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110 + BK4819_WriteRegister(0x13, (3u << 8) | (5u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110 BK4819_WriteRegister(0x12, 0x037C); BK4819_WriteRegister(0x11, 0x027B); BK4819_WriteRegister(0x10, 0x007A); diff --git a/firmware.bin b/firmware.bin index 2f6ccb8..cbaf5f6 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 5ac360d..345d7a3 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/mdc1200.c b/mdc1200.c index f684685..15d2f2b 100644 --- a/mdc1200.c +++ b/mdc1200.c @@ -9,13 +9,16 @@ #define FEC_K 7 -// MDC1200 sync bit reversals and packet sync +// ********************************************************** + +// pre-amble and sync pattern // // >= 24-bit pre-amble -// 40-bit sync +// 40-bit sync // -static const uint8_t pre_amble[] = {0x00, 0x00, 0x00, 0x00, 0x00}; -static const uint8_t sync[] = {0xCC, 0x07, 0x09, 0x2a, 0x44, 0x6f}; +static const uint8_t pre_amble[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0xCC}; +static const uint8_t sync[] = {0x07, 0x09, 0x2a, 0x44, 0x6f}; + /* uint8_t bit_reverse_8(uint8_t n) { @@ -45,6 +48,7 @@ uint32_t bit_reverse_32(uint32_t n) } */ // ************************************ +// common #if 0 @@ -105,6 +109,7 @@ uint32_t bit_reverse_32(uint32_t n) #endif // ************************************ +// RX void error_correction(uint8_t *data) { // can correct up to 3 or 4 corrupted bits (I think) @@ -147,26 +152,6 @@ void error_correction(uint8_t *data) } } } - -void xor_modulation(uint8_t *data, const unsigned int size) -{ // exclusive-or succesive bits - the entire packet - unsigned int i; - uint8_t prev_bit = 0; - for (i = 0; i < size; i++) - { - int bit_num; - uint8_t in = data[i]; - uint8_t out = 0; - for (bit_num = 7; bit_num >= 0; bit_num--) - { - const uint8_t new_bit = (in >> bit_num) & 1u; - if (new_bit != prev_bit) - out |= 1u << bit_num; // previous bit and new bit are different - send a '1' - prev_bit = new_bit; - } - data[i] = out ^ 0xff; - } -} /* void xor_demodulation(uint8_t *data, const unsigned int size, const bool sync_inverted) { @@ -256,6 +241,29 @@ bool decode_data(uint8_t *data) return (crc1 == crc2) ? true : false; } +// ********************************************************** +// TX + +void xor_modulation(uint8_t *data, const unsigned int size) +{ // exclusive-or succesive bits - the entire packet + unsigned int i; + uint8_t prev_bit = 0; + for (i = 0; i < size; i++) + { + int bit_num; + uint8_t in = data[i]; + uint8_t out = 0; + for (bit_num = 7; bit_num >= 0; bit_num--) + { + const uint8_t new_bit = (in >> bit_num) & 1u; + if (new_bit != prev_bit) + out |= 1u << bit_num; // previous bit and new bit are different - send a '1' + prev_bit = new_bit; + } + data[i] = out ^ 0xff; + } +} + uint8_t * encode_data(uint8_t *data) { // R=1/2 K=7 convolutional coder @@ -431,6 +439,9 @@ unsigned int MDC1200_encode_double_packet(uint8_t *data, const uint8_t op, const } */ +// ********************************************************** +// RX + struct { uint8_t bit; uint8_t prev_bit; @@ -617,6 +628,8 @@ bool MDC1200_process_rx(const uint8_t rx_byte, uint8_t *op, uint8_t *arg, uint16 return false; } +// ********************************************************** + /* void test(void) { diff --git a/utils/main.cpp b/utils/main.cpp index aecd428..c05dbf3 100644 --- a/utils/main.cpp +++ b/utils/main.cpp @@ -36,10 +36,10 @@ // <7:5> = LNA Gain // 7 = 0dB // 6 = -2dB - // 5 = -4dB + // 5 = -4dB < original value // 4 = -6dB // 3 = -9dB - // 2 = -14dB < original value + // 2 = -14dB // 1 = -19dB // 0 = -24dB // @@ -87,7 +87,7 @@ void create_gain_table(const char *filename) const int16_t pga_dB[8] = { (-33), (-27), (-21), (-15), (-9), (-6), (-3), (0)}; const uint8_t orig_lna_short = 3; - const uint8_t orig_lna = 2; + const uint8_t orig_lna = 5; const uint8_t orig_mixer = 3; const uint8_t orig_pga = 6; @@ -581,7 +581,7 @@ int main(int argc, char* argv[]) rotate_font("uv-k5_small.bin", "uv-k5_small.c"); rotate_font("uv-k5_small_bold.bin", "uv-k5_small_bold.c"); - rotate_font_4x5("uv-k5_small_4x5.bin", "uv-k5_small_4x5.c"); +// rotate_font_4x5("uv-k5_small_4x5.bin", "uv-k5_small_4x5.c"); return 0; } diff --git a/utils/misc.exe b/utils/misc.exe index 507a27e..0f0a935 100644 Binary files a/utils/misc.exe and b/utils/misc.exe differ