feat: 添加CDC协议通信模块支持
- 集成nanopb库用于protobuf序列化 - 创建cdc_wrapper_module.c实现帧解析功能 - 实现protocol_module.c处理协议编解码 - 定义device_comm.proto通信协议 - 修改CMakeLists.txt添加protobuf源文件 - 更新配置启用NANOPB支持 - 移除usb_cdc_module中基于行的处理逻辑
This commit is contained in:
12
inc/cdc_wrapper_module.h
Normal file
12
inc/cdc_wrapper_module.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef BLINKY_CDC_WRAPPER_MODULE_H_
|
||||
#define BLINKY_CDC_WRAPPER_MODULE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLINKY_CDC_WRAPPER_MODULE_H_ */
|
||||
26
inc/protocol_module.h
Normal file
26
inc/protocol_module.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef BLINKY_PROTOCOL_MODULE_H_
|
||||
#define BLINKY_PROTOCOL_MODULE_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CDC_PROTO_TYPE_HELLO_REQ 0x01U
|
||||
#define CDC_PROTO_TYPE_HELLO_RSP 0x02U
|
||||
|
||||
int protocol_module_process_cdc_packet(uint8_t req_type,
|
||||
const uint8_t *req_payload,
|
||||
size_t req_payload_len,
|
||||
uint8_t *rsp_type,
|
||||
uint8_t *rsp_payload,
|
||||
size_t rsp_payload_buf_size,
|
||||
size_t *rsp_payload_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLINKY_PROTOCOL_MODULE_H_ */
|
||||
Reference in New Issue
Block a user