uv-k5-firmware-chinese-lts/debugging.h

39 lines
804 B
C
Raw Normal View History

2023-12-07 03:39:09 +00:00
#ifndef DEBUGGING_H
#define DEBUGGING_H
2023-12-17 04:23:45 +00:00
#ifdef ENABLE_UART
2023-12-07 03:39:09 +00:00
#include "driver/uart.h"
#include "driver/bk4819.h"
#include "string.h"
2023-12-08 04:22:16 +00:00
#include <stdio.h>
2023-12-07 03:39:09 +00:00
#include "am_fix.h"
2023-12-17 04:23:45 +00:00
static inline void LogUart(const char *const str)
2023-12-07 03:39:09 +00:00
{
2023-12-17 04:23:45 +00:00
UART_Send(str, strlen(str));
2023-12-07 03:39:09 +00:00
}
static inline void LogRegUart(uint16_t reg)
{
2023-12-17 04:23:45 +00:00
uint16_t regVal = BK4819_ReadRegister(reg);
char buf[32];
sprintf(buf, "reg%02X: %04X\n", reg, regVal);
LogUart(buf);
2023-12-07 03:39:09 +00:00
}
static inline void LogPrint()
{
2023-12-17 04:23:45 +00:00
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-07 03:39:09 +00:00
}
2023-12-17 04:23:45 +00:00
#endif
2023-11-30 06:38:27 +00:00
#endif