Read/write BK4819 regs through UART
This commit is contained in:
4
Makefile
4
Makefile
@@ -49,6 +49,7 @@ ENABLE_SCAN_RANGES ?= 1
|
|||||||
# ---- DEBUGGING ----
|
# ---- DEBUGGING ----
|
||||||
ENABLE_AM_FIX_SHOW_DATA ?= 0
|
ENABLE_AM_FIX_SHOW_DATA ?= 0
|
||||||
ENABLE_AGC_SHOW_DATA ?= 0
|
ENABLE_AGC_SHOW_DATA ?= 0
|
||||||
|
ENABLE_UART_RW_BK_REGS ?= 0
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
@@ -369,6 +370,9 @@ endif
|
|||||||
ifeq ($(ENABLE_FLASHLIGHT),1)
|
ifeq ($(ENABLE_FLASHLIGHT),1)
|
||||||
CFLAGS += -DENABLE_FLASHLIGHT
|
CFLAGS += -DENABLE_FLASHLIGHT
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(ENABLE_UART_RW_BK_REGS),1)
|
||||||
|
CFLAGS += -DENABLE_UART_RW_BK_REGS
|
||||||
|
endif
|
||||||
|
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld -Wl,--gc-sections
|
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld -Wl,--gc-sections
|
||||||
|
53
app/uart.c
53
app/uart.c
@@ -395,6 +395,11 @@ static void CMD_052D(const uint8_t *pBuffer)
|
|||||||
SendReply(&Reply, sizeof(Reply));
|
SendReply(&Reply, sizeof(Reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// session init, sends back version info and state
|
||||||
|
// timestamp is a session id really
|
||||||
|
// this command also disables dual watch, crossband,
|
||||||
|
// DTMF side tones, freq reverse, PTT ID, DTMF decoding, frequency offset
|
||||||
|
// exits power save, sets main VFO to upper,
|
||||||
static void CMD_052F(const uint8_t *pBuffer)
|
static void CMD_052F(const uint8_t *pBuffer)
|
||||||
{
|
{
|
||||||
const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer;
|
const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer;
|
||||||
@@ -429,6 +434,44 @@ static void CMD_052F(const uint8_t *pBuffer)
|
|||||||
SendVersion();
|
SendVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UART_RW_BK_REGS
|
||||||
|
static void CMD_0601_ReadBK4819Reg(const uint8_t *pBuffer)
|
||||||
|
{
|
||||||
|
typedef struct __attribute__((__packed__)) {
|
||||||
|
Header_t header;
|
||||||
|
uint8_t reg;
|
||||||
|
} CMD_0601_t;
|
||||||
|
|
||||||
|
CMD_0601_t *cmd = (CMD_0601_t*) pBuffer;
|
||||||
|
|
||||||
|
struct __attribute__((__packed__)) {
|
||||||
|
Header_t header;
|
||||||
|
struct {
|
||||||
|
uint8_t reg;
|
||||||
|
uint16_t value;
|
||||||
|
} data;
|
||||||
|
} reply;
|
||||||
|
|
||||||
|
reply.header.ID = 0x0601;
|
||||||
|
reply.header.Size = sizeof(reply.data);
|
||||||
|
reply.data.reg = cmd->reg;
|
||||||
|
reply.data.value = BK4819_ReadRegister(cmd->reg);
|
||||||
|
SendReply(&reply, sizeof(reply));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CMD_0602_WriteBK4819Reg(const uint8_t *pBuffer)
|
||||||
|
{
|
||||||
|
typedef struct __attribute__((__packed__)) {
|
||||||
|
Header_t header;
|
||||||
|
uint8_t reg;
|
||||||
|
uint16_t value;
|
||||||
|
} CMD_0602_t;
|
||||||
|
|
||||||
|
CMD_0602_t *cmd = (CMD_0602_t*) pBuffer;
|
||||||
|
BK4819_WriteRegister(cmd->reg, cmd->value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool UART_IsCommandAvailable(void)
|
bool UART_IsCommandAvailable(void)
|
||||||
{
|
{
|
||||||
uint16_t Index;
|
uint16_t Index;
|
||||||
@@ -567,5 +610,15 @@ void UART_HandleCommand(void)
|
|||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef ENABLE_UART_RW_BK_REGS
|
||||||
|
case 0x0601:
|
||||||
|
CMD_0601_ReadBK4819Reg(UART_Command.Buffer);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x0602:
|
||||||
|
CMD_0602_WriteBK4819Reg(UART_Command.Buffer);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user