GPIO Type

As far as general-purpose I/O (GPIO) lines go, Tibbo devices fall into two categories:

To find out what type of GPIO lines are on your device, refer to its platform documentation (for example, EM1000's is here).


Devices With Unidirectional GPIO Lines

On such devices, you need to explicitly enable or disable the output driver of each I/O line (controlled by the io. object). When the device boots up, all pins are configured as inputs. If you want to use any particular I/O pin as an output, enable this pin's output driver first (set io.enabled = 1 — YES):

Tibbo BASIC or C
...
io.num= PL_IO_NUM_5	'select the line
io.enabled= YES		'enable output driver (you need to do this only once)
io.state= LOW		'set the state
...

A warning note icon.Make sure that your external circuitry does not attempt to drive the I/O lines that have their output drivers enabled. Severe damage to the device and/or your circuitry may occur if this happens!

When the driver is enabled (io.enabled = 1 — YES) and you read the state of the pin, you get back the state of your own output driver. To turn the line into an input, switch the output driver off (io.enabled = 0 — NO). This will allow you to sense the state of the external signal applied to the I/O line:

Tibbo BASIC or C
...
io.num= PL_IO_NUM_4	'just to select some line as an example
io.enabled= NO		'now the output driver is off
x=io.state			'read line state into x
...

There is the io.portenabled property as well. It allows simultaneous configuration of all GPIO lines in an 8-bit I/O port.

Serial port lines also require proper configuration. See Serial Port Line Configuration for the details.


Devices With Bidirectional GPIO Lines

The I/O lines of these devices do not require explicit configuration as inputs or outputs. All lines are "quasi-bidirectional" and can be viewed as open collector outputs with weak pull-up resistors. To "measure" an external signal applied to an I/O line, set this line to HIGH first, then read the state of the line. It is OK to drive the line LOW externally when the same line outputs HIGH internally. The io.enabled and io.portenabled properties exist, but only for compatibility with other platforms. Writing to these properties has no effect and reading them always returns 1 — YES and 255 (all lines enabled), repsectively.

To sense the state of an external signal applied to an I/O line, set the line to HIGH first:

Tibbo BASIC or C
...
io.num= PL_IO_NUM	'just to select some line as an example
io.state= HIGH	'now we can read the line
x=io.state		'read line state into x
...

The serial port lines of devices with bidirectional GPIOs do not require configuration.


GPIO Type

Devices With Unidirectional GPIO Lines

Devices With Bidirectional GPIO Lines