Component: IO Expander (Comms: System)

From Flowcode Help
Jump to navigationJump to search
Author Matrix TSL
Version 1.0
Category Comms: System


IO Expander component

Provides 16 digital input/output pins arranged into two 8-bit ports using a SPI bus connection. Multiple expanders can be connected to the same SPI peripheral by means of individual chip select pins.

Detailed description

No detailed description exists yet for this component


Examples

More information on I2C can be found here,

Matrix Flowcode Blog: Simplified communications I2C and SPI


Generic I2C EEPROM

Example file demonstrating how to read and write bytes from a generic I2C EEPROM device. FC6 Icon.png I2CEEPROM

Simulated I2C devices

This example uses the I2C master component combined with the DS1307 injector to simulate an I2C communications bus between the target Microcontroller and the virtual DS1307 device. FC6 Icon.png I2C DS1307 Example The panel displays the current time from the DS1307 RAM which is populated to match the system time.

DS1307Panel.jpg


The I2C console shows the communications between the target microcontroller and simulated I2C device.

DS1307Data.jpg


The DS1307 console shows the contents of RAM memory on the simulated I2C device.

DS1307Ram.jpg






Downloadable macro reference

Fc9-comp-macro.png ReadPort
Reads a value to one of the ports with a mask. Configures the masked bits to be inputs before reading the input value. 
Fc9-u8-icon.png - BYTE Port
0=PortA, 1=PortB 
Fc9-u8-icon.png - BYTE Mask
Allows port bits to be modified without effecting other bits, 255 = write full port. 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png ConfigureInversion
Configures the pin inversion for the two ports. Disabled on all pins by default. 
Fc9-u8-icon.png - BYTE PortA
Port A inversion sent as an 8-bit value, 0 = Disabled, 1 = Enabled 
Fc9-u8-icon.png - BYTE PortB
Port B inversion sent as an 8-bit value, 0 = Disabled, 1 = Enabled 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReadPortPin
Reads a single port pin from one of the ports. Configures the pins to be an input before reading the input value. Returns 0 or 1 corresponding to the value on the port pin. 
Fc9-u8-icon.png - BYTE Port
0=PortA, 1=PortB 
Fc9-u8-icon.png - BYTE Pin
Port pin to read. Range: 0-7 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png WritePortPin
Writes a single port pin on one of the ports. Configures the pins to be an output before writing the input value.  
Fc9-u8-icon.png - BYTE Port
0=PortA, 1=PortB 
Fc9-u8-icon.png - BYTE Pin
Port pin to read. Range: 0-7 
Fc9-u8-icon.png - BYTE Value
Value to output on the selected pin. Range: 0-1 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png WritePort
Writes a value to one of the ports with a mask. Configures the masked bits to be outputs before writing the output value. 
Fc9-u8-icon.png - BYTE Port
0=PortA, 1=PortB 
Fc9-u8-icon.png - BYTE Mask
Allows port bits to be modified without effecting other bits, 255 = write full port. 
Fc9-u8-icon.png - BYTE Value
Value to write. Range 0-255 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ConfigurePullups
Configures the pullups for the two ports. Disabled on all pins by default. 
Fc9-u8-icon.png - BYTE PortA
Port A pull ups sent as an 8-bit value, 0 = Disabled, 1 = Enabled 
Fc9-u8-icon.png - BYTE PortB
Port B pull ups sent as an 8-bit value, 0 = Disabled, 1 = Enabled 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReadRegister
Reads an 8-bit value from a register on the I/O expander device. 
Fc9-u8-icon.png - BYTE Address
Register address to write to. Range: 0-15 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png WriteRegister
Writes an 8-bit value to a register on the I/O expander device. 
Fc9-u8-icon.png - BYTE Address
Register address to write to. Range: 0-15 
Fc9-u8-icon.png - BYTE Value
Value to write. Range: 0-255 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Enables the I²C hardware and performs some initialization. Should be called at the start of the program or at least before any of the other I²C functions are called. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png CheckNetworkStatus
Returns the state of the GSM network. 0 = Not connected, 1 = connected, 255 = no reply from GSM. 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png CheckForIncoming
Checks to see if any incoming phone call or SMS message. 0 = Nothing, 1 = Text Received, 2 = Phone Ringing 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png Initialise
Sets up the GSM module. Returns 0 for OK, 255 for no reply and 254 for command fail. 
Fc9-u8-icon.png - BYTE Return



Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png External Address
Selects the value of the three address pins for the MCP23S17. 
Fc9-type-16-icon.png Channel
SPI Channel selector 
Fc9-type-16-icon.png Prescale
Prescale option selector 
Fc9-type-5-icon.png MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
Fc9-type-5-icon.png MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
Fc9-type-5-icon.png CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
Fc9-type-5-icon.png CS / SS
Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
Fc9-type-7-icon.png Use Reset
 
Fc9-conn-icon.png Connections
Fc9-conn-icon.png Simulations
Fc9-type-10-icon.png Label
 
Fc9-type-7-icon.png Scope Traces
Selects if the scope traces are automatically generated or not 
Fc9-type-7-icon.png Console Data
Selects if the console data is automatically generated or not 
Fc9-type-16-icon.png API