Line/Port Manipulation Without Preselection

I/O line manipulation without preselection is good when you need to deal with several I/O lines at once. For this, use the io.lineset, io.lineget, and io.invert methods. These methods require the line number to be supplied directly, as a parameter. Therefore, preselection with the io.num property is not necessary. Moreover, executing these methods leaves the io.num value intact.

Here is an example of a serialized clock/data output. The clock line is PL_IO_NUM_0 and the data line is PL_IO_NUM_1. Notice how this is implemented — the clock line is preselected once, then set LOW and HIGH using the io.state property. Meanwhile, the data line is updated using the io.lineset method. The variable x supposedly carries a bit of data to be output (where x gets is data is not shown).

Tibbo BASIC
Dim f As Byte
Dim x As low_high
 
io.num=PL_IO_NUM_0 'pre-select the clock line
For f=0 To 7
   ... 'obtain the value of the next bit, put it into x (not shown)
   io.state=LOW 'set the clock line LOW (the clock line has already been preselected)
   io.lineset(PL_IO_NUM_1,x) 'output the next data bit
   io.state=HIGH 'set the clock line HIGH (the clock line has already been preselected)
Next f

Direct port manipulation is achieved using the io.portset and io.portget methods.

Note that I/O line and port names are platform-specific and are defined by the pl_io_num  and pl_io_port_num enums, respectively. The declarations for these enums can be found in your device's platform documentation (for example, the EM1000's is here).

On many devices, a number of I/O lines may be shared with inputs/outputs of special function blocks (serial ports, etc.). When a special function block is enabled, the I/O lines it uses cannot (should not) be manipulated though the io. object.