|
EPICS Motor Module motor-R6-8-RC1_1-4
|
00001 /* 00002 FILENAME... omsMAXv.h 00003 USAGE... Pro-Dex OMS MAXv asyn motor controller support 00004 00005 Version: $Revision: 1.3 $ 00006 Modified By: $Author: ernesto $ 00007 Last Modified: $Date: 2013/07/09 15:27:30 $ 00008 HeadURL: $URL$ 00009 */ 00010 00011 /* 00012 * Created on: 10/2010 00013 * Author: eden 00014 */ 00015 00016 #ifndef OMSMAXV_H_ 00017 #define OMSMAXV_H_ 00018 00019 #include "omsBaseController.h" 00020 #include <devLib.h> 00021 00022 #define BUFFER_SIZE 1024 00023 00024 #define MAXv_NUM_CARDS 15 /* maximum number of cards */ 00025 #define OMS_INT_VECTOR 180 /* default interrupt vector (64-255) */ 00026 #define OMS_INT_LEVEL 5 /* default interrupt level (1-6) */ 00027 00028 #define RTpositionString "RT_POSITIONS" /* asynInt32Array, r/o */ 00029 #define auxString "AUX" /* asynInt32Array, r/o */ 00030 #define gpioString "GPIO" /* asynInt32Array, r/o */ 00031 00032 /* Limit Switch Status - Offset = 0x40 */ 00033 typedef union 00034 { 00035 epicsUInt32 All; 00036 struct 00037 { 00038 unsigned int s_minus :1; 00039 unsigned int r_minus :1; 00040 unsigned int v_minus :1; 00041 unsigned int u_minus :1; 00042 unsigned int t_minus :1; 00043 unsigned int z_minus :1; 00044 unsigned int y_minus :1; 00045 unsigned int x_minus :1; 00046 unsigned int s_plus :1; 00047 unsigned int r_plus :1; 00048 unsigned int v_plus :1; 00049 unsigned int u_plus :1; 00050 unsigned int t_plus :1; 00051 unsigned int z_plus :1; 00052 unsigned int y_plus :1; 00053 unsigned int x_plus :1; 00054 } Bits; 00055 } LIMIT_SWITCH; 00056 00057 /* Home Switch Status - Offset = 0x44 */ 00058 typedef union 00059 { 00060 epicsUInt32 All; 00061 struct 00062 { 00063 unsigned int home_s :1; /* status of S axis */ 00064 unsigned int home_r :1; /* status of R axis */ 00065 unsigned int home_v :1; /* status of V axis */ 00066 unsigned int home_u :1; /* status of U axis */ 00067 unsigned int home_t :1; /* status of T axis */ 00068 unsigned int home_z :1; /* status of Z axis */ 00069 unsigned int home_y :1; /* status of Y axis */ 00070 unsigned int home_x :1; /* status of X axis */ 00071 } Bits; 00072 } HOME_SWITCH; 00073 00074 /* Firmware status - Offset = 0x48 */ 00075 typedef union 00076 { 00077 epicsUInt32 All; 00078 struct 00079 { 00080 unsigned int na19 :13; /* N/A bits 19-31 */ 00081 unsigned int factoryparm_loaded :1; 00082 unsigned int altparm_loaded :1; 00083 unsigned int defaultparm_loaded :1; 00084 unsigned int altprgm_err :1; 00085 unsigned int altparm_chksum_err :1; 00086 unsigned int prgm_err :1; 00087 unsigned int parm_chksum_err :1; 00088 unsigned int na10 :2; /* N/A bits 10-11 */ 00089 unsigned int program_error :1; 00090 unsigned int flash_chksum_err :1; 00091 unsigned int na3 :5; /* N/A bits 3-7 */ 00092 unsigned int running :1; 00093 unsigned int initializing :1; 00094 unsigned int not_downloaded :1; 00095 } Bits; 00096 } FIRMWARE_STATUS; 00097 00098 /* RT position structure */ 00099 typedef union 00100 { 00101 epicsUInt16 All[5]; 00102 struct 00103 { 00104 00105 epicsUInt16 encoderMSB :16; /* encoder position */ 00106 epicsUInt16 encoderLSB :16; /* encoder position */ 00107 epicsUInt8 axis :8; /* axis */ 00108 epicsUInt8 home :8; /* home switch and home event bits */ 00109 epicsUInt16 ioPos :16; /* positive I/O bits */ 00110 epicsUInt16 ioNeg :16; /* negative I/O bits */ 00111 } RTposition; 00112 } RTPC_TBL_ENTRY; 00113 00114 00115 /* Status#1 - Offset = 0xFC0 */ 00116 typedef union 00117 { 00118 epicsUInt32 All; 00119 struct 00120 { 00121 unsigned int na3 :5; /* N/A bits 27-31. */ 00122 unsigned int data_avail :1; 00123 unsigned int text_response :1; 00124 unsigned int cmndError :1; /* Command error dectect */ 00125 unsigned int slip :8; 00126 unsigned int overtravel :8; 00127 unsigned int done :8; 00128 } Bits; 00129 } STATUS1; 00130 00131 /* OMS MAXv VME dual port memory map */ 00132 struct MAXv_motor 00133 { 00134 epicsUInt32 cmndPos[8]; 00135 epicsUInt32 encPos[8]; 00136 LIMIT_SWITCH limit_switch; 00137 HOME_SWITCH home_switch; 00138 FIRMWARE_STATUS firmware_status; 00139 epicsUInt32 direct_cmnd_mbox; 00140 epicsUInt32 position_req_mbox; 00141 epicsUInt32 coherent_cmndPos[8]; 00142 epicsUInt32 coherent_encPos[8]; 00143 epicsUInt32 msg_semaphore; 00144 epicsUInt32 queue_flush_mbox; 00145 epicsUInt32 gpio; 00146 epicsUInt32 naA0[19]; /* N/A byte offset 0xA0 - 0xEB. */ 00147 epicsUInt32 flash_pgm_ptr; 00148 epicsUInt32 outPutIndex; 00149 epicsUInt32 outGetIndex; 00150 epicsUInt32 inPutIndex; 00151 epicsUInt32 inGetIndex; 00152 epicsUInt8 outBuffer[BUFFER_SIZE]; 00153 epicsUInt8 inBuffer[BUFFER_SIZE]; 00154 epicsUInt8 utility[BUFFER_SIZE]; 00155 00156 epicsUInt32 naD00[37]; // N/A byte offset 0xD00 - 0xD93. 00157 epicsUInt8 rtpcPutIndex; 00158 epicsUInt8 rtpcGetIndex; 00159 RTPC_TBL_ENTRY rtpcTblEntry[55]; 00160 epicsUInt16 naFBE[2]; // N/A byte offset 0xFBE - 0xFBF. 00161 00162 STATUS1 status1_flag; 00163 STATUS1 status1_irq_enable; 00164 epicsUInt32 status2_flag; 00165 epicsUInt32 status2_irq_enable; 00166 epicsUInt32 IACK_vector; 00167 epicsUInt32 config_switch; 00168 epicsUInt32 AM_register; 00169 epicsUInt32 naFDC[7]; 00170 epicsUInt32 FIFO_status_cntrl; 00171 epicsUInt32 FIFO_date; 00172 00173 }; 00174 00175 typedef struct MAXv_RT { 00176 char *portName; 00177 epicsMutexId lock; 00178 epicsEventId pollRTEventId_; 00179 00180 /* Asyn interfaces */ 00181 asynInterface common; 00182 asynInterface asynInt32Array; 00183 asynInterface asyndrvUser; 00184 00185 asynUser *pasynUser; 00186 asynStatus status; 00187 00188 void *asynInt32ArrayPvt; 00189 00190 epicsInt32 encPos[8]; 00191 } MAXv_RT; 00192 00193 00194 class omsMAXv : public omsBaseController { 00195 public: 00196 omsMAXv(const char*, int, int, const char*, int, int, unsigned int, int, int, const char*, int); 00197 omsMAXv(const char*, int, int, const char*, int, int, int ); 00198 asynStatus sendReceive(const char *, char *, unsigned int, size_t *); 00199 asynStatus sendOnly(const char *); 00200 asynStatus readInt32Array(asynUser *pasynUser, epicsInt32 *value,size_t nElements, size_t *nIn); 00201 asynStatus getRTposition(); 00202 static void callRTPoller(void*); 00203 asynStatus startRTPoller(); 00204 void omsRTPoller(); 00205 static char* baseAddress; 00206 static epicsAddressType addrType; 00207 static int numCards; 00208 static epicsUInt32 baseInterruptVector; 00209 static epicsUInt8 interruptLevel; 00210 static void InterruptHandler( void * param ); 00211 void* getCardAddress(){return (void*) pmotor;}; 00212 void* getRTAddress(){return (void*) pRT;}; 00213 static void resetOnExit(void* param){((omsMAXv*)param)->resetIntr();}; 00214 void resetIntr(); 00215 int getCardNo(){return cardNo;}; 00216 00217 protected: 00218 virtual void initialize(const char*, int, int, const char*, int, int, unsigned int, int, int, epicsAddressType, int ); 00219 00220 int RTposition; 00221 int aux; 00222 int gpio; 00223 private: 00224 void motorIsrSetup(volatile unsigned int, volatile epicsUInt8); 00225 int cardNo; 00226 epicsThreadId RTpositionThread; 00227 int priority, stackSize; 00228 volatile struct MAXv_motor *pmotor; 00229 struct MAXv_RT *pRT; 00230 char readBuffer[BUFFER_SIZE]; 00231 }; 00232 00233 #endif /* OMSMAXV_H_ */
1.7.4