USB2XXX 1.2
USB2XXX接口函数说明文档
载入中...
搜索中...
未找到
usb2sent.h
1
9#ifndef __USB2SENT_H_
10#define __USB2SENT_H_
11
12#include <stdint.h>
13#ifndef OS_UNIX
14#include <Windows.h>
15#else
16#include <unistd.h>
17#ifndef WINAPI
18#define WINAPI
19#endif
20#endif
32#define SENT_SUCCESS (0)
33#define SENT_ERR_NOT_SUPPORT (-1)
34#define SENT_ERR_USB_WRITE_FAIL (-2)
35#define SENT_ERR_USB_READ_FAIL (-3)
36#define SENT_ERR_CMD_FAIL (-4)
37#define SENT_ERR_PARAMETER (-5)
38#define SENT_ERR_MSG_TYPE (-6)
46#define SENT_MASTER 1
47#define SENT_SLAVE 0
48#define SENT_SPC 0x80
49#define SENT_SPC_SLAVE_TX 0x40
58#define SENT_MSGTYPE_ERROR 0
59#define SENT_MSGTYPE_FAST 1
60#define SENT_MSGTYPE_SLOW_SHORT 2
61#define SENT_MSGTYPE_SLOW_ENH1 3
62#define SENT_MSGTYPE_SLOW_ENH2 4
63#define SENT_MSGTYPE_TX 0x80
64#define SENT_MSGTYPE_SPC 0x08
72#define SENT_IDLE_HIGH 1
73#define SENT_IDLE_LOW 0
80typedef struct _SENT_CONFIG
81{
82 unsigned char TicksTimeUs;
83 unsigned char MasterMode;
84 unsigned char LowTicks;
85 unsigned char PausePulseTicks;
86 unsigned char NibbleNum;
87 unsigned char IdleLevel;
88 unsigned char DataFormat;
89 unsigned char SensorType;
97typedef struct _SENT_MSG
98{
99 unsigned int Timestamp;
100 unsigned char TimestampHigh;
101 unsigned char MsgType;
110 unsigned char Status;
111 unsigned char Data[8];
112 unsigned char crc;
113 unsigned short Tmtr;
114 unsigned short Tmlow;
115}SENT_MSG;
121typedef enum
122{
123 H0 = 0,
131 //F.6.1 Data Frames with One Multiplexed Fast Channel and 12-bit Sensor Data
138 //F.6.2 Data Frames with One Multiplexed Fast Channel and 16-bit Sensor Data
143 //F.6.3 Data Frames with Two Multiplexed Fast Channels with Sensor Data
149 //F.6.4 Data Frames with Free to Use Data
158 F4_9
159}SENT_DATA_FORMATS;//参考Table H-1 – Basic SENT frame formats, data channels and nibble orders
161#ifdef __cplusplus
162extern "C"
163{
164#endif
165
175int WINAPI SENT_Init(int DevHandle,unsigned char Channel, SENT_CONFIG* pConfig);
176
186int WINAPI SENT_SetTickTime(int DevHandle, unsigned char Channel, double TickTimeUs);
187
198int WINAPI SENT_SendMsg(int DevHandle, unsigned char Channel, SENT_MSG* pSentMsg, unsigned int MsgNum);
199
211int WINAPI SENT_StartFastMsgTable(int DevHandle, unsigned char Channel, SENT_MSG* pSentMsg, unsigned int MsgNum, unsigned int SendTimes);
212
222int WINAPI SENT_UpdateFastMsgTable(int DevHandle, unsigned char Channel, unsigned char StartMsgIndex,SENT_MSG* pSentMsg, unsigned int MsgNum);
223
232int WINAPI SENT_StopFastMsgTable(int DevHandle, unsigned char Channel);
233
245int WINAPI SENT_StartSPCMsgTable(int DevHandle, unsigned char Channel, SENT_MSG* pSentMsg, unsigned int MsgNum, unsigned int SendTimes);
246
256int WINAPI SENT_UpdateSPCMsgTable(int DevHandle, unsigned char Channel, unsigned char StartMsgIndex,SENT_MSG* pSentMsg, unsigned int MsgNum);
257
266int WINAPI SENT_StopSPCMsgTable(int DevHandle, unsigned char Channel);
267
277int WINAPI SENT_StartSlowMsgTable(int DevHandle, unsigned char Channel, SENT_MSG* pSentMsg, unsigned int MsgNum, unsigned int SendTimes);
278
288int WINAPI SENT_UpdateSlowMsgTable(int DevHandle, unsigned char Channel, unsigned char StartMsgIndex,SENT_MSG* pSentMsg, unsigned int MsgNum);
289
298int WINAPI SENT_StopSlowMsgTable(int DevHandle, unsigned char Channel);
299
308int WINAPI SENT_GetMsg(int DevHandle, unsigned char Channel, SENT_MSG* pSentMsg);
309
319int WINAPI SENT_GetMsgWithSize(int DevHandle, unsigned char Channel, SENT_MSG* pSentMsg, unsigned int BufSize);
320
328long long WINAPI SENT_GetStartTime(int DevHandle, unsigned char Channel);
329
337int WINAPI SENT_ResetStartTime(int DevHandle, unsigned char Channel);
338
346int WINAPI SENT_Stop(int DevHandle, unsigned char Channel);
347
359int WINAPI SENT_MsgDecode(unsigned char DataFormat,SENT_MSG* pSentMsg,int MsgNum,unsigned int *pDataCh1, unsigned int* pDataCh2);
360
374int WINAPI SENT_MsgDecodeEx(unsigned char DataFormat, SENT_MSG* pSentMsg, int MsgNum, unsigned int* pDataCh1, unsigned int* pDataCh2, unsigned char* pFC, unsigned char* pDCC);
375
376#ifdef __cplusplus
377}
378#endif
380#endif
int WINAPI SENT_ResetStartTime(int DevHandle, unsigned char Channel)
复位时间戳,复位后起始时间戳为当前时间
int WINAPI SENT_UpdateSPCMsgTable(int DevHandle, unsigned char Channel, unsigned char StartMsgIndex, SENT_MSG *pSentMsg, unsigned int MsgNum)
更新SENT SPC快速通道发送列表中的帧
int WINAPI SENT_StartSPCMsgTable(int DevHandle, unsigned char Channel, SENT_MSG *pSentMsg, unsigned int MsgNum, unsigned int SendTimes)
设置并启动SENT SPC帧发送列表
int WINAPI SENT_GetMsgWithSize(int DevHandle, unsigned char Channel, SENT_MSG *pSentMsg, unsigned int BufSize)
主机模式获取已发成功发送出去的帧,从机模式获取监控到的帧
int WINAPI SENT_MsgDecodeEx(unsigned char DataFormat, SENT_MSG *pSentMsg, int MsgNum, unsigned int *pDataCh1, unsigned int *pDataCh2, unsigned char *pFC, unsigned char *pDCC)
将快速通道原始SENT数据解析成实际数据,注意只解析快速通道帧数据
int WINAPI SENT_StartFastMsgTable(int DevHandle, unsigned char Channel, SENT_MSG *pSentMsg, unsigned int MsgNum, unsigned int SendTimes)
设置并启动SENT快速通道帧发送列表
int WINAPI SENT_Stop(int DevHandle, unsigned char Channel)
停止SENT总线功能
int WINAPI SENT_StopSlowMsgTable(int DevHandle, unsigned char Channel)
停止正在发送的SENT帧列表
int WINAPI SENT_SetTickTime(int DevHandle, unsigned char Channel, double TickTimeUs)
配置SENT总线Tick时间
int WINAPI SENT_GetMsg(int DevHandle, unsigned char Channel, SENT_MSG *pSentMsg)
主机模式获取已发成功发送出去的帧,从机模式获取监控到的帧
long long WINAPI SENT_GetStartTime(int DevHandle, unsigned char Channel)
获取SENT起始时间戳,该时间戳可以转换成实际的时间
int WINAPI SENT_StopFastMsgTable(int DevHandle, unsigned char Channel)
停止正在发送的SENT帧列表
int WINAPI SENT_Init(int DevHandle, unsigned char Channel, SENT_CONFIG *pConfig)
初始化配置SENT总线,必须调用,否则无法正常工作
SENT_DATA_FORMATS
Definition: usb2sent.h:122
int WINAPI SENT_UpdateFastMsgTable(int DevHandle, unsigned char Channel, unsigned char StartMsgIndex, SENT_MSG *pSentMsg, unsigned int MsgNum)
更新SENT快速通道发送列表中的帧
int WINAPI SENT_UpdateSlowMsgTable(int DevHandle, unsigned char Channel, unsigned char StartMsgIndex, SENT_MSG *pSentMsg, unsigned int MsgNum)
更新慢速通道发送列表中的帧
int WINAPI SENT_MsgDecode(unsigned char DataFormat, SENT_MSG *pSentMsg, int MsgNum, unsigned int *pDataCh1, unsigned int *pDataCh2)
将快速通道原始SENT数据解析成实际数据,注意只解析快速通道帧数据
int WINAPI SENT_StartSlowMsgTable(int DevHandle, unsigned char Channel, SENT_MSG *pSentMsg, unsigned int MsgNum, unsigned int SendTimes)
设置并启动SENT慢速通道帧发送列表,调用该函数后数据不会立即发送,它是在发送快速数据的时候才通过Status域发送,所以需要发送慢速通道帧数据,需要同时启动快速帧发送列表
int WINAPI SENT_SendMsg(int DevHandle, unsigned char Channel, SENT_MSG *pSentMsg, unsigned int MsgNum)
主机模式下手动发送SENT消息
int WINAPI SENT_StopSPCMsgTable(int DevHandle, unsigned char Channel)
停止正在发送的SENT帧列表
@ F4_5
FC=byte[0]
Definition: usb2sent.h:154
@ F3_2
FC=byte[0],CH1=(byte[1]<<6)|(byte[2]<<2)|(byte[3]>>2),CH2=(byte[5]<<6)|(byte[4]<<2)|(byte[3]&0x03)
Definition: usb2sent.h:145
@ F1_1
FC=byte[0],CH1=(byte[1]<<8)|(byte[2]<<4)|byte[3]
Definition: usb2sent.h:132
@ F2_1
FC=byte[0],CH1=(byte[1]<<12)|(byte[2]<<8)|(byte[3]<<4)|byte[4]
Definition: usb2sent.h:139
@ H4
CH1=(byte[0]<<8)|(byte[1]<<4)|byte[2],CH2(Counter)=(byte[3]<<4)|byte[4]
Definition: usb2sent.h:127
@ F1_5
FC=byte[0],DCC=byte[1],CH1=(byte[2]<<8)|(byte[3]<<4)|byte[4]
Definition: usb2sent.h:136
@ F4_2
FC=byte[0]
Definition: usb2sent.h:151
@ F1_2
FC=byte[0],CH1=(byte[1]<<8)|(byte[2]<<4)|byte[3]
Definition: usb2sent.h:133
@ H5
CH1=(byte[0]<<8)|(byte[1]<<4)|byte[2],CH2=0
Definition: usb2sent.h:128
@ F1_4
FC=byte[0],DCC=byte[1],CH1=(byte[2]<<8)|(byte[3]<<4)|byte[4]
Definition: usb2sent.h:135
@ F3_1
FC=byte[0],CH1=(byte[1]<<8)|(byte[2]<<4)|byte[3],CH2=(byte[5]<<4)|byte[4]
Definition: usb2sent.h:144
@ F4_6
FC=byte[0],DCC=byte[1]
Definition: usb2sent.h:155
@ F4_4
FC=byte[0]
Definition: usb2sent.h:153
@ F4_9
FC=byte[0],DCC=byte[1]
Definition: usb2sent.h:158
@ F1_3
FC=byte[0],CH1=(byte[1]<<8)|(byte[2]<<4)|byte[3]
Definition: usb2sent.h:134
@ H1
CH1=(byte[0]<<8)|(byte[1]<<4)|byte[2],CH2=(byte[5]<<8)|(byte[4]<<4)|byte[3]
Definition: usb2sent.h:124
@ F2_4
FC=byte[0],DCC=byte[1],CH1=(byte[2]<<12)|(byte[3]<<8)|(byte[4]<<4)|byte[5]
Definition: usb2sent.h:142
@ F4_7
FC=byte[0],DCC=byte[1]
Definition: usb2sent.h:156
@ F3_5
FC=byte[0],DCC=byte[1],CH1=(byte[2]<<8)|(byte[3]<<4)|byte[4],CH2=(byte[7]<<8)|(byte[6]<<4)|byte[5]
Definition: usb2sent.h:148
@ F3_4
FC=byte[0],CH1=(byte[1]<<10)|(byte[2]<<6)|(byte[3]<<2)|(byte[4]>>2),CH2=(byte[7]<<10)|(byte[6]<<6)|(b...
Definition: usb2sent.h:147
@ F4_3
FC=byte[0]
Definition: usb2sent.h:152
@ H6
CH1=(byte[0]<<10)|(byte[1]<<6)|(byte[2]<<2)|(byte[3]>>2),CH2=(byte[5]<<6)|(byte[4]<<2)|(byte[3]&0x03)
Definition: usb2sent.h:129
@ H7
CH1=(byte[0]<<12)|(byte[1]<<8)|(byte[2]<<4)|byte[3],CH2==(byte[5]<<4)|byte[4]
Definition: usb2sent.h:130
@ H3
CH1=(byte[0]<<9)|(byte[1]<<6)|(byte[2]<<3)|byte[3]
Definition: usb2sent.h:126
@ H2
CH1=(byte[0]<<8)|(byte[1]<<4)|byte[2]
Definition: usb2sent.h:125
@ F4_1
FC=byte[0]
Definition: usb2sent.h:150
@ F1_6
FC=byte[0],DCC=byte[1],CH1=(byte[2]<<8)|(byte[3]<<4)|byte[4]
Definition: usb2sent.h:137
@ F3_3
FC=byte[0],CH1=(byte[1]<<12)|(byte[2]<<8)|(byte[3]<<4)|byte[4],CH2=(byte[7]<<8)|(byte[6]<<4)|byte[5]
Definition: usb2sent.h:146
@ F2_2
FC=byte[0],CH1=(byte[1]<<12)|(byte[2]<<8)|(byte[3]<<4)|byte[4]
Definition: usb2sent.h:140
@ F2_3
FC=byte[0],CH1=(byte[1]<<12)|(byte[2]<<8)|(byte[3]<<4)|byte[4]
Definition: usb2sent.h:141
@ F4_8
FC=byte[0],DCC=byte[1]
Definition: usb2sent.h:157
Definition: usb2sent.h:81
unsigned char MasterMode
0-从机模式,用于监控SENT总线数据,1-主机模式,用于发送SENT总线数据,bit[7]-使能SPC模式,bit[6]-使能SPC从机响应数据模式
Definition: usb2sent.h:83
unsigned char PausePulseTicks
暂停脉冲数,0-不输出,1~64对应12Ticks~768Ticks,0xFF-自动长度,但是最小为12Ticks
Definition: usb2sent.h:85
unsigned char IdleLevel
总线空闲状态,0-空闲低电平,1-空闲高电平
Definition: usb2sent.h:87
unsigned char NibbleNum
快速通道半字节数,不包含CRC,从机模式若是0则自动匹配,主机模式Status高4位代表要发送的有效半字节数
Definition: usb2sent.h:86
unsigned char LowTicks
低电平输出Ticks数,低电平输出时间=TicksTimeUs*LowTicks,推荐设置为5
Definition: usb2sent.h:84
unsigned char TicksTimeUs
Ticks时间,单位为us,一般为3
Definition: usb2sent.h:82
unsigned char DataFormat
数据格式
Definition: usb2sent.h:88
unsigned char SensorType
传感器类型
Definition: usb2sent.h:89
Definition: usb2sent.h:98
unsigned short Tmtr
Total trigger time,单位为0.01tick
Definition: usb2sent.h:113
unsigned char Status
低4位代表Status,高4位代表DLC
Definition: usb2sent.h:110
unsigned char TimestampHigh
时间戳高位
Definition: usb2sent.h:100
unsigned int Timestamp
接收到信息帧时的时间标识,从SENT控制器初始化开始计时,单位为100us。发送数据时为帧间隔时间,单位为ms
Definition: usb2sent.h:99
unsigned char MsgType
Definition: usb2sent.h:101
unsigned char crc
MsgType若为3或者4,则是6bit有效CRC,其他的为4bit有效CRC
Definition: usb2sent.h:112
unsigned char Data[8]
若MsgType为1,里面为半字节数据;若MsgType为2,Data[0]为ID,Data[1]为数据;若MsgType为3或4,Data[0]为ID,Data[1]为高4位或者高8位数据,Data[...
Definition: usb2sent.h:111
unsigned short Tmlow
触发字段,SPC模式时用到,Master low time,单位为0.01tick
Definition: usb2sent.h:114