Component: I2C (CAL) (Misc): Difference between revisions
No edit summary |
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder"" |
||
| (8 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. | ||
== | ==Detailed description== | ||
''No detailed description exists yet for this component'' | |||
==Examples== | |||
| Line 33: | Line 38: | ||
| Line 47: | Line 50: | ||
===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}} | |||
{{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 64: | Line 80: | ||
===GetConsoleHandle=== | ===GetConsoleHandle=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''GetConsoleHandle''' | ||
|- | |- | ||
| colspan="2" | Obtains the CAL console handle | | colspan="2" | Obtains the CAL console handle | ||
| Line 78: | Line 94: | ||
===GetList=== | ===GetList=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''GetList''' | ||
|- | |- | ||
| colspan="2" | returns Named property List as filter string | | colspan="2" | returns Named property List as filter string | ||
| Line 97: | Line 113: | ||
===GetValue=== | ===GetValue=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''GetValue''' | ||
|- | |- | ||
| colspan="2" | Get the Named property value. | | colspan="2" | Get the Named property value. | ||
| Line 116: | Line 132: | ||
===Master_Init=== | ===Master_Init=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Master_Init''' | ||
|- | |- | ||
| colspan="2" | Initialise the Master | | colspan="2" | Initialise the Master | ||
| Line 130: | Line 146: | ||
===Master_Restart=== | ===Master_Restart=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Master_Restart''' | ||
|- | |- | ||
| colspan="2" | Output a Master Restart sequence | | colspan="2" | Output a Master Restart sequence | ||
| Line 144: | Line 160: | ||
===Master_RxByte=== | ===Master_RxByte=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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. | | 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. | ||
| Line 163: | Line 179: | ||
===Master_Start=== | ===Master_Start=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Master_Start''' | ||
|- | |- | ||
| colspan="2" | Output a Master Start sequence | | colspan="2" | Output a Master Start sequence | ||
| Line 177: | Line 193: | ||
===Master_Stop=== | ===Master_Stop=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Master_Stop''' | ||
|- | |- | ||
| colspan="2" | Output a Master Stop | | colspan="2" | Output a Master Stop | ||
| Line 191: | Line 207: | ||
===Master_TxByte=== | ===Master_TxByte=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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. | | 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. | ||
| Line 210: | Line 226: | ||
===Master_Uninit=== | ===Master_Uninit=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Master_Uninit''' | ||
|- | |- | ||
| colspan="2" | Uninitialise the Master | | colspan="2" | Uninitialise the Master | ||
| Line 224: | Line 240: | ||
===SetValue=== | ===SetValue=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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 | | colspan="2" | Change Named property to new Value. If "CHANNEL" the ports will be also updated from the fcd | ||
| Line 248: | Line 264: | ||
===Slave_Init=== | ===Slave_Init=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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. | | 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. | ||
| Line 272: | Line 288: | ||
===Slave_RxByte=== | ===Slave_RxByte=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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 | | colspan="2" | Returns the data received, and sends either Ack or Nak Set parameter Last as: 1=Last=Nak, 0=Ack=More | ||
| Line 291: | Line 307: | ||
===Slave_Status=== | ===Slave_Status=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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) | | 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) | ||
| Line 305: | Line 321: | ||
===Slave_TxByte=== | ===Slave_TxByte=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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 | | colspan="2" | Send a data byte, returns Ack/Nak from Master 0=Ack=More, 1=Nak=Last | ||
| Line 324: | Line 340: | ||
===Slave_Uninit=== | ===Slave_Uninit=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Slave_Uninit''' | ||
|- | |- | ||
| colspan="2" | Uninitialise the Slave | | colspan="2" | Uninitialise the Slave | ||
| Line 338: | Line 354: | ||
===Transaction_Initialise=== | ===Transaction_Initialise=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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 | | colspan="2" | Initialise the I2C interface to communicate with a Slave device at Address Returns 0 on fail, 1 on success | ||
| Line 357: | Line 373: | ||
===Transaction_Read=== | ===Transaction_Read=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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 | | 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 | ||
| Line 381: | Line 397: | ||
===Transaction_Uninit=== | ===Transaction_Uninit=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Transaction_Uninit''' | ||
|- | |- | ||
| colspan="2" | Uninitialise the I2C interface | | colspan="2" | Uninitialise the I2C interface | ||
| Line 395: | Line 411: | ||
===Transaction_Write=== | ===Transaction_Write=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | 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 | | 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 | ||
| Line 420: | Line 436: | ||
==Property reference== | ==Property reference== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Properties''' | ||
|- | |- | ||
|- | |- | ||
| Line 431: | 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. | | 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. | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Connections | ||
|- | |- | ||
|- | |- | ||
| Line 455: | Line 471: | ||
| colspan="2" | Pin used for SCL (clock signal) | | colspan="2" | Pin used for SCL (clock signal) | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Options | ||
|- | |- | ||
|- | |- | ||
| Line 484: | Line 500: | ||
| colspan="2" | When Enabled input logic thresholds are compliant with SMBus specification | | colspan="2" | When Enabled input logic thresholds are compliant with SMBus specification | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Simulation | ||
|- | |- | ||
|- | |- | ||
| Line 503: | Line 519: | ||
| colspan="2" | Specifies the API component on the panel to interact with to provide comms simulation. | | colspan="2" | 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: [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
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
Macro reference
GetConsoleHandle
| GetConsoleHandle | |
| Obtains the CAL console handle | |
| Return | |
GetList
| GetList | |
| returns Named property List as filter string | |
| Name | |
| Return | |
GetValue
| GetValue | |
| Get the Named property value. | |
| Name | |
| Return | |
Master_Init
| Master_Init | |
| Initialise the Master | |
| Return | |
Master_Restart
| Master_Restart | |
| Output a Master Restart sequence | |
| Return | |
Master_RxByte
Master_Start
| Master_Start | |
| Output a Master Start sequence | |
| Return | |
Master_Stop
| Master_Stop | |
| Output a Master Stop | |
| Return | |
Master_TxByte
Master_Uninit
| Master_Uninit | |
| Uninitialise the Master | |
| Return | |
SetValue
| SetValue | |
| Change Named property to new Value. If "CHANNEL" the ports will be also updated from the fcd | |
| Name | |
| Value | |
| port value as string | |
| Return | |
Slave_Init
Slave_RxByte
| Slave_RxByte | |
| Returns the data received, and sends either Ack or Nak Set parameter Last as: 1=Last=Nak, 0=Ack=More | |
| Last | |
| Sends Ack if 0, else Nak | |
| Return | |
Slave_Status
Slave_TxByte
| Slave_TxByte | |
| Send a data byte, returns Ack/Nak from Master 0=Ack=More, 1=Nak=Last | |
| Data | |
| Return | |
Slave_Uninit
| Slave_Uninit | |
| Uninitialise the Slave | |
| Return | |
Transaction_Initialise
Transaction_Read
Transaction_Uninit
| Transaction_Uninit | |
| Uninitialise the I2C interface | |
| Return | |
Transaction_Write
Property reference
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