https://www.brandywinecomm.com/wp-content/themes/brandywine/library/images/default-banner.png0
Category Name > Knowledge Base
KB00321: Windows Drivers for PC/104 SyncClock

Below is a source code example modifying DOS curtime.c example to use free IODLL library.

Web link for IODLL is http://www.geekhideout.com/iodll.shtml

There is also a product called TVicHW32:
http://www.entechtaiwan.com/dev/hw32/faq.shtm


// curtime.cpp : Defines the entry point for the console application.

// curtime.c 13nov95 demonstrates reading current time from PC104-SG

#define BASE 0x300

#include "stdafx.h"

#include "104sgdef.h"

#include "sgdpdef.h"

#include

#include

#include

#include

#define MAXMODULE 50

typedef void (WINAPI*cccfunc)(short int Port,char Data);

typedef char (WINAPI*ccfunc)(short int Port);

ccfunc PortIn;

cccfunc PortOut;

/* void PortOut(short int Port, char Data);

void PortWordOut(short int Port, short int Data);

void PortDWordOut(short int Port, int Data);

char PortIn(short int Port); */

short int PortWordIn(short int Port);

int PortDWordIn(short int Port);

void SetPortBit(short int Port, char Bit);

void ClrPortBit(short int Port, char Bit);

void NotPortBit(short int Port, char Bit);

short int GetPortBit(short int Port, char Bit);

short int RightPortShift(short int Port, short int Val);

short int LeftPortShift(short int Port, short int Val);

short int IsDriverInstalled();

int Read_Dual_Port_RAM(char addr);

int main(int argc, char* argv[])

{

#define BASE 0x300

int i;int timechar[9];

HINSTANCE hLib=LoadLibrary("IO.DLL");

if(hLib==NULL) {

cout << "Unable to load library!" << endl;

getch();

return(0);

}

char mod[MAXMODULE];

GetModuleFileName((HMODULE)hLib, (LPTSTR)mod, MAXMODULE);

cout << "Library loaded: " << mod << endl;

PortIn=(ccfunc)GetProcAddress((HMODULE)hLib, "PortIn");

PortOut=(cccfunc)GetProcAddress((HMODULE)hLib, "PortOut");

if((PortIn==NULL) || (PortOut==NULL)) {

cout << "Unable to load function(s)." << endl;

FreeLibrary((HMODULE)hLib);

return(0);

}

while (1)

{

for (i=0;i<=8;i++)

/* always read Usec1_Nsec100_Port first, latching hi-order ports */

/* Then, other current time ports can be read */

/* partially or completely in any order */

/* this example reads ALL the current time ports, and then displays them */

{timechar[i]=PortIn(BASE+Usec1_Nsec100_Port-i);}

for (i=8;i>=0;i--)

{printf("%02x " ,timechar[i]&0x0ff);}

i=Read_Dual_Port_RAM(DP_Extd_Sts);

printf("DP Extd status: %2x \n",i);

}

FreeLibrary((HMODULE)hLib);

return (0);

}

int Read_Dual_Port_RAM(char addr)

#define BASE 0x300

{

char response;

response=PortIn(BASE+Dual_Port_Data_Port); /* clear response flag */

PortOut((short int)(BASE+Dual_Port_Address_Port) ,addr);

while ((PortIn(BASE+Extended_Status_Port)&Response_Ready) ==0) {;}

response=PortIn(BASE+Dual_Port_Data_Port);

return response;

}

Supportscreen tag