00001 #ifndef COPROCESSORH
00002 #define COPROCESSORH
00003
00004
00005
00006
00007
00008
00026
00027
00028
00029 #include "CAN.h"
00030 #include "serial.h"
00031
00032 #define NEW 1
00033 #define OLD 0
00034 #define TRUE 1
00035 #define FALSE 0
00036 #define RS232BUFSIZE 1000
00037 #define RS422BUFSIZE 1000
00038 #define LCD_QSZ 10
00039 #define COPCODE
00040
00041 #define BITMASK(data) (1<<data)
00042
00043
00044
00045 #define INTERNAL_ATOD_NUM 16
00046 #define EXTERNAL_ATOD_NUM 8 //if it's populated
00047
00048 #define PWMNUM 16
00049 #define COUNTNUM 8
00050
00051 #define ATOD0RESPONSE (BITMASK(ADBLK0))
00052 #define ATOD1RESPONSE (BITMASK(ADBLK1))
00053
00057 typedef struct VersionInfo
00058 {
00059 __u8 version;
00060 char date[14];
00061 }VersionInfo;
00062
00069 typedef struct RG_ParseMask
00070 {
00072 __u16 Internal_AD;
00074 __u8 External_AD;
00076 __u8 counter;
00078 __u8 zero;
00080 __u16 pwm;
00081 }RG_ParseMask;
00082
00087 typedef struct PWMconfig{
00089 __u16 pwm;
00091 __u16 frequency;
00093 __u16 duty;
00094
00095 __u16 delay;
00096 }PWMconfig;
00097
00102 typedef struct countconfig{
00104 __u16 counter;
00106 __u16 trigger;
00108 __u16 threshold;
00110 __u16 flags;
00111 }countconfig;
00112
00116 typedef struct countdata{
00117
00118 __u16 counter;
00122 __u16 countstart;
00126 __u16 laststart;
00128 unsigned long timestamp;
00130 unsigned long laststamp;
00132 int zerocross;
00133 }countdata;
00134
00143 typedef struct Cop_Data {
00145 __u8 Datarxd;
00147 int ptogo;
00149 int psize;
00151 char packet[MAXPACKETSIZE];
00153 __u16 Internal_AD[INTERNAL_ATOD_NUM];
00155 __u16 External_AD[EXTERNAL_ATOD_NUM];
00157 PWMconfig PWM_config[PWMNUM];
00159 countdata counter_data[COUNTNUM];
00161 countconfig counter_config[COUNTNUM];
00163 __u8 Digital[2];
00165 char RS232_string[RS232BUFSIZE];
00167 char RS422_string[RS422BUFSIZE];
00169 char Key;
00171 E12Can_Message *CAN_message;
00173 VersionInfo version;
00175 RG_ParseMask parsemask;
00177 PcpkPacket packetdata;
00179 void *userdata;
00180 }Cop_Data;
00181
00182
00183
00190 Cop_Data *CopDeviceCreate(int flags);
00191
00197 int CopDeviceDestroy(Cop_Data *Cop);
00198
00211 __u32 E12_Packet_Route(Cop_Data *Cop, unsigned char *data, int datasize);
00212
00223 __u32 E12_Parse_Until(int fd, Cop_Data *Cop, __u32 bitmask );
00224
00235 int e12packetout(int fd,__u8 device,__u8 maskcnt,void *data);
00236
00249 int E12_Digitalout(int fd, __u8 data,int port);
00250
00259 int E12_Digital_Req(int fd);
00260
00271 int E12_Digital_Cfg(int fd, __u8 mask, int port);
00272
00325 int E12_PWMControl(int fd,int pwm, int frequency, int duty,Cop_Data *Cop);
00326
00334 int E12_Internal_AtoD_Req(int fd, int channel);
00335
00343 int E12_External_AtoD_Req(int fd, int channel);
00344
00356 int E12_AtoD_Req(int fd, int channel);
00357
00366 int E12_DtoA_Write(int fd, int channel,int data);
00367
00368
00376 int E12_VersionReq(int fd);
00377
00378
00384 int UpdatetHardwarePWMInfo(int fd, Cop_Data *Cop);
00385
00386 int E12_PWMCfg_Req(int fd, int pwm);
00387
00390 #endif