Jump to content

Component: I2C (CAL) (Misc): Difference between revisions

From Flowcode Help
No edit summary
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(11 intermediate revisions by 3 users not shown)
Line 15: Line 15:
CAL = Code Abstraction Layer - Allows one code base to run on a wide range of chips. A low level implementation giving direct access to the Two Wire I²C peripheral.
CAL = Code Abstraction Layer - Allows one code base to run on a wide range of chips. A low level implementation giving direct access to the Two Wire I²C peripheral.


==Component Source Code==
==Detailed description==
 
 
 
 
 
 
 
 
 
 
 
''No detailed description exists yet for this component''
 
==Examples==


Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_temp/I2C.fcfx FC_Comp_Source_temp/I2C.fcfx]


Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_temp/I2C.fcfx FC_Comp_Source_temp/I2C.fcfx]


==Detailed description==




Line 33: Line 44:




''No detailed description exists yet for this component''


==Examples==




Line 45: Line 54:




===PIC16F1937 Examples===


The slave device is connected to a bank of switches, the master device to a bank of LEDs. The value of the switches is passed to the master LEDs.
{{Fcfile|1. I2C Master Read.fcfx|Master Read Example}}


''<span style="color:red;">No additional examples</span>''
{{Fcfile|1. I2C Slave switches.fcfx|Slave Switches Example}}
The slave device is connected to a bank of LEDs, the master device to a bank of switches. The value of the switches is passed to the slave LEDs.
{{Fcfile|2. I2C Master Switches.fcfx|Master Send Example}}


{{Fcfile|2. I2C Slave LEDs.fcfx|Slave LEDs Example}}
===Arduino Uno Examples===


Example program showing how to use the I2C Slave on an AVR Arduino device.
{{Fcfile|I2C Uno slave.fcfx|I2C Slave Arduino Uno Example}}
===ECIO40P Examples===


Example program showing how to use the I2C Slave on an ECIO40P device.
{{Fcfile|ECIO40P_I2C_Master.fcfx|Master Example}}


{{Fcfile|ECIO40P_I2C_Slave.fcfx|Slave Example}}




Line 58: Line 80:


===GetConsoleHandle===
===GetConsoleHandle===
{| 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;" | '''GetConsoleHandle'''
| width="90%" class="mtx-class-macrohead" | '''GetConsoleHandle'''
|-
|-
| colspan="2" | Obtains the CAL console handle&nbsp;
| colspan="2" | Obtains the CAL console handle&nbsp;
Line 72: Line 94:


===GetList===
===GetList===
{| 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;" | '''GetList'''
| width="90%" class="mtx-class-macrohead" | '''GetList'''
|-
|-
| colspan="2" | returns Named property List as filter string &nbsp;
| colspan="2" | returns Named property List as filter string &nbsp;
Line 91: Line 113:


===GetValue===
===GetValue===
{| 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;" | '''GetValue'''
| width="90%" class="mtx-class-macrohead" | '''GetValue'''
|-
|-
| colspan="2" | Get the Named property value.  &nbsp;
| colspan="2" | Get the Named property value.  &nbsp;
Line 110: Line 132:


===Master_Init===
===Master_Init===
{| 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;" | '''Master_Init'''
| width="90%" class="mtx-class-macrohead" | '''Master_Init'''
|-
|-
| colspan="2" | Initialise the Master&nbsp;
| colspan="2" | Initialise the Master&nbsp;
Line 124: Line 146:


===Master_Restart===
===Master_Restart===
{| 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;" | '''Master_Restart'''
| width="90%" class="mtx-class-macrohead" | '''Master_Restart'''
|-
|-
| colspan="2" | Output a Master Restart sequence&nbsp;
| colspan="2" | Output a Master Restart sequence&nbsp;
Line 138: Line 160:


===Master_RxByte===
===Master_RxByte===
{| 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;" | '''Master_RxByte'''
| width="90%" class="mtx-class-macrohead" | '''Master_RxByte'''
|-
|-
| colspan="2" | Returns a received data byte. Set Last=0 if there is following more Master_RxByte macros Set Last=1 if this is the last Master_RxByte and it is followed with Master_Stop. If Last = 1 the I2C bus will be presented with a 'Nack' condition.&nbsp;
| colspan="2" | Returns a received data byte. Set Last=0 if there is following more Master_RxByte macros Set Last=1 if this is the last Master_RxByte and it is followed with Master_Stop. If Last = 1 the I2C bus will be presented with a 'Nack' condition.&nbsp;
Line 157: Line 179:


===Master_Start===
===Master_Start===
{| 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;" | '''Master_Start'''
| width="90%" class="mtx-class-macrohead" | '''Master_Start'''
|-
|-
| colspan="2" | Output a Master Start sequence&nbsp;
| colspan="2" | Output a Master Start sequence&nbsp;
Line 171: Line 193:


===Master_Stop===
===Master_Stop===
{| 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;" | '''Master_Stop'''
| width="90%" class="mtx-class-macrohead" | '''Master_Stop'''
|-
|-
| colspan="2" | Output a Master Stop&nbsp;
| colspan="2" | Output a Master Stop&nbsp;
Line 185: Line 207:


===Master_TxByte===
===Master_TxByte===
{| 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;" | '''Master_TxByte'''
| width="90%" class="mtx-class-macrohead" | '''Master_TxByte'''
|-
|-
| colspan="2" | Send a data byte and collects the acknowledge from the slave. Returns 0 for Ack received. Returns 1 for Ack not received - slave not responding.&nbsp;
| colspan="2" | Send a data byte and collects the acknowledge from the slave. Returns 0 for Ack received. Returns 1 for Ack not received - slave not responding.&nbsp;
Line 204: Line 226:


===Master_Uninit===
===Master_Uninit===
{| 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;" | '''Master_Uninit'''
| width="90%" class="mtx-class-macrohead" | '''Master_Uninit'''
|-
|-
| colspan="2" | Uninitialise the Master&nbsp;
| colspan="2" | Uninitialise the Master&nbsp;
Line 218: Line 240:


===SetValue===
===SetValue===
{| 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;" | '''SetValue'''
| width="90%" class="mtx-class-macrohead" | '''SetValue'''
|-
|-
| colspan="2" | Change Named property to new Value.  If "CHANNEL" the ports will be also updated from the fcd &nbsp;
| colspan="2" | Change Named property to new Value.  If "CHANNEL" the ports will be also updated from the fcd &nbsp;
Line 242: Line 264:


===Slave_Init===
===Slave_Init===
{| 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;" | '''Slave_Init'''
| width="90%" class="mtx-class-macrohead" | '''Slave_Init'''
|-
|-
| colspan="2" | Initialise the Slave with the given Address, or range of Addresses. Only address bits that have a corresponding bit set in the Mask will be compared with the incoming bus address.&nbsp;
| colspan="2" | Initialise the Slave with the given Address, or range of Addresses. Only address bits that have a corresponding bit set in the Mask will be compared with the incoming bus address.&nbsp;
Line 266: Line 288:


===Slave_RxByte===
===Slave_RxByte===
{| 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;" | '''Slave_RxByte'''
| width="90%" class="mtx-class-macrohead" | '''Slave_RxByte'''
|-
|-
| colspan="2" | Returns the data received, and sends either Ack or Nak Set parameter Last as: 1=Last=Nak, 0=Ack=More&nbsp;
| colspan="2" | Returns the data received, and sends either Ack or Nak Set parameter Last as: 1=Last=Nak, 0=Ack=More&nbsp;
Line 285: Line 307:


===Slave_Status===
===Slave_Status===
{| 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;" | '''Slave_Status'''
| width="90%" class="mtx-class-macrohead" | '''Slave_Status'''
|-
|-
| colspan="2" | Returns the Slave Status. Bit 0 = 1 Indicates address/data byte available in the buffer to read Bit 5 = 1 Indicates that the last byte received or transmitted was data (else address) &nbsp;
| colspan="2" | Returns the Slave Status. Bit 0 = 1 Indicates address/data byte available in the buffer to read Bit 5 = 1 Indicates that the last byte received or transmitted was data (else address) &nbsp;
Line 299: Line 321:


===Slave_TxByte===
===Slave_TxByte===
{| 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;" | '''Slave_TxByte'''
| width="90%" class="mtx-class-macrohead" | '''Slave_TxByte'''
|-
|-
| colspan="2" | Send a data byte, returns Ack/Nak from Master 0=Ack=More, 1=Nak=Last&nbsp;
| colspan="2" | Send a data byte, returns Ack/Nak from Master 0=Ack=More, 1=Nak=Last&nbsp;
Line 318: Line 340:


===Slave_Uninit===
===Slave_Uninit===
{| 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;" | '''Slave_Uninit'''
| width="90%" class="mtx-class-macrohead" | '''Slave_Uninit'''
|-
|-
| colspan="2" | Uninitialise the Slave&nbsp;
| colspan="2" | Uninitialise the Slave&nbsp;
Line 332: Line 354:


===Transaction_Initialise===
===Transaction_Initialise===
{| 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;" | '''Transaction_Initialise'''
| width="90%" class="mtx-class-macrohead" | '''Transaction_Initialise'''
|-
|-
| colspan="2" | Initialise the I2C interface to communicate with a Slave device at Address Returns 0 on fail, 1 on success&nbsp;
| colspan="2" | Initialise the I2C interface to communicate with a Slave device at Address Returns 0 on fail, 1 on success&nbsp;
Line 351: Line 373:


===Transaction_Read===
===Transaction_Read===
{| 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;" | '''Transaction_Read'''
| width="90%" class="mtx-class-macrohead" | '''Transaction_Read'''
|-
|-
| colspan="2" | Attempt to read Length number of bytes from the I2C slave to the given Buffer. Ensure that the Buffer is large enough.  Returns number of bytes read, caller should check that this matches requested Length&nbsp;
| colspan="2" | Attempt to read Length number of bytes from the I2C slave to the given Buffer. Ensure that the Buffer is large enough.  Returns number of bytes read, caller should check that this matches requested Length&nbsp;
Line 375: Line 397:


===Transaction_Uninit===
===Transaction_Uninit===
{| 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;" | '''Transaction_Uninit'''
| width="90%" class="mtx-class-macrohead" | '''Transaction_Uninit'''
|-
|-
| colspan="2" | Uninitialise the I2C interface&nbsp;
| colspan="2" | Uninitialise the I2C interface&nbsp;
Line 389: Line 411:


===Transaction_Write===
===Transaction_Write===
{| 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;" | '''Transaction_Write'''
| width="90%" class="mtx-class-macrohead" | '''Transaction_Write'''
|-
|-
| colspan="2" | Attempt to write Length number of bytes to the I2C slave from the given Buffer. Ensure that the Buffer is large enough.  Returns the number of bytes written, the caller should check that this matches requested Length&nbsp;
| colspan="2" | Attempt to write Length number of bytes to the I2C slave from the given Buffer. Ensure that the Buffer is large enough.  Returns the number of bytes written, the caller should check that this matches requested Length&nbsp;
Line 410: Line 432:
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




==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 427: Line 447:
| colspan="2" | Allows the component to be easily disabled from generating code, allowing for multiple CAL components to be easily created. For example a sensor IC with both I2C and SPI communications interfaces.&nbsp;
| colspan="2" | Allows the component to be easily disabled from generating code, allowing for multiple CAL components to be easily created. For example a sensor IC with both I2C and SPI communications interfaces.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
| width="90%" class="mtx-class-propfolder" | Connections
|-
|-
|-
|-
Line 451: Line 471:
| colspan="2" | Pin used for SCL (clock signal)&nbsp;
| colspan="2" | Pin used for SCL (clock signal)&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Options
| width="90%" class="mtx-class-propfolder" | Options
|-
|-
|-
|-
Line 480: Line 500:
| colspan="2" |  When Enabled input logic thresholds are compliant with SMBus specification&nbsp;
| colspan="2" |  When Enabled input logic thresholds are compliant with SMBus specification&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
|-
|-
Line 499: Line 519:
| colspan="2" | Specifies the API component on the panel to interact with to provide comms simulation.&nbsp;
| colspan="2" | Specifies the API component on the panel to interact with to provide comms simulation.&nbsp;
|}
|}
==Component Source Code==
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_I2C.fcfx FC_Comp_Source_I2C.fcfx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_I2C.fcfx FC_Comp_Source_I2C.fcfx]

Latest revision as of 14:37, 13 July 2026

Author Matrix TSL
Version 2.0
Category Misc


I2C component

CAL = Code Abstraction Layer - Allows one code base to run on a wide range of chips. A low level implementation giving direct access to the Two Wire I²C peripheral.

Detailed description

No detailed description exists yet for this component

Examples

PIC16F1937 Examples

The slave device is connected to a bank of switches, the master device to a bank of LEDs. The value of the switches is passed to the master LEDs. Master Read Example

Slave Switches Example The slave device is connected to a bank of LEDs, the master device to a bank of switches. The value of the switches is passed to the slave LEDs. Master Send Example

Slave LEDs Example

Arduino Uno Examples

Example program showing how to use the I2C Slave on an AVR Arduino device. I2C Slave Arduino Uno Example

ECIO40P Examples

Example program showing how to use the I2C Slave on an ECIO40P device. Master Example

Slave Example


Macro reference

GetConsoleHandle

GetConsoleHandle
Obtains the CAL console handle 
- HANDLE Return


GetList

GetList
returns Named property List as filter string  
- STRING Name
 
- STRING Return


GetValue

GetValue
Get the Named property value.  
- STRING Name
 
- STRING Return


Master_Init

Master_Init
Initialise the Master 
- VOID Return


Master_Restart

Master_Restart
Output a Master Restart sequence 
- VOID Return


Master_RxByte

Master_RxByte
Returns a received data byte. Set Last=0 if there is following more Master_RxByte macros Set Last=1 if this is the last Master_RxByte and it is followed with Master_Stop. If Last = 1 the I2C bus will be presented with a 'Nack' condition. 
- BYTE Last
Range: 0-1 - 0 = Not the last byte to receive, 1 = last byte to receive 
- BYTE Return


Master_Start

Master_Start
Output a Master Start sequence 
- VOID Return


Master_Stop

Master_Stop
Output a Master Stop 
- VOID Return


Master_TxByte

Master_TxByte
Send a data byte and collects the acknowledge from the slave. Returns 0 for Ack received. Returns 1 for Ack not received - slave not responding. 
- BYTE Data
Data byte to write to the I2C bus 
- BYTE Return


Master_Uninit

Master_Uninit
Uninitialise the Master 
- VOID Return


SetValue

SetValue
Change Named property to new Value. If "CHANNEL" the ports will be also updated from the fcd  
- STRING Name
 
- STRING Value
port value as string 
- VOID Return


Slave_Init

Slave_Init
Initialise the Slave with the given Address, or range of Addresses. Only address bits that have a corresponding bit set in the Mask will be compared with the incoming bus address. 
- BYTE Address
7 Bit Address of this device (Bit 0 is ignored) 
- BYTE Mask
Bit mask used to compare addresses 
- VOID Return


Slave_RxByte

Slave_RxByte
Returns the data received, and sends either Ack or Nak Set parameter Last as: 1=Last=Nak, 0=Ack=More 
- BYTE Last
Sends Ack if 0, else Nak 
- BYTE Return


Slave_Status

Slave_Status
Returns the Slave Status. Bit 0 = 1 Indicates address/data byte available in the buffer to read Bit 5 = 1 Indicates that the last byte received or transmitted was data (else address)  
- BYTE Return


Slave_TxByte

Slave_TxByte
Send a data byte, returns Ack/Nak from Master 0=Ack=More, 1=Nak=Last 
- BYTE Data
 
- BYTE Return


Slave_Uninit

Slave_Uninit
Uninitialise the Slave 
- VOID Return


Transaction_Initialise

Transaction_Initialise
Initialise the I2C interface to communicate with a Slave device at Address Returns 0 on fail, 1 on success 
- BYTE Address
7-bit I2C Address without the shift for the R/W bit 
- BYTE Return


Transaction_Read

Transaction_Read
Attempt to read Length number of bytes from the I2C slave to the given Buffer. Ensure that the Buffer is large enough. Returns number of bytes read, caller should check that this matches requested Length 
- BYTE Buffer
Buffer to store the incoming byte data 
- UINT Length
Number of bytes to read 
- UINT Return


Transaction_Uninit

Transaction_Uninit
Uninitialise the I2C interface 
- VOID Return


Transaction_Write

Transaction_Write
Attempt to write Length number of bytes to the I2C slave from the given Buffer. Ensure that the Buffer is large enough. Returns the number of bytes written, the caller should check that this matches requested Length 
- BYTE Buffer
Buffer of bytes to write to the I2C 
- UINT Length
Number of bytes to send out, MS bit 0x8000 signifies no Stop if set 
- UINT Return


Property reference

Properties
Component Enable
Allows the component to be easily disabled from generating code, allowing for multiple CAL components to be easily created. For example a sensor IC with both I2C and SPI communications interfaces. 
Connections
Channel
Channel selection 
Mode
Defines if the component will be used for Master or Slave communications. Master mode supports a software bitbanged I2C channel. Slave mode requires a hardware I2C peripheral to catch the communications from the Master. 
SDA
Pin used for SDA (data signal) 
SCL
Pin used for SCL (clock signal) 
Options
Stop Delay
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not a 10ms delay between an I2C stop event and the next I2C start event. Most modern microcontrollers will not have a problem so this property can be disabled to speed up the I2C communications.  
Baud Select
Baud rate option selector 
Baud Rate
Baud rate to be used 
Slew Rate Control
Slew Rate Control Enabled or Disabled 
SMBus Inputs
When Enabled input logic thresholds are compliant with SMBus specification 
Simulation
Scope Traces
Selects if the component pin connections are automatically generated on the data recorder window or not. Yes: Automatically add the component pins to a group on the data recorder which will reflect the sim data during simultion. No: Do not show the pin signals on the data recorder window. 
Console Data
Selects if the console data is automatically generated or not 
API
Specifies the API component on the panel to interact with to provide comms simulation. 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_I2C.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_I2C.fcfx