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

dro.c File Reference

#include "dro.h"

Include dependency graph for dro.c:

Include dependency graph

Go to the source code of this file.

Defines

#define inportb(port)   (0)
#define outportb(port, val)   {printf("outportb(%d (0x%X),%d)\n",port,port,val);}
#define CLOCK_DATA   0x0E
#define CLOCK_SETUP   0x98
#define INPUT_SETUP   0xC1
#define QUAD_X1   0xA8
#define QUAD_X2   0xB0
#define QUAD_X4   0xB8
#define BP_RESET   0x01
#define BP_RESETB   0x81
#define CNTR_RESET   0x02
#define CNTR_RESETB   0x82
#define TRSFRPR_CNTR   0x08
#define TRSFRCNTR_OL   0x90
#define EFLAG_RESET   0x86
#define INDEX_DISABLE   0xE0
#define DATA(x)   (BASE7266 + (2 * x))
#define CTRL(x)   (BASE7266 + (2 * x) + 1)

Functions

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

Variables

int BASE7266 = 0x200
int Present [4] = {1, 1, 1, 1}


Define Documentation

#define BP_RESET   0x01
 

Definition at line 82 of file dro.c.

#define BP_RESETB   0x81
 

Definition at line 83 of file dro.c.

#define CLOCK_DATA   0x0E
 

Definition at line 76 of file dro.c.

#define CLOCK_SETUP   0x98
 

Definition at line 77 of file dro.c.

#define CNTR_RESET   0x02
 

Definition at line 84 of file dro.c.

#define CNTR_RESETB   0x82
 

Definition at line 85 of file dro.c.

#define CTRL      (BASE7266 + (2 * x) + 1)
 

Definition at line 95 of file dro.c.

Referenced by LS7266Init(), LS7266Read(), and LS7266Write().

#define DATA      (BASE7266 + (2 * x))
 

Definition at line 94 of file dro.c.

Referenced by LS7266Init(), LS7266Read(), and LS7266Write().

#define EFLAG_RESET   0x86
 

Definition at line 88 of file dro.c.

#define INDEX_DISABLE   0xE0
 

Definition at line 89 of file dro.c.

#define INPUT_SETUP   0xC1
 

Definition at line 78 of file dro.c.

#define QUAD_X1   0xA8
 

Definition at line 79 of file dro.c.

#define QUAD_X2   0xB0
 

Definition at line 80 of file dro.c.

#define QUAD_X4   0xB8
 

Definition at line 81 of file dro.c.

#define TRSFRCNTR_OL   0x90
 

Definition at line 87 of file dro.c.

#define TRSFRPR_CNTR   0x08
 

Definition at line 86 of file dro.c.

#define inportb port       (0)
 

Definition at line 71 of file dro.c.

Referenced by LS7266Init(), and LS7266Read().

#define outportb port,
val       {printf("outportb(%d (0x%X),%d)\n",port,port,val);}
 

Definition at line 72 of file dro.c.

Referenced by LS7266Init(), LS7266Read(), and LS7266Write().


Function Documentation

int LS7266Init void   
 

Definition at line 102 of file dro.c.

Referenced by __attribute__().

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.

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 }


Variable Documentation

int BASE7266 = 0x200 [static]
 

Definition at line 91 of file dro.c.

int Present[4] = {1, 1, 1, 1} [static]
 

Definition at line 92 of file dro.c.


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