Component: I2C Slave (Comms: Interface)
Author | Matrix Ltd. |
Version | 1.2 (Release) |
Category | Comms: Interface |
Contents
I2C Slave component
Generic Two Wire I2C Communications Interface
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
Downloadable macro reference
ReceiveByte
Receives a byte from the I²C bus.
Parameters
- BYTE Last
- Used to signify the last byte when streaming incoming data. 0=Not last byte, 1=Last Byte
Return value
TransmitByte
Sends a byte on the I²C bus. Returns the acknowledge if any.
0 represents that data was acknowledged and 1 represents no acknowledge was detected.
Parameters
- BYTE Data
- Data byte to send on the I²C bus.
Return value
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.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
This component does not contain any simulation macros
Property reference
Channel
This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.
Specifies the I2C peripheral used by the component.
Hardware channels are defined by the number of I2C peripherals available onboard your target microcontroller.
Software channels use standard I/O pins allowing you to connect the I2C bus to pretty much any pin.
Baud Select
This property is of type Fixed list of ints and can be referenced with the variable name BAUD_LIST.
Sets the rate of the I2C clock which sets the maximum number of bits per second that can be sent or received.
Slew Rate Control
This property is of type Fixed list of ints and can be referenced with the variable name SRC.
The slew rate control only works with hardware I2C channels but acts to modify the overall baud to ensure
that signals are being transferred correctly based on how fast the control signals are able to rise and fall.
SMBus Inputs
This property is of type Fixed list of ints and can be referenced with the variable name SMB.
The SMBus Inputs only works with hardware I2C channels but acts to modify the I2C driver to be compatible with SM Bus.
Data (SDA)
This property is of type Single digital pin and can be referenced with the variable name SDA.
I2C data pin commonly referred to as SDA which represents serial data
Clock (SCL)
This property is of type Single digital pin and can be referenced with the variable name SCL.
I2C clock pin commonly referred to as SCL which represents serial clock
Label
This property is of type Line of text and can be referenced with the variable name label.
Label shown on the comms flasher on the simulation panel.
Injector
This property is of type Fixed list of ints and can be referenced with the variable name Injector.
Lists all the available injector components on the panel to allow the I2C data to have meaning.
Injectors are available to let you directly type in values, simulate devices and communicate between multiple instances of Flowcode.
Slave Address
This property is of type Signed integer and can be referenced with the variable name Slave_Address.
No additional information
Mask
This property is of type Signed integer and can be referenced with the variable name Mask.
0 - don't care;
1 - perform match;
So address of 0x30 and mask of 0xF0 will allow the slave to respond to addresses of 0x30, 0x31, 0x32, …, 0x3F