0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

fixed my bots

This commit is contained in:
OneOfEleven 2023-10-25 14:19:18 +01:00
parent 6e8d4b6b17
commit c51a002905
10 changed files with 87 additions and 77 deletions

View File

@ -12,7 +12,7 @@ ENABLE_OVERLAY := 0
ENABLE_LTO := 1 ENABLE_LTO := 1
# UART Programming 2.9 kB # UART Programming 2.9 kB
ENABLE_UART := 1 ENABLE_UART := 1
ENABLE_UART_DEBUG := 0 ENABLE_UART_DEBUG := 1
# AirCopy 2.5 kB # AirCopy 2.5 kB
ENABLE_AIRCOPY := 1 ENABLE_AIRCOPY := 1
ENABLE_AIRCOPY_REMEMBER_FREQ := 1 ENABLE_AIRCOPY_REMEMBER_FREQ := 1

View File

@ -945,8 +945,7 @@ void BOARD_fetchChannelName(char *s, const int channel)
if (!RADIO_CheckValidChannel(channel, false, 0)) if (!RADIO_CheckValidChannel(channel, false, 0))
return; return;
EEPROM_ReadBuffer(0x0F50 + (channel * 16), s + 0, 8); EEPROM_ReadBuffer(0x0F50 + (channel * 16), s, 10);
EEPROM_ReadBuffer(0x0F58 + (channel * 16), s + 8, 2);
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
if (s[i] < 32 || s[i] > 127) if (s[i] < 32 || s[i] > 127)

View File

@ -20,26 +20,40 @@
void CRC_Init(void) void CRC_Init(void)
{ {
CRC_CR = CRC_CR =
CRC_CR_CRC_EN_BITS_DISABLE CRC_CR_CRC_EN_BITS_DISABLE |
| CRC_CR_INPUT_REV_BITS_NORMAL CRC_CR_INPUT_REV_BITS_NORMAL |
| CRC_CR_INPUT_INV_BITS_NORMAL CRC_CR_INPUT_INV_BITS_NORMAL |
| CRC_CR_OUTPUT_REV_BITS_NORMAL CRC_CR_OUTPUT_REV_BITS_NORMAL |
| CRC_CR_OUTPUT_INV_BITS_NORMAL CRC_CR_OUTPUT_INV_BITS_NORMAL |
| CRC_CR_DATA_WIDTH_BITS_8 CRC_CR_DATA_WIDTH_BITS_8 |
| CRC_CR_CRC_SEL_BITS_CRC_16_CCITT; CRC_CR_CRC_SEL_BITS_CRC_16_CCITT;
CRC_IV = 0; CRC_IV = 0;
} }
uint16_t CRC_Calculate(const void *pBuffer, uint16_t Size) void CRC_InitReverse(void)
{ {
const uint8_t *data = (const uint8_t *)pBuffer; CRC_CR =
CRC_CR_CRC_EN_BITS_DISABLE |
CRC_CR_INPUT_REV_BITS_REVERSED |
CRC_CR_INPUT_INV_BITS_NORMAL |
CRC_CR_OUTPUT_REV_BITS_REVERSED |
CRC_CR_OUTPUT_INV_BITS_NORMAL |
CRC_CR_DATA_WIDTH_BITS_8 |
CRC_CR_CRC_SEL_BITS_CRC_16_CCITT;
CRC_IV = 0;
}
uint16_t CRC_Calculate(const void *buffer, const unsigned int size)
{
const uint8_t *data = (const uint8_t *)buffer;
uint16_t i; uint16_t i;
uint16_t crc; uint16_t crc;
CRC_CR = (CRC_CR & ~CRC_CR_CRC_EN_MASK) | CRC_CR_CRC_EN_BITS_ENABLE; CRC_CR = (CRC_CR & ~CRC_CR_CRC_EN_MASK) | CRC_CR_CRC_EN_BITS_ENABLE;
for (i = 0; i < Size; i++) for (i = 0; i < size; i++)
CRC_DATAIN = data[i]; CRC_DATAIN = data[i];
crc = (uint16_t)CRC_DATAOUT; crc = (uint16_t)CRC_DATAOUT;

View File

@ -20,7 +20,8 @@
#include <stdint.h> #include <stdint.h>
void CRC_Init(void); void CRC_Init(void);
uint16_t CRC_Calculate(const void *pBuffer, uint16_t Size); void CRC_InitReverse(void);
uint16_t CRC_Calculate(const void *buffer, const unsigned int size);
#endif #endif

Binary file not shown.

Binary file not shown.

View File

@ -2,6 +2,7 @@
#include <string.h> #include <string.h>
#include "bsp/dp32g030/crc.h" #include "bsp/dp32g030/crc.h"
#include "driver/crc.h"
#include "driver/uart.h" #include "driver/uart.h"
#include "mdc1200.h" #include "mdc1200.h"
#include "misc.h" #include "misc.h"
@ -30,7 +31,7 @@ uint16_t bit_reverse_16(uint16_t n)
n = ((n >> 8) & 0x00FFu) | ((n << 8) & 0xFF00u); n = ((n >> 8) & 0x00FFu) | ((n << 8) & 0xFF00u);
return n; return n;
} }
/*
uint32_t bit_reverse_32(uint32_t n) uint32_t bit_reverse_32(uint32_t n)
{ {
n = ((n >> 1) & 0x55555555u) | ((n << 1) & 0xAAAAAAAAu); n = ((n >> 1) & 0x55555555u) | ((n << 1) & 0xAAAAAAAAu);
@ -40,22 +41,12 @@ uint32_t bit_reverse_32(uint32_t n)
n = ((n >> 16) & 0x0000FFFFu) | ((n << 16) & 0xFFFF0000u); n = ((n >> 16) & 0x0000FFFFu) | ((n << 16) & 0xFFFF0000u);
return n; return n;
} }
*/
uint16_t reverse_bits(const uint16_t bits_in, const unsigned int num_bits) // ************************************
{
uint16_t i; #if 0
uint16_t bit;
uint16_t bits_out;
for (i = 1u << (num_bits - 1), bit = 1u, bits_out = 0u; i != 0; i >>= 1)
{
if (bits_in & i)
bits_out |= bit;
bit <<= 1;
}
return bits_out;
}
#if 1
uint16_t compute_crc(const uint8_t *data, const unsigned int data_len) uint16_t compute_crc(const uint8_t *data, const unsigned int data_len)
{ // using the reverse computation avoids having to reverse the bit order during and after { // using the reverse computation avoids having to reverse the bit order during and after
unsigned int i; unsigned int i;
@ -70,40 +61,45 @@ uint16_t reverse_bits(const uint16_t bits_in, const unsigned int num_bits)
crc ^= 0xffff; crc ^= 0xffff;
return crc; return crc;
} }
#else
#elif 1
uint16_t compute_crc(const uint8_t *data, const unsigned int data_len) 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; unsigned int i;
#if 0
uint16_t crc; uint16_t crc;
// CRC_InitReverse();
CRC_CR = (CRC_CR & ~CRC_CR_CRC_EN_MASK) | CRC_CR_CRC_EN_BITS_ENABLE; CRC_CR = (CRC_CR & ~CRC_CR_CRC_EN_MASK) | CRC_CR_CRC_EN_BITS_ENABLE;
for (i = 0; i < data_len; i++)
//CRC_DATAIN = data[i];
CRC_DATAIN = bit_reverse_8(data[i]);
crc = CRC_DATAOUT;
CRC_CR = (CRC_CR & ~CRC_CR_CRC_EN_MASK) | CRC_CR_CRC_EN_BITS_DISABLE;
// CRC_Init();
// bit reverse and invert the final CRC
//return crc ^ 0xffff;
return bit_reverse_16(crc) ^ 0xffff;
}
#else #else
uint16_t compute_crc(const uint8_t *data, const unsigned int data_len)
{
unsigned int i;
uint16_t crc = 0; uint16_t crc = 0;
#endif
for (i = 0; i < data_len; i++) 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; uint8_t mask;
// bit reverse each data byte before adding it to the CRC // bit reverse each data byte
// the cortex CPU might have an instruction to bit reverse for us ? const uint8_t bits = bit_reverse_8(*data++);
//
const uint8_t bits = reverse_bits(data[i], 8);
//const uint8_t bits = bit_reverse_8(*data++);
for (mask = 0x0080; mask != 0; mask >>= 1) for (mask = 0x0080; mask != 0; mask >>= 1)
{ {
@ -114,20 +110,16 @@ uint16_t reverse_bits(const uint16_t bits_in, const unsigned int num_bits)
if (msb) if (msb)
crc ^= 0x1021; crc ^= 0x1021;
} }
#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 // bit reverse and invert the final CRC
return reverse_bits(crc, 16) ^ 0xffff; return bit_reverse_16(crc) ^ 0xffff;
// return bit_reverse_16(crc) ^ 0xffff;
} }
#endif #endif
// ************************************
#define FEC_K 7 #define FEC_K 7
void error_correction(uint8_t *data) void error_correction(uint8_t *data)
@ -277,7 +269,10 @@ uint8_t * encode_data(uint8_t *data)
data[FEC_K + i] = bo; data[FEC_K + i] = bo;
} }
} }
/*
// 01 80 00 23 31 FC 00 65 80 32 0F 99 86 23
// 01 80 00 23 31 FC 00 65 80 32 0F 99 86 23
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
{ {
const unsigned int size = FEC_K * 2; const unsigned int size = FEC_K * 2;
@ -288,7 +283,7 @@ uint8_t * encode_data(uint8_t *data)
UART_SendText("\r\n"); UART_SendText("\r\n");
} }
#endif #endif
*/
{ // interleave the bits { // interleave the bits
unsigned int i; unsigned int i;

View File

@ -1128,7 +1128,7 @@ void RADIO_tx_eot(void)
#ifdef ENABLE_MDC1200 #ifdef ENABLE_MDC1200
if (g_eeprom.roger_mode == ROGER_MODE_MDC) if (g_eeprom.roger_mode == ROGER_MODE_MDC)
{ {
BK4819_send_MDC1200(MDC1200_OP_CODE_POST_ID, 0x80, g_eeprom.mdc1200_id); BK4819_send_MDC1200(MDC1200_OP_CODE_POST_ID, 0x00, g_eeprom.mdc1200_id);
} }
else else
#endif #endif

View File

@ -783,7 +783,7 @@ void UI_DisplayMain(void)
UI_PrintStringSmallest(str, x, (line + 0) * 8, false, true); UI_PrintStringSmallest(str, x, (line + 0) * 8, false, true);
} }
} }
x += smallest_char_spacing * 4; x += (smallest_char_spacing * 4) - 1;
if (g_eeprom.vfo_info[vfo_num].compand) if (g_eeprom.vfo_info[vfo_num].compand)
UI_PrintStringSmallest("C", x, (line + 0) * 8, false, true); UI_PrintStringSmallest("C", x, (line + 0) * 8, false, true);

View File

@ -1237,6 +1237,7 @@ void UI_DisplayMenu(void)
UI_PrintString(str, sub_menu_x1, sub_menu_x2, 0, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 0, 8);
// channel name // channel name
memset(str, 0, sizeof(str));
BOARD_fetchChannelName(str, g_sub_menu_selection); BOARD_fetchChannelName(str, g_sub_menu_selection);
if (str[0] == 0) if (str[0] == 0)
strcpy(str, "--"); strcpy(str, "--");