Module zio :: Class GPIO

Class GPIO

object --+    
         |    
    Module --+
             |
            GPIO

GPIO class is used to control devices over general purpose IO pins.
Instance Methods
 
__init__(self, agent)
Constructs an GPIO object.
 
pin_type(self, pin)
Returns the type of the pin - TYPE_BIDIR, TYPE_INPUT or TYPE_OUTPUT.
 
write_port(self, data, mask)
Drives out data on multiple output pins.
 
write_pin(self, pin, value)
Drives out data on specified pin.
int
read_port(self)
Reads out data on all pins.
int
read_pin(self, pin)
Reads the specified pin.

Inherited from Module: do_op

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  TYPE_BIDIR = 0
Constant indicates pin type bi-directional (open-drain).
  TYPE_INPUT = 1
Constant indicates pin type input.
  TYPE_OUTPUT = 2
Constant indicates pin type output.
Properties
  input_pin_count
The no.
  output_pin_count
The no.
  bidir_pin_count
The no.

Inherited from object: __class__

Method Details

__init__(self, agent)
(Constructor)

 
Constructs an GPIO object.
Parameters:
  • agent (Agent) - the agent interface object
Raises:
  • ProtocolError - If communication with agent fails or if data sent or received is corrupted
Overrides: object.__init__

pin_type(self, pin)

 
Returns the type of the pin - TYPE_BIDIR, TYPE_INPUT or TYPE_OUTPUT.
Parameters:
  • pin (int) - the pin whose type is required.

write_port(self, data, mask)

 
Drives out data on multiple output pins.
Parameters:
  • data (int) - the data to be driven on the pins
  • mask (int) - indicates which pins are to be modified, 1 - pin will be affected, 0 - pin will not be affected
Raises:
  • ProtocolError - If communication with agent fails or if data sent or received is corrupted

write_pin(self, pin, value)

 
Drives out data on specified pin.
Parameters:
  • pin (int) - the pin to be driven
  • value (int) - the value to be driven
Raises:
  • ProtocolError - If communication with agent fails or if data sent or received is corrupted

read_port(self)

 
Reads out data on all pins.
Returns: int
the data read from the pins.
Raises:
  • ProtocolError - If communication with agent fails or if data sent or received is corrupted

read_pin(self, pin)

 
Reads the specified pin.
Parameters:
  • pin (int) - the pin to be read
Returns: int
the data read from the pin
Raises:
  • ProtocolError - If communication with agent fails or if data sent or received is corrupted

Property Details

input_pin_count

The no. of input pins supported by the interface kit.
Get Method:
_get_input_pin_count(self)

output_pin_count

The no. of output pins supported by the interface kit.
Get Method:
_get_output_pin_count(self)

bidir_pin_count

The no. of bi-directional pins supported by the interface kit.
Get Method:
_get_bidir_pin_count(self)