/*********************************************************************** * pport.cpp * * Parallel port access routines for the Windows environment. These * functions must be linked against dlportio.lib. * * Bits of the various registers are complemented according to the * inversions present on the parallel port itself and the XS40 board. ***********************************************************************/ #include #include #include "pport.h" /*********************************************************************** * void writeDataReg(unsigned char d) * * d's value is written to the data register of the given parallel port. * Note that bit 7 must be kept high to avoid re-programming the FPGA. * ***********************************************************************/ void writeDataReg(unsigned char d) { DlPortWritePortUchar(PORT_BASE, 0x80 | (d ^ DATA_MASK)); } /*********************************************************************** * unsigned char readStatusReg(void) * * Returns the value of the given parallel port's status register. * The return value is first shifted right by three to eliminate the * three "ghost" bits. ***********************************************************************/ unsigned char readStatusReg(void) { return (DlPortReadPortUchar(PORT_BASE + STATUS_OFFSET) ^ STATUS_MASK) >> 3; } /*********************************************************************** * void writeControlReg(unsigned char c) * * c's value is written to the control register of the given parallel * port. ***********************************************************************/ void writeControlReg(unsigned char c) { DlPortWritePortUchar(PORT_BASE + CONTROL_OFFSET, c ^ CONTROL_MASK); }