Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

dro.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define DRO_MAX   4

Functions

int LS7266Init (void)
long LS7266Read (int i)
void LS7266Write (int i, long in)


Define Documentation

#define DRO_MAX   4
 

Definition at line 4 of file dro.h.


Function Documentation

int LS7266Init void   
 

Definition at line 102 of file dro.c.

00103 {
00104   int t;
00105 
00106   for (t = 0; t < 4; t++) {
00107     /* set present flag to true, clear it later if not there */
00108     Present[t] = 1;
00109 
00110     /* if even, initialize chip half */
00111     if (! t % 2) {
00112       outportb(CTRL(t), INDEX_DISABLE);
00113       outportb(CTRL(t), EFLAG_RESET);
00114       outportb(CTRL(t), BP_RESETB);
00115       outportb(DATA(t), CLOCK_DATA);
00116       outportb(CTRL(t), CLOCK_SETUP);
00117       outportb(CTRL(t), INPUT_SETUP);
00118       outportb(CTRL(t), QUAD_X4);
00119       outportb(CTRL(t), CNTR_RESETB);
00120 
00121       outportb(CTRL(t), 184);
00122       outportb(CTRL(t), 135);
00123       outportb(CTRL(t), 133);
00124       outportb(CTRL(t), 131);
00125       outportb(CTRL(t), 193);
00126       outportb(CTRL(t), 224);
00127     }
00128 
00129     /* initialize encoder input */
00130     outportb(CTRL(t), BP_RESET);
00131     outportb(DATA(t), 3 * t + 1);
00132     outportb(DATA(t), 3 * t + 2);
00133     outportb(DATA(t), 3 * t + 3);
00134 
00135     outportb(CTRL(t), TRSFRPR_CNTR);
00136     outportb(CTRL(t), TRSFRCNTR_OL);
00137     outportb(CTRL(t), CNTR_RESET);
00138 
00139     outportb(CTRL(t), BP_RESET);
00140     if (inportb(DATA(t)) != 3 * t + 1) {
00141       Present[t] = 0;
00142     }
00143     if (inportb(DATA(t)) != 3 * t + 2) {
00144       Present[t] = 0;
00145     }
00146     if (inportb(DATA(t)) != 3 * t + 3) {
00147       Present[t] = 0;
00148     }
00149   }
00150 
00151   if (Present[0] || Present[1] || Present[2] || Present[3]) {
00152     return 0;
00153   }
00154 
00155   return -1;
00156 }

long LS7266Read int    i
 

Definition at line 161 of file dro.c.

Referenced by extEncoderRead(), and extEncoderReadAll().

00162 {
00163   union pos_tag {
00164     long l;
00165     struct byte_tag { char b0; char b1; char b2; char b3;} byte;
00166   } pos;
00167 
00168   outportb(CTRL(i), TRSFRCNTR_OL);
00169   outportb(CTRL(i), BP_RESET);
00170   pos.byte.b0=inportb(DATA(i));
00171   pos.byte.b1=inportb(DATA(i));
00172   pos.byte.b2=inportb(DATA(i));
00173   if (pos.byte.b2 < 0) {
00174     pos.byte.b3 = -1;
00175   }
00176   else {
00177     pos.byte.b3 = 0;
00178   }
00179 
00180   return pos.l;
00181 }

void LS7266Write int    i,
long    in
 

Definition at line 186 of file dro.c.

00187 {
00188   union pos_tag {
00189     long l;
00190     struct byte_tag { char b0; char b1; char b2; char b3;} byte;
00191   } pos;
00192 
00193   pos.l = in;
00194   outportb(CTRL(i), BP_RESET);
00195   outportb(DATA(i), pos.byte.b0);
00196   outportb(DATA(i), pos.byte.b1);
00197   outportb(DATA(i), pos.byte.b2);
00198   outportb(CTRL(i), TRSFRPR_CNTR);
00199   outportb(CTRL(i), TRSFRCNTR_OL);
00200   outportb(CTRL(i), BP_RESET);
00201 
00202   return;
00203 }


Generated on Sun Dec 2 15:27:51 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001