/*
 * RTC Version  2.0           Author :  Vincent Hayward
 *                                      School of Electrical Engineering
 *                                      Purdue University
 *      Dir     : h
 *      File    : rtc.h
 *      Remarks : Robot interface state and command descriptions
 *      Usage   : made available to the user
 */

#define VERSION         2

#define ADC             16

#undef  NO
#undef  YES
#define NO              0
#define YES             1

#undef  NJOINTS         6
#define NJOINTS         6
#define DEFAULTRATE     2
#define HARDCLOCK       7       /* basic sample time    */

#define STOP            1
#define STOPCAL         2
#define POS             3
#define CUR             4

/*
 * global arm state structure, if modified, the pack routine will
 * arrange to reflect the change onto the arm controller
 */


struct i {
	char set;                /* flag to be set if change requested */
	unsigned short vali;     /* corresponding value */
};

struct a {
	char set ;
	unsigned short vala[NJOINTS];
};

struct g {
	char set;               /* flag to be set if change requested */
	unsigned short valg;     /* corresponding value */
};


struct chg {
	struct i i_motion[NJOINTS];      /* case POS - CUR - STOP - STOPCAL */
	struct i i_gravty[NJOINTS];

	struct a a_motion;
	struct a a_gravty;

	struct g g_adco;                /* open adc channel */
	struct g g_hand;                /* command hand */
	struct g g_rate;                /* rate in 2 ** value * 7 ms */

	char end;                       /* termination */
	char stop;                      /* stop on the spot */
	char calib;
};


/*
 * structure send by the controller on each interrupt
 */

struct how {
	short wc;
	unsigned short
		exio,                   /* state of the extern io register */
		pos[NJOINTS];           /* current positions               */
#ifdef ADC
	short
		adcr[ADC];              /* adc readings                    */
#endif
	short   chks;
};
