Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

I2C - System Management Bus


Files

file  otI2cBus.h
 I2C Library.

Modules

 Version History
 I2C - Code example

Functions

void I2cBusFrequency (int frequency, int dutyCycle)
 Set the bus frequency Set the bus frequency and clock duty cycle.
void I2cBusReset ()
 Reset the interface Reset the bus interface.
bool I2cBusClrSclSda ()
 Restores control of the interface Restore (after a bus error) the control of the interface.
void I2cBusSclSdaControls (bool scl, bool sda)
 Control of SDA and SCL lines as a port.
bool I2cBusWrite (U8 DeviceAddr, U8 *TWI_Data_Pointer, U16 TWI_Length)
 Do a master mode write Write (as master) a sequence of bytes at the specified address.
bool I2cBusWriteReg (U8 DeviceAddr, U8 regId, U8 *TWI_Data_Pointer, U16 TWI_Length)
 Do a master mode write Write (as master) a sequence of bytes at the specified address.
bool I2cBusWriteReg16 (U8 DeviceAddr, U16 regId, U16 *TWI_Data_Pointer, U16 TWI_Length)
 Do a master mode write Write (as master) a sequence of words at the specified address.
void I2cBusRead (U8 DeviceAddr, U8 *TWI_Data_Pointer, U16 Count)
 Do a master mode read Read (as master) a sequence of bytes from a specified address.
void I2cBusRead16 (U8 DeviceAddr, U16 *TWI_Data_Pointer, U16 Count)
 Do a master mode read Read (as master) a sequence of words from a specified address.
bool I2cBusWriteByte (U8 address, U8 regId, U8 data)
 Write a byte Write a byte to the specified register (address) of a device at address.
U8 I2cBusReadByte (U8 address, U8 regId, U8 *ok)
 Read a byte Read a byte from the specified register (regID) of a device at address.
bool I2cBusReadBytes (U8 address, U8 regId, U16 count, U8 *dest)
 Read n bytes Read bytes from the specified regId of a device at address.
bool I2cBusWrite8_16 (U8 address, U8 regId, U16 value)
 Write a word Write a word to the specified register at address of the device.
bool I2cBusWrite8_32 (U8 address, U8 regId, U32 value)
 Write a double word Write a double word to the specified register at address of the device.
bool I2cBusWrite16_8 (U8 address, U16 regId, U8 value)
 Write a word Write a word to the specified register at address of the device.
bool I2cBusWrite16_16 (U8 address, U16 regId, U16 value)
 Write a word Write a word (16bit) to a specified register with 16 bit address.
bool I2cBusReadReg8_16 (U8 address, U8 regId, U16 *regDat)
 Read a word Read a a word (16bit) from a specified 16 bit register located by a 8bit address.
bool I2cBusReadReg8_32 (U8 address, U8 regID, U32 *regDat)
 Read a double word Read a a double word (32bit) from a specified 32 bit register located by a 8bit address.
bool I2cBusReadReg16_8 (U8 address, U16 regId, U8 *regDat)
 Read a byte Read a byte from a specified register located by a 16bit address.
bool I2cBusReadReg16_16 (U8 address, U16 regId, U16 *regDat)
 Read a word Read a word (16bit) from a specified register located by a 16bit address.
bool I2cBusReadReg16_16N (U8 address, U16 regID, U16 *regDat, U16 wordCount)
bool I2cBusWriteStart (U8 DeviceAddr, U16 num)
bool I2cBusWriteData (U8 data)
bool I2cBusWriteEnd ()
void I2cBusReadStart (U8 DeviceAddr, U16 count)
U8 I2cBusReadData ()
void I2cBusReadEnd ()

Detailed Description

More info at: https://www.nxp.com/docs/en/user-guide/UM10204.pdf Dependency: TIMER - Procedure for timer usage

Function Documentation

bool I2cBusClrSclSda  ) 
 

void I2cBusFrequency int  frequency,
int  dutyCycle
 

Parameters:
frequency Set the bus frequency, its expressed as KHz
dutyCycle Set the clock duty cycle.

void I2cBusRead U8  DeviceAddr,
U8 TWI_Data_Pointer,
U16  Count
 

Parameters:
DeviceAddr specify the address of a device on the bus.
TWI_Data_Pointer is the pointer to store the data.
Count is the number of bytes to be receive.
Returns:
true on success.

void I2cBusRead16 U8  DeviceAddr,
U16 TWI_Data_Pointer,
U16  Count
 

Parameters:
DeviceAddr specify the address of a device on the bus.
TWI_Data_Pointer is the pointer to store the data.
Count is the number of words to be receive.
Returns:
true on success.

U8 I2cBusReadByte U8  address,
U8  regId,
U8 ok
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address.
ok is setted to true on success. Set the address to zero if don't want check results.
Returns:
the value read from the device.

bool I2cBusReadBytes U8  address,
U8  regId,
U16  count,
U8 dest
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address.
count number of bytes to read
dest is the pointer to store the data.
Returns:
true on success.

U8 I2cBusReadData  ) 
 

void I2cBusReadEnd  ) 
 

bool I2cBusReadReg16_16 U8  address,
U16  regId,
U16 regDat
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address.
regDat address where to write read word.
Returns:
true on success.

bool I2cBusReadReg16_16N U8  address,
U16  regID,
U16 regDat,
U16  wordCount
 

bool I2cBusReadReg16_8 U8  address,
U16  regId,
U8 regDat
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address.
regDat address where to write read byte.
Returns:
true on success.

bool I2cBusReadReg8_16 U8  address,
U8  regId,
U16 regDat
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address.
regDat address where to read the word.
Returns:
true on success.

bool I2cBusReadReg8_32 U8  address,
U8  regID,
U32 regDat
 

Parameters:
address specify the address of a device on the bus.
regID specific device internal address.
regDat address where to read a double word.
Returns:
true on success.

void I2cBusReadStart U8  DeviceAddr,
U16  count
 

void I2cBusReset  ) 
 

void I2cBusSclSdaControls bool  scl,
bool  sda
 

Parameters:
scl If true SCL line is set to 0
sda If true SDA line is set to 0

bool I2cBusWrite U8  DeviceAddr,
U8 TWI_Data_Pointer,
U16  TWI_Length
 

Parameters:
DeviceAddr specify the address of a device on the bus.
TWI_Data_Pointer is the pointer to data to be sent.
TWI_Length size of data to be sent.
Returns:
true on success.

bool I2cBusWrite16_16 U8  address,
U16  regId,
U16  value
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address (word).
value (word) to be written
Returns:
true on success.

bool I2cBusWrite16_8 U8  address,
U16  regId,
U8  value
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address.
value to be written
Returns:
true on success.

bool I2cBusWrite8_16 U8  address,
U8  regId,
U16  value
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address.
value to be written
Returns:
true on success.

bool I2cBusWrite8_32 U8  address,
U8  regId,
U32  value
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address.
value to be written
Returns:
true on success.

bool I2cBusWriteByte U8  address,
U8  regId,
U8  data
 

Parameters:
address specify the address of a device on the bus.
regId specific device internal address.
data byte to be written
Returns:
true on success.

bool I2cBusWriteData U8  data  ) 
 

bool I2cBusWriteEnd  ) 
 

bool I2cBusWriteReg U8  DeviceAddr,
U8  regId,
U8 TWI_Data_Pointer,
U16  TWI_Length
 

Parameters:
DeviceAddr specify the address of a device on the bus.
regId Internal device address
TWI_Data_Pointer is the pointer to data to be sent.
TWI_Length size of data to be sent.
Returns:
true on success.

bool I2cBusWriteReg16 U8  DeviceAddr,
U16  regId,
U16 TWI_Data_Pointer,
U16  TWI_Length
 

Parameters:
DeviceAddr specify the address of a device on the bus.
regId Internal device address
TWI_Data_Pointer is the pointer to data to be sent.
TWI_Length size of data to be sent.
Returns:
true on success.

bool I2cBusWriteStart U8  DeviceAddr,
U16  num
 

footer

otStudio - Library Reference - (C) 2020-23 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0