IEEE-1284 / Centronix / Parallel Port

C code for ECP mode interface on a Windows 95 PC

Simon Nield [simon.nield at quantel.com] says:

one thing to bear in mind when accessing the parallel port in epp mode is that it _does_ drop back into spp mode between reads / writes, so make sure you set up the spp mode correctly first.

I have pasted a small code snippet below that worked fine in Win95.

The hardware end of this code was an Altera 7k128 in case you were wondering.

unsigned short PORT=0x378;  // parallel base port

typedef struct FooCtrl
{
     short position;
} FooCtrl;

void TalkToFooCtrl( FooCtrl *testboard, unsigned short base, short pwm)
{
     unsigned short address_port, data_port, control_port;
     short position_delta;

     control_port = base + 2; // SPP control port
     address_port = base + 3; // EPP address port
     data_port    = base + 4; // EPP data port

     _outp(control_port, 0x00);    // ensure strobes deasserted in between EPP transfers
     _outp(address_port, pwm);
     _outp(data_port, pwm >> 8);
     position_delta = _inp(data_port);
     position_delta = position_delta << 8;
     position_delta += _inp(address_port);

     testboard->position = position_delta;
}


Interested: