Add core firmware modules: input, menu, NRF24L01, OLED, protocol, PWM, storage + UI assets

This commit is contained in:
root
2026-06-25 22:55:41 +08:00
parent 97ab93e93d
commit 5c0ff0ce63
22 changed files with 3671 additions and 17 deletions

52
Core/Inc/protocol.h Normal file
View File

@@ -0,0 +1,52 @@
/**
* 协议层: 遥控信号打包/解包、SBUS 解析、USB HID Joystick
* 统一管理 NRF24/CRFS/SBUS/USB 四种协议的数据流
*/
#ifndef PROTOCOL_H
#define PROTOCOL_H
#include "main.h"
#include "nrf24l01.h"
#include "storage.h"
#include "menu.h"
/* 数据包结构 (NRF24 协议) */
#define RF_PACKET_SIZE 32
#define RF_HEADER_SIZE 6
/* 数据包头 */
#define RF_SYNC_BYTE0 0xAA
#define RF_SYNC_BYTE1 0x55
/* SBUS 帧结构 */
#define SBUS_FRAME_SIZE 25
#define SBUS_BAUDRATE 100000
/* USB HID 报告大小 */
#define HID_REPORT_SIZE 16
/* 函数声明 */
void Protocol_Init(void);
/* RF 协议 */
void Protocol_SendRFPacket(void); /* 发送 NRF24 数据包 */
void Protocol_ProcessRF(void); /* 处理 RF 收发 */
/* SBUS 输入 */
void Protocol_SBUS_Init(void);
uint8_t Protocol_SBUS_Parse(const uint8_t *frame, int16_t *channels);
/* USB HID Joystick */
void Protocol_HID_Init(void);
void Protocol_HID_Send(void); /* 发送 HID 报告 */
/* 主循环调用 */
void Protocol_Run(void);
/* 回传数据 */
extern uint16_t telem_voltage; /* 电压 (mV) */
extern uint8_t telem_rssi; /* RSSI */
extern uint8_t telem_packet_loss; /* 丢包率 */
extern uint16_t telem_temp; /* 温度 */
#endif /* PROTOCOL_H */