Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 f9daq 1
/************************************************************************\
2
##                                                                      ##
3
##  Creation Date: 18 Mar 2007                                          ##
4
##  Last Update:   18 Mar 2007                                          ##
5
##  Author:       XInstruments                                          ##
6
##                                                                      ##
7
##  Desc:   Setup packet-building functions.                            ##
8
##                                                                      ##
9
\************************************************************************/
10
 
11
 
12
#ifndef _USMCTYPES_H
13
#define _USMCTYPES_H
14
 
15
 
16
#include <linux/types.h>
17
 
18
 
19
// IOControl Codes:
20
// Controller-specific operations:
21
#define         IOCTL_GET_DESCRIPTOR_CONFIGURATION              0x00000000
22
#define         IOCTL_GET_DESCRIPTOR_DEVICE                     0x00000001
23
#define         IOCTL_GET_DESCRIPTOR_STRING                     0x00000002
24
#define         IOCTL_GET_STATUS_DEVICE                         0x00000003
25
#define         IOCTL_GET_STATUS_ENDPOINT                       0x00000004
26
#define         IOCTL_GET_STATUS_INTERFACE                      0x00000005
27
#define         IOCTL_GET_VERSION                               0x00000006
28
#define         IOCTL_GET_SERIAL                                0x00000007
29
#define         IOCTL_GET_ENCODER_STATE                         0x00000008
30
#define         IOCTL_GET_STATE                                 0x00000009
31
#define         IOCTL_GO_TO                                     0x0000000A
32
#define         IOCTL_SET_MODE                                  0x0000000B
33
#define         IOCTL_SET_PARAMETERS                            0x0000000C
34
#define         IOCTL_DOWNLOAD                                  0x0000000D
35
#define         IOCTL_SET_SERIAL                                0x0000000E
36
#define         IOCTL_SET_CURRENT_POSITION                      0x0000000F
37
#define         IOCTL_STOP_STEP_MOTOR                           0x00000010
38
#define         IOCTL_EMULATE_BUTTONS                           0x00000011
39
#define         IOCTL_SAVE_PARAMETERS                           0x00000012
40
// Driver-specific operations:
41
#define         IOCTL_GET_NOD                                   0x00000100
42
 
43
 
44
// Types of GetDescriptor SetupPacket:
45
#define         GET_DESCRIPTOR_CONFIGURATION    1
46
#define         GET_DESCRIPTOR_DEVICE           2
47
#define         GET_DESCRIPTOR_STRING           3
48
 
49
 
50
// Types of GetStatus SetupPacket:
51
#define         GET_STATUS_DEVICE               1
52
#define         GET_STATUS_ENDPOINT             2
53
#define         GET_STATUS_INTERFACE            3
54
 
55
#pragma         pack    ( push, 1 )
56
 
57
typedef struct  _STATE_PACKET   // 11 bytes;
58
{
59
        __u32  CurPos;          // Current Position (byte 0 is lowest byte 3 - highest) - CP.
60
        __u16  Temp;            // Current Temperature of Driver.
61
        // Byte 6:
62
        __u8   M1        : 1;   // | Step size is 2^(-M1-2*M2), where M1,M2 = 0,1. May be otherwise 1<->2.
63
        __u8   M2        : 1;   // |
64
        __u8   LOFT      : 1;   // Indicates "Loft State".
65
        __u8   REFIN     : 1;   // If TRUE then full power.
66
        __u8   CW_CCW    : 1;   // Current direction. Relatively!
67
        __u8   RESET     : 1;   // If TRUE then Step Motor is ON.
68
        __u8   FULLSPEED : 1;   // If TRUE then full speed. Valid in "Slow Start" mode.
69
        __u8   AFTRESET  : 1;   // TRUE After Device reset, FALSE after "Set Position".
70
        // Byte 7:
71
        __u8   RUN       : 1;   // TRUE if step motor is rotating.
72
        __u8   SYNCIN    : 1;   // Logical state directly from input synchronization PIN (pulses treated as positive).
73
        __u8   SYNCOUT   : 1;   // Logical state directly from output synchronization PIN (pulses are positive).
74
        __u8   ROTTR     : 1;   // Indicates current rotary transducer logical press state.
75
        __u8   ROTTRERR  : 1;   // Indicates rotary transducer error flag (reset by USMC_SetMode function with ResetRT bit √ TRUE).
76
        __u8   EMRESET   : 1;   // Indicates state of emergency disable button (TRUE √ Step motor power off).
77
        __u8   TRAILER1  : 1;   // Indicates trailer 1 logical press state.
78
        __u8   TRAILER2  : 1;   // Indicates trailer 2 logical press state.
79
        // Byte 8:
80
        __u8   USBPOW    : 1;   // USB Powered.
81
        __u8   UNKNOWN   : 6;
82
        __u8   Working   : 1;   // This bit must be always TRUE (to chek functionality).
83
        __u16  Voltage;         // Voltage of +40V Power input.
84
} STATE_PACKET, * PSTATE_PACKET, * LPSTATE_PACKET;
85
 
86
 
87
typedef struct  _ENCODER_STATE_PACKET   // 8 bytes;
88
{
89
        __u32 ECurPos;  // Current Position in Encoder Units.
90
        __u32 EncPos;   // Encoder Current Position.
91
} ENCODER_STATE_PACKET, * PENCODER_STATE_PACKET, * LPENCODER_STATE_PACKET;
92
 
93
 
94
typedef struct  _GO_TO_PACKET   // 7 bytes;
95
{
96
        __u32 DestPos;          // Destination Position.
97
        __u16  TimerPeriod;     // Period between steps is 12*(65536-[TimerPeriod])/[SysClk] in seconds, where SysClk = 24000000 Hz.
98
        // Byte 7:
99
        __u8  M1        : 1;    // | Step size is 2^(-M1-2*M2), where M1,M2 = 0,1. May be otherwise 1<->2.
100
        __u8  M2        : 1;    // |
101
        __u8  DEFDIR    : 1;    // Default direction. For "Anti Loft" operation.
102
        __u8  LOFTEN    : 1;    // Enable automatic "Anti Loft" operation.
103
        __u8  SLSTRT    : 1;    // Slow Start(and Stop) mode.
104
        __u8  WSYNCIN   : 1;    // Wait for input synchronization signal to start.
105
        __u8  SYNCOUTR  : 1;    // Reset output synchronization counter.
106
        __u8  FORCELOFT : 1;    // Force driver automatic "Anti Loft" mechanism to reset "Loft State".
107
} GO_TO_PACKET, * PGO_TO_PACKET, * LPGO_TO_PACKET;
108
 
109
 
110
typedef struct  _MODE_PACKET    // 7 bytes;
111
{
112
        // Byte 0:
113
        __u8  PMODE    : 1;     // Turn off buttons (TRUE - buttons disabled).
114
        __u8  REFINEN  : 1;     // Current reduction regime (TRUE - regime is on).
115
        __u8  RESETD   : 1;     // Turn power off and make a whole step (TRUE - apply).
116
        __u8  EMRESET  : 1;     // Quick power off.
117
        __u8  TR1T     : 1;     // Trailer 1 TRUE state.
118
        __u8  TR2T     : 1;     // Trailer 2 TRUE state.
119
        __u8  ROTTRT   : 1;     // Rotary Transducer TRUE state.
120
        __u8  TRSWAP   : 1;     // If TRUE, Trailers are Swapped (Swapping After Reading Logical State).
121
        // Byte 1:
122
        __u8  TR1EN    : 1;     // Trailer 1 Operation Enabled.
123
        __u8  TR2EN    : 1;     // Trailer 2 Operation Enabled.
124
        __u8  ROTTREN  : 1;     // Rotary Transducer Operation Enabled.
125
        __u8  ROTTROP  : 1;     // Rotary Transducer Operation Select (stop on error for TRUE).
126
        __u8  BUTT1T   : 1;     // Button 1 TRUE state.
127
        __u8  BUTT2T   : 1;     // Button 2 TRUE state.
128
        __u8  BUTSWAP  : 1;     // If TRUE, Buttons are Swapped (Swapping After Reading Logical State).
129
        __u8  RESETRT  : 1;     // Reset Rotary Transducer Check Positions (need one full revolution before it can detect error).
130
        // Byte 2:
131
        __u8  SNCOUTEN : 1;     // Output Syncronization Enabled.
132
        __u8  SYNCOUTR : 1;     // Reset output synchronization counter.
133
        __u8  SYNCINOP : 1;     // Synchronization input mode: TRUE - Step motor will move one time to the DestPos FALSE - Step motor will move multiple times by DestPos microsteps as distance.
134
        __u8  SYNCOPOL : 1;     // Output Syncronization Pin Polarity.
135
        __u8  ENCODER  : 1;     // Encoder is used on pins {SYNCIN,ROTTR} - disables Syncronization input and Rotary Tranducer.
136
        __u8  INVENC   : 1;     // Invert Encoder Counter Direction.
137
        __u8  RESBENC  : 1;     // Reset <Encoder Position> and <SM Position in Encoder units> to 0.
138
        __u8  RESENC   : 1;     // Reset <SM Position in Encoder units> to <Encoder Position>.
139
        __u16 SYNCCOUNT;        // Number of steps after which synchronization output signal occurs.
140
} MODE_PACKET, * PMODE_PACKET, * LPMODE_PACKET;
141
 
142
 
143
typedef struct  _PARAMETERS_PACKET      // 57 bytes;
144
{
145
        __u8  DELAY1;           // Acceleration time multiplier.
146
        __u8  DELAY2;           // Deceleration time multiplier.
147
        __u16 RefINTimeout;     // Timeout for RefIN reseting.
148
        __u16 BTIMEOUT1;        // | Buttons Timeouts (4 stages).
149
        __u16 BTIMEOUT2;        // |
150
        __u16 BTIMEOUT3;        // |
151
        __u16 BTIMEOUT4;        // |
152
        __u16 BTIMEOUTR;        // Timeout for RESET command.
153
        __u16 BTIMEOUTD;        // Timeout for Double Click.
154
        __u16 MINPERIOD;        // Standart Timer Period.
155
        __u16 BTO1P;            // | Timer Periods for button rotation.
156
        __u16 BTO2P;            // |
157
        __u16 BTO3P;            // |
158
        __u16 BTO4P;            // |
159
        __u16 MAX_LOFT;         // Max Loft Value.
160
        __u32 STARTPOS;         // Start Position.
161
        __u16 RTDelta;          // Revolution Distance.
162
        __u16 RTMinError;       // Minimal value of Rotatory Tranduser Error.
163
        __u16 MaxTemp;          // Working Temperature Limit.
164
        __u8  SynOUTP;          // Syncronizaion OUT pulse duration( T = (sopd-1/2)*StepPeriod ).
165
        __u16 LoftPeriod;       // Loft last phase speed.
166
        __u8  EncVSCP;          // 4x Number of Encoder steps per one full SM step.
167
        __u8  Reserved [15];    // Reserved.
168
} PARAMETERS_PACKET, * PPARAMETERS_PACKET, * LPPARAMETERS_PACKET;
169
 
170
 
171
typedef struct  _DOWNLOAD_PACKET        // 65 bytes;
172
{
173
        __u8 Page;              // Page number ( 0 - 119 ). 0 - first, 119 - last.
174
        __u8 Data [64];         // Data.
175
} DOWNLOAD_PACKET, * PDOWNLOAD_PACKET, * LPDOWNLOAD_PACKET;
176
 
177
 
178
typedef struct  _SERIAL_PACKET  // 32 bytes;
179
{
180
        __u8 Password     [16];
181
        __u8 SerialNumber [16];
182
} SERIAL_PACKET, * PSERIAL_PACKET, * LPSERIAL_PACKET;
183
 
184
#pragma         pack    ( pop )
185
 
186
 
187
typedef GO_TO_PACKET const * PCGO_TO_PACKET;
188
typedef GO_TO_PACKET const * LPCGO_TO_PACKET;
189
typedef MODE_PACKET const * PCMODE_PACKET;
190
typedef MODE_PACKET const * LPCMODE_PACKET;
191
typedef PARAMETERS_PACKET const * PCPARAMETERS_PACKET;
192
typedef PARAMETERS_PACKET const * LPCPARAMETERS_PACKET;
193
typedef DOWNLOAD_PACKET const * PCDOWNLOAD_PACKET;
194
typedef DOWNLOAD_PACKET const * LPCDOWNLOAD_PACKET;
195
typedef SERIAL_PACKET const * PCSERIAL_PACKET;
196
typedef SERIAL_PACKET const * LPCSERIAL_PACKET;
197
typedef STATE_PACKET const * PCSTATE_PACKET;
198
typedef STATE_PACKET const * LPCSTATE_PACKET;
199
typedef ENCODER_STATE_PACKET const * PCENCODER_STATE_PACKET;
200
typedef ENCODER_STATE_PACKET const * LPCENCODER_STATE_PACKET;
201
 
202
 
203
#endif  // _USMCTYPES_H