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 C
byte x = 0;
io.num = PL_IO_NUM_0;				// Pre-select the clock line
for (byte i = 0; i < 8; i++) {	// 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)
}

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

I/O line and port names are defined by the pl_io_num and pl_io_port_num enums, respectively.

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.