From 70b8b7f2d766f4ca131f9fa299546eb3697db8d4 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 23 Mar 2017 20:42:26 +0100 Subject: changed scheme layout hw: changed scheme and annotated components doc: added build script for windows sw: added res/ folder with blaster and created jedec document for address decoder pld --- .../userport/UserPort/Examples/IOPort.pas | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 res/ATFBlast_ALL/userport/UserPort/Examples/IOPort.pas (limited to 'res/ATFBlast_ALL/userport/UserPort/Examples/IOPort.pas') diff --git a/res/ATFBlast_ALL/userport/UserPort/Examples/IOPort.pas b/res/ATFBlast_ALL/userport/UserPort/Examples/IOPort.pas new file mode 100644 index 0000000..941240c --- /dev/null +++ b/res/ATFBlast_ALL/userport/UserPort/Examples/IOPort.pas @@ -0,0 +1,72 @@ +unit IOPort; + +interface +uses windows; + +procedure outport(portid : integer; value : integer); +procedure outportb(portid : integer; value : BYTE); +function inportb(portid : integer) : byte; +function inport(portid : integer) : integer; +function StartUpIoPorts(PortToAccess : integer) : boolean; + +implementation + +var + bPrivException : boolean; + +procedure outport(portid : integer; value : integer); +Begin + asm + mov edx,portid; + mov eax,value; + out dx,ax; + end; +end; + +procedure outportb(portid : integer; value : BYTE); +Begin + asm + mov edx,portid + mov al,value + out dx,al + end; +end; + +function inportb(portid : integer) : byte; +Var value : byte; +Begin + asm + mov edx,portid + in al,dx + mov value,al + end; + inportb := value; +end; + +function inport(portid : integer) : integer; +Var value : integer; +Begin + value := 0; + asm + mov edx,portid + in ax,dx + mov value,eax + end; + inport := value; +end; + +function StartUpIoPorts(PortToAccess : integer) : boolean; +Var hUserPort : THandle; +Begin + hUserPort := CreateFile('\\.\UserPort', GENERIC_READ, 0, nil,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + CloseHandle(hUserPort); // Activate the driver + Sleep(100); // We must make a process switch + + try + inportb(PortToAccess); // Try to access the given port address + except + MessageBox(0,'fel','fel',MB_OK); + end; +end; + +end. \ No newline at end of file -- cgit v1.2.1