|Top Previous Next|
As for as GPIO lines go, Tibbo devices fall into two categories:
•Devices with unidirectional GPIO lines: such devices require explicit configuration of each GPIO line as input or output; and
•Devices with bidirectional GPIO lines: GPIO lines of these devices work as outputs and inputs at the same time.
To find out the type of GPIO lines 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 the output, enable this pin's output driver first (set io.enabled= 1-YES):
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 (ser.enabled= 0- NO). This will allow you to sense the state of the external signal applied to the I/O line:
There is the io.portenabled property as well. It allows simultaneous configuration of all GPIO lines in the 8-bit I/O port.
Devices with bidirectional GPIO lines
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. 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) correspondingly.
To sense the state of the external signal applied to the I/O line, set the line to HIGH first:
Serial port lines of devices with bidirectional GPIO do not require configuration as well.