Provide digital inputs and outputs.
Module RB8506 is a (dual) parallel interface. Internally the module may contain Motorola Peripheral Interface Adapter MC6821 (Pia) ICs or Rockwell Versatile Interface Adapater R6522 (Via) ICs or a combination of both.
The following variations of this module are known to exist:
You should create a separate object for each Pia/Via in a Parallel Interface module.
The Parallel Interface front-panels look as follows.
dual single
+----------------------+ +-----------+
| Parallel Interface | | Parallel |
| | | Interface |
| Pia 1 Pia 2 | | |
| pb0 pb4 | | pb0 |
| == (o) (o) | | (o) |
| |..| pb1 pb5 | | pb1 |
| |..| (o) (o) | | (o) |
| |..| pb2 pb6 | | P pb2 |
| |..| (o) (o) | | I (o) |
| |..| pb3 pb7 | | A pb3 |
| |..| (o) (o) | | 2 (o) |
| == cb1 cb2 | | cb1 |
| (o) (o) | | (o) |
| | | |
| RULBUS | | RULBUS |
+----------------------+ +-----------+
PIA and VIA offer the following interface pins.
port pin direction description
A PA0..PA7 i/o level inputs and outputs
A CA1 input active edge transition sets interrupt flag
A CA2 i/o complex operation
B PB0..PB7 i/o level inputs and outputs
B CB1 input active edge transition sets interrupt flag
B CB2 i/o complex operation
See Pia and Via for a more detailed description of the IC's capabilities.
The 50-pin connector for Pia 1 makes all its pins of Port A and Port B available. Of Pia 2, the BNC-connectors provide access to only Port B pins.
See pport.cpp for an example program. It contains several bit-manipulation functions.
The RB8506 parallel interface module has no properties that are configured at production time.
rb8506_pia "name1" { address = 0x90 } rb8506_via "name2" { address = 0x90 }
When the Rulbus configuration file is read, the parallel interface ports are left unchanged.
There are three groups of functions:
The port-related functions allow you to read or write a complete port at one time, or to get or set its data direction.
However, if you want to act on a single line, the line-related functions are more convenient to use.
The following tables show the port names and the bit-positions for the various peripheral lines as used in the port-related functions and the line names and data-direction specifications for the line-related functions.
bit direction active edge
port 7 6 5 4 3 2 1 0 line in out neg pos
------------------------------- -------------------------------
"PA" PA7 . . . . . . PA0 "PAn" 'i' 'o'
"CA" CA2 CA1 "CA1" 'n' 'p'
"CA2" 'i' 'o'
"PB" PB7 . . . . . . PB0 "PBn" 'i' 'o'
"CB" CB2 CB1 "CB1" 'n' 'p'
"CB2" 'i' 'o'
peripheral lines bit-positions peripheral lines data-direction
for port-related functions for line-related functions
(i/o and data-direction) (n: 0..7)
When setting data direction, a 0 in the bitmask makes a line input, whereas a 1 makes it an output. For CA1 and CB1, a 0 makes the input act on the negative edge, a 1 makes it sensitive to the positive, upgoing edge.
When setting output, a 0 in the bitmask makes the line level low, whereas a 1 makes it high.
When reading data-direction from port CA or CB, the CA1 and CA2 (CB1 and CB2) data-direction settings are combined as follows:
int dir = ( getDirCA2() != 'i' ) << 1 ) | getEdgeCA1() != 'n';
When reading port CA, or CB the CA1 and CA2 (CB1 and CB2) lines are combined as follows:
int data = ( getLineCA2() << 1 ) | getIrqCA1();
So to set PB0..PB1 and CB2 to output and to set PB2..PB3 to input, you may write:
rb8506_pport_setPortDir( handle, "PB", 0x03 ); rb8506_pport_setPortDir( handle, "CB", 0x02 );
Note that this ignores the previous data-direction setting: it also sets PB4..PB7 to input.
The following code also sets PB0..PB1 and CB2 to output and PB2..PB3 to input, but leaves the other lines unaffected.
rb8506_pport_setLineDir( handle, "PB0", 'o' ); rb8506_pport_setLineDir( handle, "PB1", 'o' ); rb8506_pport_setLineDir( handle, "CB2", 'o' ); rb8506_pport_setLineDir( handle, "PB2", 'i' ); rb8506_pport_setLineDir( handle, "PB3", 'i' );
To do the equivalent with the port-related functions you could write:
int32 dir; rb8506_pport_getPortDir( handle, "PB", &dir ); rb8506_pport_setPortDir( handle, "PB", (dir & ~0x0F ) | 0x03 ); rb8506_pport_getPortDir( handle, "CB", &dir ); rb8506_pport_setPortDir( handle, "CB", dir | 0x02 );
With dir & ~0x0F we first clear the bits for lines we want to define, PB0..PB3 (0x0F is 00001111 binary).
Note that for CB2 we just as well could write rb8506_pport_setPortDir( handle, "CB", 0x02 ) as before, since it is the only output-capable line of port CB (setting CB1's data-direction is silently ignored).
To address specific pins in port data, you need to use a bitmask. For example, a bitmask of 0x21 specifies pin 0 and pin 5. The mask can also be made with:
1 << 5 | 1 << 0
Having read direction or data, you use the bitmask to select the pin(s) you are interested in, for example:
char dir_pin5 = ( direction_read & (1 << 5) ) ? 'o' : 'i';
See pport.cpp for an example program. It contains several bit-manipulation functions.
Open and close | |
| EXPORT int32 RDL_API | rb8506_pport_open (int32 *pHandle, CCstr name) |
| open a PIA or a VIA. | |
| EXPORT int32 RDL_API | rb8506_pport_close (int32 handle) |
| close a PIA. | |
Data direction | |
| EXPORT int32 RDL_API | rb8506_pport_getPortDir (int32 handle, CCstr port, int32 *pDir) |
| get port data direction. | |
| EXPORT int32 RDL_API | rb8506_pport_setPortDir (int32 handle, CCstr port, int32 dir) |
| set port data direction. | |
| EXPORT int32 RDL_API | rb8506_pport_getLineDir (int32 handle, CCstr line, char8 *pDir) |
| get line direction. | |
| EXPORT int32 RDL_API | rb8506_pport_setLineDir (int32 handle, CCstr line, char8 dir) |
| set line direction. | |
Data input and output | |
| EXPORT int32 RDL_API | rb8506_pport_getPortData (int32 handle, CCstr port, int32 *pData) |
| get port data. | |
| EXPORT int32 RDL_API | rb8506_pport_setPortData (int32 handle, CCstr port, int32 data) |
| set port data. | |
| EXPORT int32 RDL_API | rb8506_pport_getLineLevel (int32 handle, CCstr line, int32 *pLevel) |
| get line level. | |
| EXPORT int32 RDL_API | rb8506_pport_setLineLevel (int32 handle, CCstr line, int32 level) |
| set line level. | |