diff --git a/README.md b/README.md index ba09444..bc0ea4a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ ENABLE_KEEP_MEM_NAME := 1 maintain channel name when (re)savin ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though front-end/PA not designed for full range) ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM ENABLE_F_CAL_MENU := 0 enable/disable the radios hidden frequency calibration menu -ENABLE_TX_UNLOCK := 0 allow TX everywhere EXCEPT airband (108~136) .. TX harmonic content will cause interference to other services, do so entirely at your own risk ! +ENABLE_TX_UNLOCK := 0 allow TX everywhere EXCEPT airband (108~137) .. TX harmonic content will cause interference to other services, do so entirely at your own risk ! ENABLE_CTCSS_TAIL_PHASE_SHIFT := 0 standard CTCSS tail phase shift rather than QS's own 55Hz tone method ENABLE_CONTRAST := 0 add contrast menu ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up diff --git a/app/fm.c b/app/fm.c index 01dd410..000cb46 100644 --- a/app/fm.c +++ b/app/fm.c @@ -49,7 +49,7 @@ uint16_t g_fm_restore_count_down_10ms; bool FM_CheckValidChannel(uint8_t Channel) { - return (Channel < ARRAY_SIZE(g_fm_channels) && (g_fm_channels[Channel] >= 760 && g_fm_channels[Channel] < 1080)) ? true : false; + return (Channel < ARRAY_SIZE(g_fm_channels) && (g_fm_channels[Channel] >= FM_RADIO_BAND.lower && g_fm_channels[Channel] < FM_RADIO_BAND.upper)) ? true : false; } uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction) diff --git a/driver/bk4819.c b/driver/bk4819.c index 9ba7a0d..7af23a5 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -2089,14 +2089,14 @@ void BK4819_PlayRogerMDC1200(void) // <15:8> 0x55 FSK Sync Byte 0 (Sync Byte 0 first, then 1,2,3) // <7:0> 0x55 FSK Sync Byte 1 // - BK4819_WriteRegister(BK4819_REG_5A, 0xffff); // bytes 1 & 2 + BK4819_WriteRegister(BK4819_REG_5A, 0x0000); // bytes 1 & 2 // REG_5B // // <15:8> 0x55 FSK Sync Byte 2 (Sync Byte 0 first, then 1,2,3) // <7:0> 0xAA FSK Sync Byte 3 // - BK4819_WriteRegister(BK4819_REG_5B, 0xffff); // bytes 2 & 3 (not used) + BK4819_WriteRegister(BK4819_REG_5B, 0x0000); // bytes 2 & 3 (not used) // CRC setting (plus other stuff we don't know what) // diff --git a/firmware.bin b/firmware.bin index 63feea0..1c28e12 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index e2a6875..8befb37 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/frequencies.c b/frequencies.c index c4e964f..bfaa4bb 100644 --- a/frequencies.c +++ b/frequencies.c @@ -22,11 +22,13 @@ // the default AIRCOPY frequency uint32_t g_aircopy_freq = 41002500; +const freq_band_table_t AIR_BAND = {10800000, 13700000}; + // FM broadcast band lower/upper limit #ifdef ENABLE_FMRADIO_64_108 const freq_band_table_t FM_RADIO_BAND = {680, 1080}; #else - const freq_band_table_t FM_RADIO_BAND = {880, 1080}; + const freq_band_table_t FM_RADIO_BAND = {875, 1080}; #endif // the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz @@ -38,8 +40,8 @@ const freq_band_table_t FREQ_BAND_TABLE[7] = #ifdef ENABLE_WIDE_RX // extended range { 1800000, 10800000}, // band 1 - {10800000, 13600000}, // band 2 - {13600000, 17400000}, // band 3 + {AIR_BAND.lower, AIR_BAND.upper}, // band 2 + {AIR_BAND.upper, 17400000}, // band 3 {17400000, 35000000}, // band 4 {35000000, 40000000}, // band 5 {40000000, 47000000}, // band 6 @@ -47,8 +49,8 @@ const freq_band_table_t FREQ_BAND_TABLE[7] = #else // QS original { 5000000, 7600000}, // band 1 - {10800000, 13600000}, // band 2 - {13600000, 17400000}, // band 3 + {AIR_BAND.lower, AIR_BAND.upper}, // band 2 + {AIR_BAND.upper, 17400000}, // band 3 {17400000, 35000000}, // band 4 {35000000, 40000000}, // band 5 {40000000, 47000000}, // band 6 @@ -188,7 +190,7 @@ int FREQUENCY_tx_freq_check(const uint32_t Frequency) if (Frequency >= BX4819_BAND1.upper && Frequency < BX4819_BAND2.lower) return -1; // BX radio chip does not work in this range - if (Frequency >= 10800000 && Frequency < 13600000) + if (Frequency >= AIR_BAND.lower && Frequency < AIR_BAND.upper) return -1; // TX not allowed in the airband if (Frequency < FREQ_BAND_TABLE[0].lower || Frequency > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper) @@ -197,7 +199,7 @@ int FREQUENCY_tx_freq_check(const uint32_t Frequency) switch (g_setting_freq_lock) { case FREQ_LOCK_NORMAL: - if (Frequency >= 13600000 && Frequency < 17400000) + if (Frequency >= AIR_BAND.upper && Frequency < 17400000) return 0; if (Frequency >= 17400000 && Frequency < 35000000) if (g_setting_174_tx_enable) @@ -234,14 +236,14 @@ int FREQUENCY_tx_freq_check(const uint32_t Frequency) break; case FREQ_LOCK_430: - if (Frequency >= 13600000 && Frequency < 17400000) + if (Frequency >= AIR_BAND.lower && Frequency < 17400000) return 0; if (Frequency >= 40000000 && Frequency < 43000000) return 0; break; case FREQ_LOCK_438: - if (Frequency >= 13600000 && Frequency < 17400000) + if (Frequency >= AIR_BAND.lower && Frequency < 17400000) return 0; if (Frequency >= 40000000 && Frequency < 43800000) return 0; diff --git a/frequencies.h b/frequencies.h index 2f53dde..c9d49ff 100644 --- a/frequencies.h +++ b/frequencies.h @@ -26,7 +26,7 @@ enum frequency_band_e { BAND_NONE = -1, BAND1_50MHz = 0, BAND2_108MHz, - BAND3_136MHz, + BAND3_137MHz, BAND4_174MHz, BAND5_350MHz, BAND6_400MHz, @@ -41,6 +41,8 @@ typedef struct { extern uint32_t g_aircopy_freq; +extern const freq_band_table_t AIR_BAND; + extern const freq_band_table_t FM_RADIO_BAND; extern const freq_band_table_t BX4819_BAND1; diff --git a/mdc1200.c b/mdc1200.c index e4e0f24..08c406b 100644 --- a/mdc1200.c +++ b/mdc1200.c @@ -5,13 +5,16 @@ #include "mdc1200.h" #include "misc.h" -// MDC1200 sync bit reversals and packet header +// MDC1200 sync bit reversals and packet magic // -// 0000 0111 1011 0111 0010 0100 0000 1001 1001 1010 +// 24-bit pre-amble +// 40-bit sync // -//static const uint8_t header[] = {0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x07, 0x09, 0x2a, 0x44, 0x6f}; -//static const uint8_t header[] = {0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x07, 0x09, 0x2a, 0x44, 0x6f}; -static const uint8_t header[] = {0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x97, 0x1f, 0xc4, 0x4e}; +//static const uint8_t header[] = {0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x07, 0x09, 0x2a, 0x44, 0x6f}; +//static const uint8_t header[] = {0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0x07, 0x09, 0x2a, 0x44, 0x6f}; +// +//static const uint8_t header[] = {0x00, 0x00, 0x00, 0x0A, 0xAA, 0xAA, 0xA0, 0xb6, 0x8e, 0x03, 0xbb, 0x14}; +static const uint8_t header[] = {0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x50, 0x29, 0x71, 0xfc, 0x44, 0xeb}; uint8_t bit_reverse_8(uint8_t n) { @@ -71,38 +74,38 @@ uint16_t reverse_bits(const uint16_t bits_in, const unsigned int num_bits) #else uint16_t compute_crc(const uint8_t *data, const unsigned int data_len) { - + // this can be done using the CPU's own CRC calculator once we know we're ok - + unsigned int i; - + #if 0 uint16_t crc; - + CRC_CR = (CRC_CR & ~CRC_CR_CRC_EN_MASK) | CRC_CR_CRC_EN_BITS_ENABLE; #else uint16_t crc = 0; #endif - + for (i = 0; i < data_len; i++) { #if 0 - + // bit reverse each data byte before adding it to the CRC // the cortex CPU might have an instruction to bit reverse for us ? // CRC_DATAIN = reverse_bits(data[i], 8); //CRC_DATAIN = bit_reverse_8(data[i]); - + #else uint8_t mask; - + // bit reverse each data byte before adding it to the CRC // the cortex CPU might have an instruction to bit reverse for us ? // const uint8_t bits = reverse_bits(data[i], 8); //const uint8_t bits = bit_reverse_8(*data++); - + for (mask = 0x0080; mask != 0; mask >>= 1) { uint16_t msb = crc & 0x8000; @@ -114,14 +117,14 @@ uint16_t reverse_bits(const uint16_t bits_in, const unsigned int num_bits) } #endif } - + #if 0 crc = (uint16_t)CRC_DATAOUT; CRC_CR = (CRC_CR & ~CRC_CR_CRC_EN_MASK) | CRC_CR_CRC_EN_BITS_DISABLE; #endif - + // bit reverse and invert the final CRC - return reverse_bits(crc, 16) ^ 0xffff; + return reverse_bits(crc, 16) ^ 0xffff; // return bit_reverse_16(crc) ^ 0xffff; } #endif @@ -188,10 +191,8 @@ void delta_modulation(uint8_t *data, const unsigned int size) for (bit_num = 7; bit_num >= 0; bit_num--) { const uint8_t b2 = (in >> bit_num) & 1u; -// const uint8_t b2 = (in >> (7 - bit_num)) & 1u; if (b1 != b2) out |= 1u << bit_num; // previous bit and new bit are different -// out |= 1u << (7 - bit_num); b1 = b2; } data[i] = out; @@ -218,8 +219,15 @@ unsigned int MDC1200_encode_single_packet(uint8_t *data, const uint8_t op, const p = encode_data(p); +#if 1 + { // op 0x01, arg 0x80, id 0xB183 + const uint8_t test_packet[] = {0x07, 0x25, 0xDD, 0xD5, 0x9F, 0xC5, 0x3D, 0x89, 0x2D, 0xBD, 0x57, 0x35, 0xE7, 0x44}; + memcpy(data + sizeof(header), test_packet, sizeof(test_packet)); + } +#endif + size = (unsigned int)(p - data); - + delta_modulation(data, size); return size; @@ -258,9 +266,9 @@ unsigned int MDC1200_encode_double_packet(uint8_t *data, const uint8_t op, const p = encode_data(p); size = (unsigned int)(p - data); - + delta_modulation(data, size); - + return size; // return 40; } diff --git a/radio.c b/radio.c index 8d8a1b9..e0e12c6 100644 --- a/radio.c +++ b/radio.c @@ -342,7 +342,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur p_vfo->freq_config_rx.frequency = Frequency; - if (Frequency >= 10800000 && Frequency < 13600000) + if (Frequency >= AIR_BAND.lower && Frequency < AIR_BAND.upper) { // air band p_vfo->tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF; p_vfo->tx_offset_freq = 0; @@ -508,7 +508,7 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo) // // 1ED0 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 50 MHz // 1EE0 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 108 MHz - // 1EF0 5F 5F 5F 69 69 69 91 91 8F FF FF FF FF FF FF FF .. 136 MHz + // 1EF0 5F 5F 5F 69 69 69 91 91 8F FF FF FF FF FF FF FF .. 137 MHz // 1F00 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 174 MHz // 1F10 5A 5A 5A 64 64 64 82 82 82 FF FF FF FF FF FF FF .. 350 MHz // 1F20 5A 5A 5A 64 64 64 8F 91 8A FF FF FF FF FF FF FF .. 400 MHz diff --git a/ui/menu.c b/ui/menu.c index 815ddb4..ec527a4 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -1088,7 +1088,7 @@ void UI_DisplayMenu(void) switch (g_sub_menu_selection) { case FREQ_LOCK_NORMAL: - strcpy(String, "136~174\n400~470\n+ others"); + strcpy(String, "137~174\n400~470\n+ others"); break; case FREQ_LOCK_FCC: strcpy(String, "FCC HAM\n144~148\n420~450"); @@ -1100,10 +1100,10 @@ void UI_DisplayMenu(void) strcpy(String, "GB HAM\n144~148\n430~440"); break; case FREQ_LOCK_430: - strcpy(String, "136~174\n400~430"); + strcpy(String, "137~174\n400~430"); break; case FREQ_LOCK_438: - strcpy(String, "136~174\n400~438"); + strcpy(String, "137~174\n400~438"); break; case FREQ_LOCK_446: strcpy(String, "446.00625\n~\n446.19375");