Component: I2C Master (Comms: Interface)

From Flowcode Help
Revision as of 15:45, 20 July 2016 by BenR (talk | contribs) (XML import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


Author Matrix Ltd.
Version 1.4 (Release)
Category Comms: Interface


Image I2C Master component

Generic Two Wire I2C Communications Interface

Examples

No additional examples


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

BYTE


Restart

Outputs a restart condition onto the I²C bus.

Parameters

This macro has no parameters


Return value

This call does not return a value


Stop

Outputs a stop condition onto the I²C bus.

Parameters

This macro has no parameters


Return value

This call does not return a value


ReceiveByteTransaction

Function to perform a generic I2C read transaction. The 7-bit device ID is automatically shifted up by one bit to make room for the read/write bit. Returns the data from the location specified.

Parameters

BYTE Device_ID
7-bit Device Address ID
BYTE AddrH
Internal Address High Byte
BYTE AddrL
Internal Address Low Byte


Return value

BYTE


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

BYTE


SendByteTransaction

Function to perform a generic I2C Write transaction. The 7-bit device ID is automatically shifted up by one bit to make room for the read/write bit.

Parameters

BYTE Device_ID
7-bit Device Address ID
BYTE AddrH
Internal Address High Byte
BYTE AddrL
Internal Address Low Byte
BYTE Data
Data Byte


Return value

This call does not return a value


Start

Outputs a start condition onto the I²C bus.

Parameters

This macro has no parameters


Return value

This call does not return a 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.

Stop Delay

This property is of type True or false and can be referenced with the variable name StopDelay.

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.

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.

Scope Traces

This property is of type True or false and can be referenced with the variable name ScopeTraces.

Selects if the scope traces are automatically generated or not

Console Data

This property is of type True or false and can be referenced with the variable name ConsoleData.

Selects if the console data is automatically generated or not

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.