1
mirror of https://github.com/egzumer/uv-k5-firmware-custom.git synced 2025-12-12 12:41:21 +04:00
Files
uv-k5-firmware-custom/debugging.h

39 lines
783 B
C
Raw Permalink Normal View History

2023-10-28 11:12:37 +02:00
#ifndef DEBUGGING_H
#define DEBUGGING_H
#ifdef ENABLE_UART
2023-10-28 11:12:37 +02:00
#include "driver/uart.h"
2023-11-30 23:54:26 +01:00
#include "driver/bk4819.h"
2023-10-28 11:12:37 +02:00
#include "string.h"
#include "external/printf/printf.h"
2023-12-05 23:13:21 +01:00
#include "am_fix.h"
2023-10-28 11:12:37 +02:00
static inline void LogUart(const char *const str)
2023-10-28 11:12:37 +02:00
{
UART_Send(str, strlen(str));
2023-10-28 11:12:37 +02:00
}
2023-11-30 23:54:26 +01:00
static inline void LogRegUart(uint16_t reg)
{
uint16_t regVal = BK4819_ReadRegister(reg);
char buf[32];
sprintf(buf, "reg%02X: %04X\n", reg, regVal);
LogUart(buf);
2023-11-30 23:54:26 +01:00
}
2023-10-28 11:12:37 +02:00
2023-12-01 02:12:46 +01:00
static inline void LogPrint()
{
uint16_t rssi = BK4819_GetRSSI();
uint16_t reg7e = BK4819_ReadRegister(0x7E);
char buf[32];
sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", (reg7e >> 15),
(reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111,
(reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi);
LogUart(buf);
2023-12-01 02:12:46 +01:00
}
2023-10-28 11:12:37 +02:00
#endif
#endif