feat: 移植从机通信帧协议
This commit is contained in:
32
app/tiny_frame/by_tiny_frame_parse.h
Normal file
32
app/tiny_frame/by_tiny_frame_parse.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _BY_TINY_FRAME_PARSE_H__
|
||||
#define _BY_TINY_FRAME_PARSE_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "by_tiny_frame_config.h"
|
||||
|
||||
// 从机地址 (1b) - 功能码 (1b) - 寄存器地址 (2b) - 数据 (4b) - CRC(2b)
|
||||
// 从机地址 (1b) 0-127, 最低位表示发送方,主机请求低位为 0,从机应答低位为 1
|
||||
// 高字节在前
|
||||
|
||||
typedef struct by_tf_parse_frame_t {
|
||||
uint8_t frame[10];
|
||||
uint8_t cmd;
|
||||
uint16_t reg_addr;
|
||||
uint16_t crc_val;
|
||||
uint32_t data;
|
||||
} by_tf_parse_frame_t;
|
||||
|
||||
typedef void (*by_tf_parse_done_handle_func)(by_tf_parse_frame_t, uint8_t);
|
||||
|
||||
extern void by_tiny_frame_parse_init(void);
|
||||
extern void by_tiny_frame_parse_uart_handle(uint8_t buff);
|
||||
extern void by_tiny_frame_parse_run(void);
|
||||
extern uint8_t by_tiny_frame_parse_crc(by_tf_parse_frame_t *frame_s);
|
||||
extern void by_tiny_frame_parse_handle_register(by_tf_parse_done_handle_func func);
|
||||
extern void by_tiny_frame_parse_start_listen(void);
|
||||
extern void by_tiny_frame_parse_end_listen(void);
|
||||
extern void by_tiny_frame_parse_set_listen_slave_id(uint8_t slave_id);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user