I'm trying to set the control bit 5 of the control register of the parallel port of my PC running windows XP . But the bit doesn't set at all and remains at logic 0....but the other bits of control register can be set or reset...I'm trying to do this using a C program.....
The program runs fine but My ECP parallel port doesnt set itself in byte mode/bidirectional mode...
******************
#include <stdio.h>
#include <windows.h>
#include <conio.h>
/* Definitions in the build of inpout32.dll are: */
/* short _stdcall Inp32(short PortAddress); */
/* void _stdcall Out32(short PortAddress, short data); */
/* prototype (function typedef) for DLL function Inp32: */
#define PPORT_BASE (0x378)
#define PPORT_CTRL (PPORT_BASE+2)
typedef short _stdcall (*inpfuncPtr)(short portaddr);
typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);
int main()
{
HINSTANCE hLib;
inpfuncPtr inp32;
oupfuncPtr oup32;
short x,y;
int i,pinput;
/* Load the library */
hLib = LoadLibrary("inpout32.dll");
if (hLib == NULL) {
printf("LoadLibrary Failed.\n");
return -1;
}
/* get the address of the function */
inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");
if (inp32 == NULL) {
printf("GetProcAddress for Inp32 Failed.\n");
return -1;
}
oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");
if (oup32 == NULL) {
printf("GetProcAddress for Oup32 Failed.\n");
return -1;
}
/***************************************************************/
/* now test the functions */
/***** One more time, different value */
i=0x37A;
/***** And read back to verify */
(oup32)(PPORT_CTRL, 0xEF);
x = (inp32)(i);
printf("port read (%04X)= %04X\n",i,x);
FreeLibrary(hLib);
getch();
return(0);
}