0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-29 06:41:25 +03:00

MDC1200 TX now working

This commit is contained in:
OneOfEleven 2023-10-24 22:41:09 +01:00
parent a94f99130f
commit da2e55fecd
6 changed files with 54 additions and 31 deletions

View File

@ -1783,9 +1783,10 @@ void APP_time_slice_10ms(void)
RADIO_enableTX(false); RADIO_enableTX(false);
BK4819_TransmitTone(true, 500); BK4819_TransmitTone(true, 500);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = true; g_speaker_enabled = true;
g_alarm_tone_counter_10ms = 0; g_alarm_tone_counter_10ms = 0;
} }
} }

View File

@ -29,7 +29,9 @@
#endif #endif
#include "audio.h" #include "audio.h"
#include "board.h" #include "board.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/uart.h" #include "driver/uart.h"
#include "dtmf.h" #include "dtmf.h"
#include "frequencies.h" #include "frequencies.h"
@ -959,6 +961,10 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
return; return;
} }
// suppress audio click
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false;
Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0); Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0);
if (Next == 0xFF) if (Next == 0xFF)
return; return;
@ -992,10 +998,18 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
return; return;
} }
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false;
// jump to the next channel // jump to the next channel
APP_channel_next(false, Direction); APP_channel_next(false, Direction);
g_scan_pause_10ms = 0; // go NOW // go NOW
g_scan_pause_10ms = 0;
g_scan_pause_time_mode = false;
g_squelch_open = false;
g_rx_reception_mode = RX_MODE_NONE;
FUNCTION_Select(FUNCTION_FOREGROUND);
g_ptt_was_released = true; g_ptt_was_released = true;
} }

View File

@ -1931,7 +1931,7 @@ void BK4819_start_fsk_rx(const unsigned int packet_size)
void BK4819_PlayRogerMDC1200(void) void BK4819_PlayRogerMDC1200(void)
{ {
uint16_t fsk_reg59; uint16_t fsk_reg59;
uint8_t packet[40]; uint8_t packet[42];
const uint8_t op = MDC1200_OP_CODE_POST_ID; const uint8_t op = MDC1200_OP_CODE_POST_ID;
const uint8_t arg = 0x80; const uint8_t arg = 0x80;

BIN
firmware.bin Normal file

Binary file not shown.

BIN
firmware.packed.bin Normal file

Binary file not shown.

View File

@ -2,19 +2,16 @@
#include <string.h> #include <string.h>
#include "bsp/dp32g030/crc.h" #include "bsp/dp32g030/crc.h"
#include "driver/uart.h"
#include "mdc1200.h" #include "mdc1200.h"
#include "misc.h" #include "misc.h"
// MDC1200 sync bit reversals and packet magic // MDC1200 sync bit reversals and packet sync
// //
// 24-bit pre-amble // 24-bit pre-amble
// 40-bit sync // 40-bit sync
// //
//static const uint8_t header[] = {0x00, 0x00, 0x05, 0x55, 0x55, 0x55, 0x55, 0x07, 0x09, 0x2a, 0x44, 0x6f}; static const uint8_t header[] = {0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x07, 0x09, 0x2a, 0x44, 0x6f};
//static const uint8_t header[] = {0x00, 0x00, 0x0A, 0xAA, 0xAA, 0xAA, 0xAA, 0x07, 0x09, 0x2a, 0x44, 0x6f};
//
//static const uint8_t header[] = {0x00, 0x00, 0x0A, 0xAA, 0xAA, 0xAA, 0xA0, 0xb6, 0x8e, 0x03, 0xbb, 0x14};
static const uint8_t header[] = {0x00, 0x00, 0x05, 0x55, 0x55, 0x55, 0x50, 0x29, 0x71, 0xfc, 0x44, 0xeb};
uint8_t bit_reverse_8(uint8_t n) uint8_t bit_reverse_8(uint8_t n)
{ {
@ -263,7 +260,18 @@ uint8_t * encode_data(uint8_t *data)
data[FEC_K + i] = bo; data[FEC_K + i] = bo;
} }
} }
/*
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
{
const unsigned int size = FEC_K * 2;
unsigned int i;
UART_printf("mdc1200 tx1 %u ", size);
for (i = 0; i < size; i++)
UART_printf(" %02X", data[i]);
UART_SendText("\r\n");
}
#endif
*/
{ // interleave the bits { // interleave the bits
unsigned int i; unsigned int i;
@ -285,7 +293,7 @@ uint8_t * encode_data(uint8_t *data)
} }
} }
// copy the interleaved bits back to the input/output buffer // 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 < (FEC_K * 2); i++)
{ {
int bit_num; int bit_num;
@ -301,22 +309,22 @@ uint8_t * encode_data(uint8_t *data)
} }
void delta_modulation(uint8_t *data, const unsigned int size) void delta_modulation(uint8_t *data, const unsigned int size)
{ // xor succesive bits in the entire packet, including the bit reversing pre-amble { // exclusive-or succesive bits
uint8_t b1;
unsigned int i; unsigned int i;
for (i = 0, b1 = 1u; i < size; i++) uint8_t prev_bit = 0;
for (i = 0; i < size; i++)
{ {
int bit_num; int bit_num;
uint8_t in = data[i]; uint8_t in = data[i];
uint8_t out = 0; uint8_t out = 0;
for (bit_num = 7; bit_num >= 0; bit_num--) for (bit_num = 7; bit_num >= 0; bit_num--)
{ {
const uint8_t b2 = (in >> bit_num) & 1u; const uint8_t new_bit = (in >> bit_num) & 1u;
if (b1 != b2) if (new_bit != prev_bit)
out |= 1u << bit_num; // previous bit and new bit are different out |= 1u << bit_num; // previous bit and new bit are different - send a '1'
b1 = b2; prev_bit = new_bit;
} }
data[i] = out; data[i] = out ^ 0xff;
} }
} }
@ -340,18 +348,18 @@ unsigned int MDC1200_encode_single_packet(uint8_t *data, const uint8_t op, const
p = encode_data(p); p = encode_data(p);
#if 0
{ // test packet
//
// 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); size = (unsigned int)(p - data);
/*
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
{
unsigned int i;
UART_printf("mdc1200 tx2 %u ", size);
for (i = 0; i < size; i++)
UART_printf(" %02X", data[i]);
UART_SendText("\r\n");
}
#endif
*/
delta_modulation(data, size); delta_modulation(data, size);
return size; return size;