93 lines
2.5 KiB
C
93 lines
2.5 KiB
C
/****************************************************************************
|
|
文件名称 : chrg_north.h
|
|
完成日期 :
|
|
当前版本号 : V1.0
|
|
主要功能 : 实现北向通信交互,包括接收命令解析,发送请求命令,切换通路。以独立线程处理。
|
|
版本历史 : 创建原始版本
|
|
说明 :
|
|
******************************************************************************/
|
|
|
|
#ifndef __CHRG_NORTH_H__
|
|
#define __CHRG_NORTH_H__
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include "chrg_tty.h"
|
|
#include "chrg_source.h"
|
|
#include "chrg_sink.h"
|
|
#include "chrg_def.h"
|
|
|
|
#define THR_NAME_NORTH "thr.nor"
|
|
#define DEV_NAME_NORTH "uart3"
|
|
|
|
#define LEN_FRAME_HEAD (3) // [帧长, 0x00, id]
|
|
#define MIN_FRAME_LENGTH (5) // 帧最短5字节
|
|
|
|
// 北向4通路索引 U14 ->
|
|
typedef enum {
|
|
IDX_NOR_CH1 = IDX_CH1, // J3
|
|
IDX_NOR_CH2 = IDX_CH2, // J4
|
|
IDX_NOR_CH3 = IDX_CH3, // J9
|
|
IDX_NOR_CH4 = IDX_CH4, // J10
|
|
|
|
TOTAL_NOR_CHS
|
|
} eIDX_NOR_CH;
|
|
|
|
|
|
struct chrg_switch_t {
|
|
eIDX_ID id;
|
|
struct chrg_src_t source;
|
|
struct chrg_sink_t sink;
|
|
};
|
|
|
|
struct chrg_north_t {
|
|
const char *devname;
|
|
|
|
struct chrg_tty_t *tty;
|
|
struct rt_ringbuffer *rb;
|
|
struct pickup_info_t frame;
|
|
|
|
rt_uint8_t rx_buf[SIZE_BUF_TTY];
|
|
|
|
rt_uint8_t enable[TOTAL_NOR_CHS]; // 通路使能
|
|
rt_uint8_t manual; // 手动插入命令
|
|
eIDX_NOR_CH idx; // 当前通路
|
|
struct chrg_switch_t sw[TOTAL_NOR_CHS];
|
|
};
|
|
|
|
extern struct chrg_north_t chrgnorth;
|
|
|
|
/*****************************************************************
|
|
函数名称: chrg_north_switch
|
|
函数描述: 北向通道选择
|
|
输入参数: ch: 北向通道
|
|
输出参数: -
|
|
返回说明: <0: 错误
|
|
其它说明: -
|
|
*****************************************************************/
|
|
extern int chrg_north_switch (eIDX_NOR_CH ch);
|
|
|
|
/*****************************************************************
|
|
函数名称: chrg_north_send
|
|
函数描述: 北向通道数据发送
|
|
输入参数: *data: 数据 length: 数据长度
|
|
输出参数: -
|
|
返回说明: <0: 错误 >0:发送数据长度
|
|
其它说明: -
|
|
*****************************************************************/
|
|
extern int chrg_north_send (rt_uint8_t *data, rt_size_t length);
|
|
|
|
/*****************************************************************
|
|
函数名称: chrg_north_thread_entry
|
|
函数描述: 北向通道数据接收线程体
|
|
输入参数: *data: 本线程信息
|
|
输出参数: -
|
|
返回说明: -
|
|
其它说明: -
|
|
*****************************************************************/
|
|
extern void chrg_north_thread_entry (void *data);
|
|
|
|
#endif
|
|
|
|
|