Myriota UltraLite SDK 2.4.0
Loading...
Searching...
No Matches

Inter-Integrated Circuit (I2C) interface for communication with sensors and peripherals. More...

Enumerations

enum  I2COption { I2C_DEFAULT_OPTIONS = 0 , I2C_FAST_MODE = 1 << 0 }
 I2C bit-wise options. More...
 

Functions

MYRIOTA_HARDWARE_API int I2CInit (void)
 Initialise I2C bus.
 
MYRIOTA_HARDWARE_API int I2CInitEx (uint32_t Option)
 Initialise I2C bus with options.
 
MYRIOTA_HARDWARE_API void I2CDeinit (void)
 Deinitialise I2C bus.
 
MYRIOTA_HARDWARE_API int I2CWrite (uint16_t DeviceAddress, const uint8_t *Command, size_t CommandLength)
 Write to an I2C device synchronously.
 
MYRIOTA_HARDWARE_API int I2CRead (uint16_t DeviceAddress, const uint8_t *Command, size_t CommandLength, uint8_t *Rx, size_t RxLength)
 Read from an I2C device synchronously.
 

Detailed Description

Inter-Integrated Circuit (I2C) interface for communication with sensors and peripherals.

Enumeration Type Documentation

◆ I2COption

enum I2COption

I2C bit-wise options.

Enumerator
I2C_DEFAULT_OPTIONS 

Up to ~100 kbit/s.

I2C_FAST_MODE 

Up to ~400 kbit/s.

Function Documentation

◆ I2CInit()

MYRIOTA_HARDWARE_API int I2CInit ( void  )

Initialise I2C bus.

Returns
0 if initialisation succeeds, -1 if initialisation fails.

◆ I2CInitEx()

MYRIOTA_HARDWARE_API int I2CInitEx ( uint32_t  Option)

Initialise I2C bus with options.

Parameters
OptionI2C options for bus speed.
Returns
0 if initialisation succeeds, -1 if initialisation fails.

◆ I2CDeinit()

MYRIOTA_HARDWARE_API void I2CDeinit ( void  )

Deinitialise I2C bus.

Deinitialises the I2C bus and releases associated hardware resources.

◆ I2CWrite()

MYRIOTA_HARDWARE_API int I2CWrite ( uint16_t  DeviceAddress,
const uint8_t *  Command,
size_t  CommandLength 
)

Write to an I2C device synchronously.

Parameters
DeviceAddressThe I2C device address.
Command[in]Pointer to the command data.
CommandLengthLength of the command data.
Returns
0 if write succeeds, -1 if write fails.

◆ I2CRead()

MYRIOTA_HARDWARE_API int I2CRead ( uint16_t  DeviceAddress,
const uint8_t *  Command,
size_t  CommandLength,
uint8_t *  Rx,
size_t  RxLength 
)

Read from an I2C device synchronously.

Parameters
DeviceAddressThe I2C device address.
Command[in]Pointer to the command data.
CommandLengthLength of the command data.
Rx[out]Pointer to the buffer to store the received data.
RxLengthLength of the buffer to store the received data.
Returns
0 if read succeeds, -1 if read fails.