73 lines
1.5 KiB
C
73 lines
1.5 KiB
C
#ifndef transmit_h__
|
|
#define transmit_h__
|
|
|
|
#include "rtthread.h"
|
|
#include "handle.h"
|
|
#include "signal.h"
|
|
|
|
|
|
|
|
// 错误码定义
|
|
#define TRAN_ERR_NONE 0x00
|
|
#define TRAN_ERR_BUSY 0x01
|
|
#define TRAN_ERR_PARAM 0x02
|
|
#define TRAN_ERR_STEP 0x03
|
|
|
|
|
|
|
|
|
|
|
|
struct _tran_def;
|
|
typedef struct _tran_def tran_def;
|
|
|
|
typedef struct _ucport_def{
|
|
uint8_t cmd;
|
|
tran_def *p;
|
|
int (*dolater)(struct _ucport_def *u,uint8_t cmd,array_def *data,char *err_str);
|
|
void (*del)(struct _ucport_def *h);
|
|
void (*doend)(struct _ucport_def *h,port_mcu *src,void *data,int ack,char *err_str);
|
|
}ucport_def;
|
|
|
|
|
|
typedef struct{
|
|
ucport_def *(*creat)(tran_def *t,uint8_t cmd,array_def *data);
|
|
uint8_t cmd;
|
|
const char *codec_name;
|
|
}ucport_item;
|
|
|
|
|
|
|
|
|
|
#define transmit_export(codec_name_,cmd_,fun_) \
|
|
const static char __tran_##codec_name_##cmd_##_name[] SECTION(".rodata.transtr") = #codec_name_; \
|
|
RT_USED static ucport_item _tran_##cmd_ SECTION("transtruct")= \
|
|
{\
|
|
.cmd=cmd_,\
|
|
.creat=fun_,\
|
|
.codec_name=__tran_##codec_name_##cmd_##_name,\
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
tran_def *tran_creat(sig_thread t);
|
|
|
|
void tran_recv_slot(tran_def *t,const char *codec_name,uint8_t cmd,array_def *data,char *err_str);
|
|
|
|
void tran_set_busy(tran_def *t,int busy);
|
|
int tran_get_busy(tran_def *t);
|
|
port_mcu *tran_get_portm(tran_def *t,int index);
|
|
uint32_t tran_get_slave_online(tran_def *t);
|
|
|
|
|
|
signal tran_reply_signal(tran_def *p,array_def *data);
|
|
signal tran_send_signal(tran_def *p,uint8_t cmd,array_def *data);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|