home *** CD-ROM | disk | FTP | other *** search
/ Between Heaven & Hell 2 / BetweenHeavenHell.cdr / 500 / 471 / rccl171 < prev    next >
Text File  |  1987-03-02  |  7KB  |  200 lines

  1. /*
  2.  * MAC  Version 2.0           Author :  Vincent Hayward
  3.  *                                      School of Electrical Engineering
  4.  *                                      Purdue University
  5.  *      Dir     : h
  6.  *      File    : jcom.h
  7.  *      Remarks : Set of macros for lsi11 / joint proc communication
  8.  *                Defines the DRV11 // interface adress.
  9.  *      Usage   : Included for joint processor control
  10.  */
  11.  
  12. #define CSR     (unsigned short *)0176770
  13. #define OBUF    (unsigned short *)0176772
  14. #define IBUF    (unsigned short *)0176774
  15.  
  16. /****************************************************************************/
  17. /*                                                                          */
  18. /*                         External I/O Group                               */
  19. /*                                                                          */
  20. /****************************************************************************/
  21.  
  22.  
  23. /*       modify by oring the contents of latch buffers of devices           */
  24.  
  25. #define bisio(d) \
  26. ((*CSR) = 0, (*OBUF) = CNTRLR, (*CSR)++, (*OBUF) = ((*IBUF) | (d)))
  27.  
  28.  
  29. /*     modify by anding the contents of latch buffers of devices            */
  30.  
  31. #define bicio(d) \
  32. ((*CSR) = 0, (*OBUF) = CNTRLR, (*CSR)++, (*OBUF) = ((*IBUF) & ~(d)))
  33.  
  34.  
  35. /*     read device register and mask the desired bits                       */
  36. /* note : after this call, (*IBUF) may be read as many times as needed    */
  37.  
  38. #define getio(d) \
  39. ((*CSR) = 0, (*OBUF) = CNTRLR, (*CSR)++, (*IBUF) & (d))
  40.  
  41.  
  42.  
  43. /****************************************************************************/
  44. /*                                                                          */
  45. /*                          Joint Command Group                             */
  46. /*                                                                          */
  47. /****************************************************************************/
  48.  
  49.  
  50. /*              wait for REQA : transfer completed                          */
  51.  
  52. #define eotwait \
  53. {int i = 0; while (!((*CSR) & REQA)) if (i++ == 100) zexit(100);}
  54.  
  55.  
  56. /*       send a write command with the associated data                      */
  57. /*       to a specified joint processor                                     */
  58.  
  59. #define putj(c, v, j) \
  60. {(*CSR) = 0; (*OBUF) = (c) | (j); (*CSR)++; (*OBUF) = (v); eotwait}
  61.  
  62.  
  63. /*          send a read command and return data                             */
  64. /*          from a specified joint processor                                */
  65.  
  66. #define getj(c, v, j) \
  67. {(*CSR) = 0; (*OBUF) = (c) | (j); (*CSR)++; eotwait; (v) = (*IBUF);}
  68.  
  69.  
  70. /*      same as above but with 6 pieces of data stored in an array          */
  71. /*      for each of the joint processors                                    */
  72.  
  73. #define put6j(c, a) \
  74. {int i = 0; \
  75. (*CSR) = 0; (*OBUF) = SEQUENT | (c); (*CSR)++; \
  76. while (i < 6) { (*OBUF) = a[i++]; eotwait; } }
  77.  
  78.  
  79. /*     same as above but with 6 pieces of data stored in an array           */
  80. /*     for each of the joint processors                                     */
  81.  
  82. #define get6j(c, a) \
  83. {int i = 0; \
  84. (*CSR) = 0; (*OBUF) = SEQUENT | (c); (*CSR)++; \
  85. while(i < 6) { eotwait; a[i++] = (*IBUF); } }
  86.  
  87.  
  88. /*    same as above but writes same data to each of the joints              */
  89.  
  90.  
  91. #define put6jg(c, v) \
  92. {int i = 6; \
  93. (*CSR) = 0; (*OBUF) = SEQUENT | (c); (*CSR)++; \
  94. while (i--) { (*OBUF) = (v); eotwait;}}
  95.  
  96.  
  97.  
  98. /****************************************************************************/
  99. /*                                                                          */
  100. /*                    RAM Parameter Access Group                            */
  101. /*                                                                          */
  102. /****************************************************************************/
  103.  
  104.  
  105.  
  106. /*     read the parameters stored in the specified joint processor ram      */
  107. /*     return the one byte parameter                                        */
  108.  
  109. #define getp(p, v ,j) \
  110. {putj(SETPAR, ADDR | (p) >> 8, j) ;\
  111. (*CSR) = 0; (*OBUF) = READM | (j); (*CSR)++; \
  112. if ((p) > 05400) (v) = (*IBUF); else (v) = (*IBUF) & 0377;}
  113.  
  114.  
  115. /*     set one byte parameter in the specified joint processor ram          */
  116.  
  117. #define putp(p, v, j) \
  118. {putj(SETPAR, (p) | (v) & 0377, j);}
  119.  
  120.  
  121. /* modify a parameter by oring the previous value with the supplied one     */
  122.  
  123. #define modop(p, m, j) \
  124. {int v; \
  125. getp(p, v, j) \
  126. putj(SETPAR, (p) | v & 0377 | (m) & 0377, j)}
  127.  
  128.  
  129.  
  130. /*        same as above but accesses the 6 joint processors                 */
  131.  
  132. #define put6p(p, a) \
  133. {int i; unsigned dl[6]; \
  134. for (i = 0;  i < 6;  i++) dl[i] = (p) | (a)[i] & 0377; put6j(SETPAR, dl);}
  135.  
  136.  
  137. /*        same as above but accesses the 6 joint processors                 */
  138.  
  139. #define get6p(p, a) \
  140. {int i = 0; \
  141. put6jg(SETPAR, ADDR | (p) >> 8); \
  142. (*CSR) = 0; (*OBUF) = SEQUENT | READM; (*CSR)++; \
  143. if (p > 05400) { while(i < 6) { eotwait; (a)[i++] = (*IBUF); } } \
  144. else { while(i < 6) { eotwait; (a)[i++] = (*IBUF) & 0377; } } }
  145.  
  146.  
  147. /*        same as above but accesses the 6 joint processors, gets 2 bytes   */
  148.  
  149. #define get6w(p, a) \
  150. {int i = 0; \
  151. put6jg(SETPAR, ADDR | (p) >> 8); \
  152. (*CSR) = 0; (*OBUF) = SEQUENT | READM; (*CSR)++; \
  153. while(i < 6) { eotwait; (a)[i++] = (*IBUF); } }
  154.  
  155.  
  156. /*        same as above but puts the same value to each joint               */
  157.  
  158. #define put6pg(p, v) \
  159. {put6jg(SETPAR, (p) | (v) & 0377)}
  160.  
  161.  
  162. /*        same as above but modifies the 6 joints by oring                  */
  163.  
  164. #define modo6p(p, a) \
  165. {int i; unsigned dl[6]; \
  166. get6p(p, dl); \
  167. for (i = 0; i < 6; i++) { dl[i] &= 0377; dl[i] |= (p) | (a)[i] & 0377;} \
  168. put6j(SETPAR, dl) ;}
  169.  
  170.  
  171. /*        same as above but same modification for all joints                */
  172.  
  173. #define modo6pg(p, m) \
  174. {int i; unsigned dl[6]; \
  175. get6p(p, dl); \
  176. for (i = 0;  i < 6;  i++) { dl[i] &= 0377; dl[i] |= p | m & 0377; } \
  177. put6j(SETPAR, dl)
  178.  
  179.  
  180.  
  181. /****************************************************************************/
  182. /*                                                                          */
  183. /*                Service Group                                             */
  184. /*                                                                          */
  185. /****************************************************************************/
  186.  
  187.  
  188.  
  189.  
  190. /*                        check for REQB                                    */
  191.  
  192. #define jreqb \
  193. (((*CSR) & REQB) ? ((*CSR) = 0, (*OBUF) = STOPP, (*IBUF) >> 8) : 0)
  194.  
  195.  
  196. /*                      check all joint tolerances                          */
  197.  
  198. #define jtol \
  199. ((*CSR) = 0, (*OBUF) = STOPP, (*IBUF) & 0377)
  200.