:html
:Revision=1
<<
128.149
McdPioCard-Object|McdPioCard
--
The IP object <!RW>McdPioCard allows the direct access to PC-IO24 PIO cards. 

These cards consist of a 8255 PIO chip with 24 IO lines and a 8253 chip with 3 separate 16 bit counters.

Cards are addressed by their base address (ranging from $300 to $3F8, divisible by 8). The cards don't have to be registrated in the system. Be careful when assigning an address, since the program can't control if a PIO card or something else is present at the address. The address range is inside the range for custom cards and so another card could be present at this address. 

Since the access is done directly, without any hardware driver component, for newer operation systems (NT, 2000, XP ...) a special driver has to be installed to disable the IO-protection of this opertaion systems. Make sure, the GiveIO driver is installed. 
>>
<<
128.149.2
Access to IO ports|Port
--
Access to the three 8 bit ports of the 8255 chip. 

Select the data direction with the <!RW>McdPioCard.Port.Init command before using any input or output command.
>>
<<
128.149.2.1
McdPioCard.Port.Bits|Bits
--
<!DEF>
procedure <!TW>McdPioCard.Port.Bits (rCardAddr, rPortNr, rBits, rOperation : real);
<!TXT>
This command changes distinct bits of a port <!PW>rPortNr (0 = port A, 1 = port B, 2 = port C) of the PC-24IO PIO card at the base address<!PW>rCardAddr.

The actual bits of the port are combined with the value of <!PW>rBits as defined by <!PW>rOperation and sent to the output.

 <!PW>rOperation can be : <!RW>CLR | <!RW>SET | <!RW>FLIP | <!RW>NOP oder 0..3
>>
<<
128.149.2.2
McdPioCard.Port.Word|Word
--
<!DEF>
procedure <!TW>McdPioCard.Port.Word (rCardAddr, rPortNr, rData: real);
<!TXT>
This command sets the whole port <!PW>rPortNr (0 = port A, 1 = port B, 2 = port C) of the PC-24IO PIO card at the base address<!PW>rCardAddr.

The output register of the port is set to the bit pattern given in <!PW>rData.
>>

<<
128.149.2.3
McdPioCard.Port.BitsEx|BitsEx
--
<!DEF>
procedure <!TW>McdPioCard.Port.BitsEx (rCardAddr, rPortNr, rGroup : real; sCommand : string);
<!TXT>
Macro commando : Set/erase bits on McdPioCards and wait

This command accesses port <!PW>rPortNr (0 = port A, 1 = port B, 2 = port C) of the PC-24IO PIO card at the base address<!PW>rCardAddr.

 <!PW>rGroup selects an action group (0..9)

 <!PW>sCommand has this format:

<!CODE>
<!SW>Bitpattern,<!SW>Action[,<!SW>Action...][;<!SW>Bitpattern,<!SW>Action[,<!SW>Action...]...]
<!TXT>

 <!SW>Bitpattern is a  8 bit word

 <!SW>Action has the following format (n is the group number 0..9 or 'x') :
<!STBL>
<!>nS<!>Set the bits<!>
<!>nR<!>Clear the bits<!>
<!>nDz<!>Delay of z milli seconds<!>
<!ETBL>

 <!SW>n selects the group. Only such actions will be executed, that have the group number selected by parameter <!PW>rGroup. 'x' will fit always.

<ul indent=12>
<li>If no action matches <!PW>rGroup, nothing happens.</li>
<li>If no actions are specified, nothing happens.</li>
<li>If <!PW>sCommand is empty, nothing happens.</li>
</ul>

Example
<!CODE>
McdPioCard.Port.BitsEx ($310, 0, 1, '5,1r,9s,1d100,9d50');

'$310, 0' selects port A on the card at address $310.
 
The '1' activates group 1.

The parts of <!PW>sCommand:
'5'     is the bit pattern
'1r'    if group 1 is active, the bits will be cleared
'9s'    if group 9 is active, the bits will be set
'1d100' if group 1 is active, make a delay of 100 ms
'9d50'  if group 1 is active, make a delay of 50 ms

Since Group 1 is active, the bits will be cleared and an delay of 100ms will be waited.
<!TXT>
>>
<<
128.149.2.4
McdPioCard.Port.Get|Get
---
<!DEF>
function <!TW>McdPioCard.Port.Get (rCardAddr, rPortNr : real) : real;
<!TXT>
This command accesses port <!PW>rPortNr (0 = port A, 1 = port B, 2 = port C) of the PC-24IO PIO card at the base address<!PW>rCardAddr.

The port is read and the bit pattern is returned.
>>

<<
128.149.2.5
McdPioCard.Port.Init|Init
--
<!DEF>
procedure <!TW>McdPioCard.Port.Init (rCardAddr, rAIn, rBIn, rCLIn, rCHIn : real);
<!TXT>
Selects the data direction of the ports of the PC-24IO card at base address<!PW>rCardAddr.

If the respective parameter is <!RW>TRUE, the port (part) will be an input, otherwise an output.

 <!PW>rAIn selects the data direction for port A (A0..A7)
 <!PW>rBIn selects the data direction for port B (B0..B7) 
 <!PW>rCLIn selects the data direction for the lower nibble of port C (C0..C3) 
 <!PW>rCHIn selects the data direction for the upper nibble of port C (C4..C7) 

When this command is used, all output ports will be reset. This is a built in function of the 8255 chip.
>>

<<
128.149.3
Access to counters|Counter
--
>>

<<
128.149.3.1
McdPioCard.Counter.Mode|Mode
--
<!DEF>
procedure <!TW>McdPioCard.Counter.Mode (rCardAddr, rCounterNr, rMode : real);
<!TXT>
Selects the operation mode for counter <!PW>rCounterNr (0..2) of the PC-24IO card at the base address <!PW>rCardAddr.
<!STBL>
<!+>rMode<!>Operation mode<!>
<!c>0<!>Interrupt on terminal count<!>
<!c>1<!>Programmable one shot<!>
<!c>2<!>Rate generator<!>
<!c>3<!>Square wave rate generator<!>
<!c>4<!>Software triggered strobe<!>
<!c>5<!>Hardware triggered strobe<!>
<!ETBL>
For a detailed discussion of the modes see the datasheet for the 8253 chip.
>>

<<
128.149.3.2
McdPioCard.Counter.Set|Set
--
<!DEF>
procedure <!TW>McdPioCard.Counter.Set (rCardAddr, rCounterNr, rValue : real);
<!TXT>
Set the counting register of counter <!PW>rCounterNr (0..2) of the PC-24IO card at the base address <!PW>rCardAddr to the value of <!PW>rValue (0..65535).
>>
<<
128.149.3.3
McdPioCard.Counter.Get|Get
--
<!DEF>
function <!TW>McdPioCard.Counter.Get (rCardAddr, rCounterNr : real) : real;
<!TXT>
Read the value of the counting register of counter <!PW>rCounterNr (0..2) of the PC-24IO card at the base address <!PW>rCardAddr.
>>
