Jump to content

Component: IO Expander (Comms: System): Difference between revisions

From Flowcode Help
No edit summary
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
 
(4 intermediate revisions by 2 users not shown)
Line 43: Line 43:
Example file demonstrating how to read and write bytes from a generic I2C EEPROM device.
Example file demonstrating how to read and write bytes from a generic I2C EEPROM device.
{{Fcfile|I2CEEPROM.fcfx|I2CEEPROM}}
{{Fcfile|I2CEEPROM.fcfx|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.
{{Fcfile|DS1307InjectorTest.fcfx|I2C DS1307 Example}}
The panel displays the current time from the DS1307 RAM which is populated to match the system time.
[[File:DS1307Panel.jpg]]
The I2C console shows the communications between the target microcontroller and simulated I2C device.
[[File:DS1307Data.jpg]]
The DS1307 console shows the contents of RAM memory on the simulated I2C device.
[[File:DS1307Ram.jpg]]


==Downloadable macro reference==
==Downloadable macro reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadPort'''
| width="90%" class="mtx-class-macrohead" | '''ReadPort'''
|-
|-
| colspan="2" | Reads a value to one of the ports with a mask. Configures the masked bits to be inputs before reading the input value. 
| colspan="2" | Reads a value to one of the ports with a mask. Configures the masked bits to be inputs before reading the input value. 
Line 96: Line 69:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ConfigureInversion'''
| width="90%" class="mtx-class-macrohead" | '''ConfigureInversion'''
|-
|-
| colspan="2" | Configures the pin inversion for the two ports.  Disabled on all pins by default. 
| colspan="2" | Configures the pin inversion for the two ports.  Disabled on all pins by default. 
Line 119: Line 92:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadPortPin'''
| width="90%" class="mtx-class-macrohead" | '''ReadPortPin'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 142: Line 115:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WritePortPin'''
| width="90%" class="mtx-class-macrohead" | '''WritePortPin'''
|-
|-
| colspan="2" | Writes a single port pin on one of the ports. Configures the pins to be an output before writing the input value.  
| colspan="2" | Writes a single port pin on one of the ports. Configures the pins to be an output before writing the input value.  
Line 170: Line 143:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WritePort'''
| width="90%" class="mtx-class-macrohead" | '''WritePort'''
|-
|-
| colspan="2" | Writes a value to one of the ports with a mask. Configures the masked bits to be outputs before writing the output value. 
| colspan="2" | Writes a value to one of the ports with a mask. Configures the masked bits to be outputs before writing the output value. 
Line 198: Line 171:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ConfigurePullups'''
| width="90%" class="mtx-class-macrohead" | '''ConfigurePullups'''
|-
|-
| colspan="2" | Configures the pullups for the two ports. Disabled on all pins by default. 
| colspan="2" | Configures the pullups for the two ports. Disabled on all pins by default. 
Line 221: Line 194:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadRegister'''
| width="90%" class="mtx-class-macrohead" | '''ReadRegister'''
|-
|-
| colspan="2" | Reads an 8-bit value from a register on the I/O expander device. 
| colspan="2" | Reads an 8-bit value from a register on the I/O expander device. 
Line 239: Line 212:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteRegister'''
| width="90%" class="mtx-class-macrohead" | '''WriteRegister'''
|-
|-
| colspan="2" | Writes an 8-bit value to a register on the I/O expander device. 
| colspan="2" | Writes an 8-bit value to a register on the I/O expander device. 
Line 262: Line 235:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| colspan="2" |  
| colspan="2" |  
Line 275: Line 248:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| colspan="2" |  
| colspan="2" |  
Line 288: Line 261:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 301: Line 274:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckNetworkStatus'''
| width="90%" class="mtx-class-macrohead" | '''CheckNetworkStatus'''
|-
|-
| colspan="2" | Returns the state of the GSM network. 0 = Not connected, 1 = connected, 255 = no reply from GSM. 
| colspan="2" | Returns the state of the GSM network. 0 = Not connected, 1 = connected, 255 = no reply from GSM. 
Line 314: Line 287:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckForIncoming'''
| width="90%" class="mtx-class-macrohead" | '''CheckForIncoming'''
|-
|-
| colspan="2" | Checks to see if any incoming phone call or SMS message. 0 = Nothing, 1 = Text Received, 2 = Phone Ringing 
| colspan="2" | Checks to see if any incoming phone call or SMS message. 0 = Nothing, 1 = Text Received, 2 = Phone Ringing 
Line 327: Line 300:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| colspan="2" | Sets up the GSM module. Returns 0 for OK, 255 for no reply and 254 for command fail. 
| colspan="2" | Sets up the GSM module. Returns 0 for OK, 255 for no reply and 254 for command fail. 
Line 344: Line 317:
==Property reference==
==Property reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|-
|-
Line 390: Line 363:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''  
| width="90%" class="mtx-class-macrohead" | '''Connections'''  
|-
|-
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''  
| width="90%" class="mtx-class-macrohead" | '''Simulations'''  
|-
|-
|-
|-

Latest revision as of 14:23, 13 July 2026

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. I2CEEPROM

Downloadable macro reference

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


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


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. 
- BYTE Port
0=PortA, 1=PortB 
- BYTE Pin
Port pin to read. Range: 0-7 
- BYTE Return


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


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


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


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


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


Initialise
 
- VOID Return


Initialise
 
- VOID Return


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. 
- VOID Return


CheckNetworkStatus
Returns the state of the GSM network. 0 = Not connected, 1 = connected, 255 = no reply from GSM. 
- BYTE Return


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


Initialise
Sets up the GSM module. Returns 0 for OK, 255 for no reply and 254 for command fail. 
- BYTE Return



Property reference

Properties
External Address
Selects the value of the three address pins for the MCP23S17. 
Channel
SPI Channel selector 
Prescale
Prescale option selector 
MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
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.  
Use Reset
 
Connections
Simulations
Label
 
Scope Traces
Selects if the scope traces are automatically generated or not 
Console Data
Selects if the console data is automatically generated or not 
API