Component: I2C (Peripheral CAL)

From Flowcode Help
Jump to navigationJump to search


Author Matrix Ltd
Version 1.3 (Release)
Category Peripheral CAL


Image I2C component

Chip Abstraction Layer for Two Wire I2C Communications

Examples

Example template program for creating a new component using the CAL I2C. Contains all the code to allow the dynamic I2C channel population and Injector functionality. FC6 Icon.png I2C CAL Demo

Downloadable macro reference

Slave_Uninit

Uninitialise the Slave

Parameters

This macro has no parameters


Return value

This call does not return a value


Master_Stop

Output a Master Stop

Parameters

This macro has no parameters


Return value

This call does not return a value


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.

Parameters

BYTE Address
7 Bit Address of this device (Bit 0 is ignored)
BYTE Mask
Bit mask used to compare addresses


Return value

This call does not return a value


Master_Uninit

Uninitialise the Master

Parameters

This macro has no parameters


Return value

This call does not return a value


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)

Parameters

This macro has no parameters


Return value

BYTE


Slave_TxByte

Send a data byte, returns Ack/Nak from Master

0=Ack=More, 1=Nak=Last

Parameters

BYTE Data


Return value

BYTE


Slave_RxByte

Returns the data received, and sends either Ack or Nak

Set parameter Last as: 1=Last=Nak, 0=Ack=More

Parameters

BYTE Last
Sends Ack if 0, else Nak


Return value

BYTE


Master_Init

Initialise the Master

Parameters

This macro has no parameters


Return value

This call does not return a value


Master_Start

Output a Master Start sequence

Parameters

This macro has no parameters


Return value

This call does not return a value


Master_TxByte

Send a data byte

Parameters

BYTE Data


Return value

BYTE


Master_Restart

Output a Master Restart sequence

Parameters

This macro has no parameters


Return value

This call does not return a value


Master_RxByte

Returns a received data byte

Parameters

BYTE Last


Return value

BYTE


Simulation macro reference

GetValue

Get the Named property value.

Parameters

STRING Name


Return value

STRING


GetConsoleHandle

Obtains the CAL console handle

Parameters

This macro has no parameters


Return value

HANDLE


SetValue

Change Named property to new Value.

If "CHANNEL" the ports will be also updated from the fcd

Parameters

STRING Name
STRING Value
port value as string


Return value

This call does not return a value


GetList

returns Named property List as filter string

Parameters

STRING Name


Return value

STRING



Property reference

Channel

This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.

Channel selection

SDA

This property is of type Single digital pin and can be referenced with the variable name SDA.

Pin used for SDA (data signal)

SCL

This property is of type Single digital pin and can be referenced with the variable name SCL.

Pin used for SCL (clock signal)

Baud Select

This property is of type Fixed list of ints and can be referenced with the variable name BAUD_LIST.

Baud rate option selector

Baud Rate

This property is of type Signed integer and can be referenced with the variable name BAUD.

Baud rate to be used

Slew Rate Control

This property is of type Fixed list of ints and can be referenced with the variable name SRC.

Slew Rate Control Enabled or Disabled

SMBus Inputs

This property is of type Fixed list of ints and can be referenced with the variable name SMB.

When Enabled input logic thresholds are compliant with SMBus specification

Stop Delay

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

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.

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