/*
 * MAC  Version 2.0           Author :  Vincent Hayward
 *                                      School of Electrical Engineering
 *                                      Purdue University
 *      Dir     : h
 *      File    : addefs.h
 *      Remarks : Not quite clean yet.
 *      Usage   : Included in lsi11 pgs to control joint processors
 */


/*  This section contains all  of  the  hardware  address  definitions      */
/*  needed for software communication to the joint microprocessors.         */


/*                       Control Register Bits                              */

#define  SELECT        00       /* sets up data transfer                    */
#define  CMDVLD        01       /* command validation                       */
#define  REQA        0200       /* request a, acknowledge transfer          */
#define  REQB     0100000       /* request b, signal attention request      */


/*                  External Communication by the Host                      */

/*  The external I/O control and front panel switches are  defined  by      */
/*  data values sent to or read from a latched  buffer when the output      */
/*  buffer of the parellel interface is sent the value of 07.               */

#define  CNTRLR        07       /* enable external communication            */

#define  EXTERN0       01       /* external input/output                    */
#define  EXTERN1       02       /* bit definitions                          */
#define  EXTERN2       04       /*                                          */
#define  EXTERN3      010       /*                                          */
#define  EXTERN4      020       /*                                          */
#define  EXTERN5      040       /*                                          */
#define  EXTERN6     0100       /*                                          */
#define  EXTERN7     0200       /*                                          */
#define  ARMPWR      0400       /* high power on/off bit  (high/low)        */
#define  OFFL       01000       /* external low signal to stop the arm      */
#define  RUN        02000       /* front panel switch - run bit low         */
#define  RESTART    04000       /* front panel switch - restart bit low     */
#define  HNDOH      01000       /* close pneumatic hand/release  (high/low) */
#define  HNDCH      02000       /* open pneumatic hand/release  (high/low)  */
#define  EXTRA4     04000       /* spare output bit (not wired)             */
#define  EXTRA0    010000       /* spare I/O bit (not wired)                */
#define  EXTRA1    020000       /* spare I/O bit (not wired)                */
#define  EXTRA2    040000       /* spare I/O bit (not wired)                */
#define  EXTRA3   0100000       /* spare I/O bit (not wired)                */

/*                    Host Commands to the Joints                           */

#define  POSET        000       /* 16 bit unsigned position set point       */
#define  DACSET       010       /* 12 bit signed dac setpoint               */
				/*   000000  minimum positive value         */
				/*   001777  halfway positive value         */
				/*   003777  maximum positive value         */
				/*   777777  minimum negative value         */
				/*   775777  halfway negative value         */
				/*   774000  maximum negative value         */
#define  TOLBND       020       /* position tolerance                       */
#define  STOPM        030       /* enter stop mode and set position         */
#define  CALIB        040       /* calibrate                                */
#define  GRAVTY       050       /* 16 bit signed gravity term               */
#define  INTBND       060       /* set integration band                     */
#define  SETPAR       070       /* setup joint servo parameters             */
#define  STOPP       0100       /* stop w/o changing position count         */
#define  UNSD1       0110       /* undefined                                */
#define  UNSD2       0120       /* undefined                                */
#define  UNSD3       0130       /* undefined                                */
#define  READ        0140       /* read 16 bit unsigned position            */
#define  JSTAT       0150       /* read joint status definitions            */
#define  JRSERVO  0100000       /*              servoing enabled            */
#define  JRINTBD  0040000       /*              integration enabled         */
#define  JRTRQSV  0020000       /*              torque servo enabled        */
#define  JRHLFCT  0010000       /*              1/2 count enabled           */
#define  JRPOSSV  0004000       /*              position servo enabled      */
				/*    002000    undefined                   */
#define  JFNDIXS  0001000       /*              index found and halted      */
#define  JLOOKZI  0000400       /*              looking for index           */
#define  JLOSTSY  0000200       /*              lost synch with encoder     */
#define  JFIXFND  0000100       /*              first index found           */
				/*    000040    undefined                   */
				/*    000020    undefined                   */
				/*    000010    undefined                   */
				/*    000004    undefined                   */
				/*    000002    undefined                   */
				/*    000001    undefined                   */
#define  READP       0160       /* read joint pot                           */
#define  READM       0170       /* read micro memory set in location 2      */
#define  SEQUENT     0200       /* sequential (to address all joints)       */


/*                          RAM Parameters                                  */

#ifdef STAN

#define  STATUS     00000       /* index status register                    */
				/*   0200  lost synch with encoder          */
				/*   0100  set after first index found      */
#define  MODE       00400       /* joint control and status register        */
#define  MESERVO     0200       /*       | enable servoing                  */
#define  MEINTBD     0100       /*       | enable integration band          */
#define  METRQSV      040       /*       | enable torque servo              */
#define  MEHLFCT      020       /*       | enable half count mode           */
#define  MEPOSSV      010       /*       | enable position servo            */
#define  MFNDIXS       02       /*       | set when found zero index        */
#define  MLOOKZI       01       /*       | look for zero index              */

#define  ADDR      001000       /* memory address to read with readm        */
#define  PGAIN     001400       /* position error servo gain  (0 to 7)      */
#define  VGAIN     002000       /* velocity error servo gain  (0 to 7)      */
#define  IGAIN     002400       /* integrated position error gain  (0 to 7) */
#define  SCALE     003000       /* final output error gain  (0 to 7)        */
#define  NINTER    003400       /* number of interps. default 32            */
#define  INTSCL    004000       /* see instructions. default 3              */
#define  TICK      004400       /* number of 8 micro second ticks           */
#define  WHLSIZ    005000       /* no. of encoder counts times four         */
#define  OFFSET    006000       /* gravity compensation term  (2 bytes)     */
#define  POSTOL    007000       /* position tolerance  (2 bytes)            */
#define  INTTOL    010000       /* integration tolerance  (2 bytes)         */
#define  CURPOS    023000       /* current position  (2 bytes)              */
#define  LSTPOS    024000       /* last servo position  (2 bytes)           */
#define  CURVEL    027000       /* current velocity  (2 bytes)              */
#endif

#ifdef PUMA

#define  STATUS     00000       /* index status register                    */
				/*   0200  lost synch with encoder          */
				/*   0100  set after first index found      */
#define  MODE       00400       /* joint control and status register        */
#define  MESERVO     0200       /*       | enable servoing                  */
#define  MEINTBD     0100       /*       | enable integration band          */
#define  MELSBSV      040       /*       | enable lsb servo                 */
#define  MEHLFCT      020       /*       | enable half count mode           */
#define  MEPOSSV      010       /*       | enable position servo            */
#define  MFNDIXS       02       /*       | set when found zero index        */
#define  MLOOKZI       01       /*       | look for zero index              */

#define  ADDR      001000       /* memory address to read with readm        */
#define  PGAIN     001400       /* position error servo gain  (0 to 7)      */
#define  VGAIN     002000       /* velocity error servo gain  (0 to 7)      */
#define  SCALE     002400       /* final output error gain  (0 to 7)        */
#define  NINTER    003000       /* number of interps. default 32            */
#define  INTSCL    003400       /* see instructions. default 3              */
#define  TICK      004000       /* number of 8 micro second ticks           */
#define  WHLSIZ    004400       /* no. of encoder counts times four         */
#define  OFFSET    010000       /* gravity compensation term  (2 bytes)     */
#define  POSERR    011000       /* curr pos err                             */
#define  CURVEL    012400       /* curr vel                                 */
#define  DACSIG    014000       /* composite dac ouput                      */
#define  POSTOL    ??????       /* position tolerance  (2 bytes)            */
#define  INTTOL    ??????       /* integration tolerance  (2 bytes)         */
#define  CURPOS    ??????       /* current position  (2 bytes)              */
#define  LSTPOS    ??????       /* last servo position  (2 bytes)           */
#endif
