Files

34 lines
941 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file sbus.h
* @brief SBUS 协议 (与 LoliCon 遥控器配套)
*
* 私有 NRF24L01 32 字节协议:
* [0] frame_id = FRAME_ID_CHANNELS
* [1] seq
* [2] model_id
* [3] flags
* [4..25] 16 路 SBUS 通道 (11 bit×16 = 22 字节小端位流)
* [26..31] 保留
*
* 标准 SBUS (反向 UART 100k 8E2):
* 25 字节:0x0F + 22 字节通道 + flags + 0x00
*/
#ifndef __SBUS_H
#define __SBUS_H
#include "stc8h.h"
#include <stdint.h>
#include "config.h"
/* 协议帧 ID (与 LoliCon 一致) */
#define FRAME_ID_CHANNELS 0xA0
#define FRAME_ID_TELEMETRY 0xB0
#define FRAME_ID_BIND 0xC0
/* 解包 SBUS 11-bit × 16 通道 → uint16_t[16] (范围 200..1844) */
void sbus_unpack_channels(const uint8_t in[22], uint16_t ch[SBUS_CH_COUNT]);
/* 把 16 路通道打包成标准 SBUS 25 字节帧 */
void sbus_make_uart_frame(const uint16_t ch[SBUS_CH_COUNT], uint8_t out[25]);
#endif