.. module:: sx1503 ************** SX1503 Module ************** .. _datasheet: http://www.semtech.com/images/datasheet/sx150x.pdf This module contains the Zerynth driver for Semtech SX1503 low voltage General Purpose parallel Input/Output. The unit allows easy serial expansion of I/O through a standard 400kHz I2C interface. Interrupt handling and programmable logic functions are not implemented (datasheet_). =============== SX1503 class =============== .. class:: SX1503(drvname, clk=400000) Creates an intance of the SX1503 class. :param drvname: I2C Bus used '( I2C0, ... )' :param clk: Clock speed, default 400kHz Example: :: from semtech.sx1503 import sx1503 ... port_expander = sx1503.SX1503(I2C1) port_expander.pinMode(10,INPUT_PULLUP) state = port_expander.digitalRead(10) port_expander.pinMode(0,OUTPUT) port_expander.digitalWrite(0,HIGH) .. method:: pinMode(pin, mode) Select a mode for a pin. Valid *pin* values are from ``0`` to ``15`` included. Available modes are: * ``INPUT`` * ``INPUT_PULLUP`` * ``INPUT_PULLDOWN`` * ``OUTPUT`` .. method:: get_port(port) Returns the state of all pins on port *port*. As a consequence of having 8 pins for port, returned value can be between ``0`` and ``255``. ===== ======== ========= port I/O bank pins ===== ======== ========= 0 A 0 to 7 1 B 8 to 15 ===== ======== ========= .. method:: digitalRead(pin) Returns the state of pin *pin*. The state can be ``0`` or ``1``. .. method:: digitalWrite(pin, val) Set pin *pin* to value *val*. Value can be ``0`` or ``1``. .. method:: set_port(port, val) Set all pins on port *port* to value *val*. *val* MUST be between ``0`` and ``255``. .. method:: set_boost(mode) Set the boost mode (cfr. par 2.2.1 of the datasheet). ===== ============ mode boost mode ===== ============ 0 OFF 1 ON ===== ============