mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
fixed my bots
This commit is contained in:
parent
6e8d4b6b17
commit
c51a002905
2
Makefile
2
Makefile
@ -12,7 +12,7 @@ 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 := 1
|
||||
ENABLE_AIRCOPY_REMEMBER_FREQ := 1
|
||||
|
3
board.c
3
board.c
@ -945,8 +945,7 @@ void BOARD_fetchChannelName(char *s, const int channel)
|
||||
if (!RADIO_CheckValidChannel(channel, false, 0))
|
||||
return;
|
||||
|
||||
EEPROM_ReadBuffer(0x0F50 + (channel * 16), s + 0, 8);
|
||||
EEPROM_ReadBuffer(0x0F58 + (channel * 16), s + 8, 2);
|
||||
EEPROM_ReadBuffer(0x0F50 + (channel * 16), s, 10);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
if (s[i] < 32 || s[i] > 127)
|
||||
|
34
driver/crc.c
34
driver/crc.c
@ -20,26 +20,40 @@
|
||||
void CRC_Init(void)
|
||||
{
|
||||
CRC_CR =
|
||||
CRC_CR_CRC_EN_BITS_DISABLE
|
||||
| CRC_CR_INPUT_REV_BITS_NORMAL
|
||||
| CRC_CR_INPUT_INV_BITS_NORMAL
|
||||
| CRC_CR_OUTPUT_REV_BITS_NORMAL
|
||||
| CRC_CR_OUTPUT_INV_BITS_NORMAL
|
||||
| CRC_CR_DATA_WIDTH_BITS_8
|
||||
| CRC_CR_CRC_SEL_BITS_CRC_16_CCITT;
|
||||
CRC_CR_CRC_EN_BITS_DISABLE |
|
||||
CRC_CR_INPUT_REV_BITS_NORMAL |
|
||||
CRC_CR_INPUT_INV_BITS_NORMAL |
|
||||
CRC_CR_OUTPUT_REV_BITS_NORMAL |
|
||||
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 *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 crc;
|
||||
|
||||
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 = (uint16_t)CRC_DATAOUT;
|
||||
|
||||
|
@ -20,7 +20,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
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
|
||||
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
87
mdc1200.c
87
mdc1200.c
@ -2,6 +2,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "bsp/dp32g030/crc.h"
|
||||
#include "driver/crc.h"
|
||||
#include "driver/uart.h"
|
||||
#include "mdc1200.h"
|
||||
#include "misc.h"
|
||||
@ -30,7 +31,7 @@ uint16_t bit_reverse_16(uint16_t n)
|
||||
n = ((n >> 8) & 0x00FFu) | ((n << 8) & 0xFF00u);
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
uint32_t bit_reverse_32(uint32_t n)
|
||||
{
|
||||
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);
|
||||
return n;
|
||||
}
|
||||
*/
|
||||
|
||||
uint16_t reverse_bits(const uint16_t bits_in, const unsigned int num_bits)
|
||||
{
|
||||
uint16_t i;
|
||||
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 0
|
||||
|
||||
#if 1
|
||||
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
|
||||
unsigned int i;
|
||||
@ -70,40 +61,45 @@ uint16_t reverse_bits(const uint16_t bits_in, const unsigned int num_bits)
|
||||
crc ^= 0xffff;
|
||||
return crc;
|
||||
}
|
||||
#else
|
||||
|
||||
#elif 1
|
||||
|
||||
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_InitReverse();
|
||||
|
||||
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
|
||||
|
||||
uint16_t compute_crc(const uint8_t *data, const unsigned int data_len)
|
||||
{
|
||||
unsigned int i;
|
||||
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++);
|
||||
// bit reverse each data byte
|
||||
const uint8_t bits = bit_reverse_8(*data++);
|
||||
|
||||
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)
|
||||
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
|
||||
return reverse_bits(crc, 16) ^ 0xffff;
|
||||
// return bit_reverse_16(crc) ^ 0xffff;
|
||||
return bit_reverse_16(crc) ^ 0xffff;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************
|
||||
|
||||
#define FEC_K 7
|
||||
|
||||
void error_correction(uint8_t *data)
|
||||
@ -277,7 +269,10 @@ uint8_t * encode_data(uint8_t *data)
|
||||
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)
|
||||
{
|
||||
const unsigned int size = FEC_K * 2;
|
||||
@ -288,7 +283,7 @@ uint8_t * encode_data(uint8_t *data)
|
||||
UART_SendText("\r\n");
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
{ // interleave the bits
|
||||
|
||||
unsigned int i;
|
||||
|
2
radio.c
2
radio.c
@ -1128,7 +1128,7 @@ void RADIO_tx_eot(void)
|
||||
#ifdef ENABLE_MDC1200
|
||||
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
|
||||
#endif
|
||||
|
@ -783,7 +783,7 @@ void UI_DisplayMain(void)
|
||||
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)
|
||||
UI_PrintStringSmallest("C", x, (line + 0) * 8, false, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user