Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
i2c.h File Reference

Go to the source code of this file.

Data Structures

struct  _I2C_PROPERTIES
struct  _I2C_DEVICE

Macros

#define I2C_NAME_PREFIX   "I2C"
 Name prefix for I2C Devices.
#define I2CSLAVE_NAME_PREFIX   "I2CSlave"
 Name prefix for I2C Slave Devices.
#define I2C_TYPE_NONE   0
#define I2C_TYPE_MASTER   1
#define I2C_TYPE_SLAVE   2
#define I2C_TYPE_MAX   2
#define I2C_STATE_DISABLED   0
#define I2C_STATE_ENABLED   1
#define I2C_STATE_MAX   1
#define I2C_FLAG_NONE   0x00000000
#define I2C_FLAG_SLAVE   0x00000001
 Device is a slave not a master.
#define I2C_FLAG_10BIT   0x00000002
 Device supports 10bit addressing.
#define I2C_FLAG_16BIT   0x00000004
 Device supports 16bit addressing.
#define I2C_FLAG_DMA   0x00000008
 Device supports DMA transfers.
#define I2C_TRANSFER_NONE   0x00000000
#define I2C_TRANSFER_DMA   0x00000001
 Use DMA for transfer (Write/Read) (If supported) (Note: Buffers must be DMA compatible).
#define I2C_TRANSFER_IGNORE_NAK   0x00000002
 Ignore NAK responses and continue (For compatibility with unusual devices).

Typedefs

typedef struct _I2C_PROPERTIES I2C_PROPERTIES
typedef struct _I2C_DEVICE I2C_DEVICE
typedef uint32_t STDCALL(* i2c_enumerate_cb) (I2C_DEVICE *i2c, void *data)
typedef uint32_t STDCALL(* i2c_notification_cb) (DEVICE *device, void *data, uint32_t notification)
typedef uint32_t STDCALL(* i2c_device_start_proc) (I2C_DEVICE *i2c, uint32_t rate)
typedef uint32_t STDCALL(* i2c_device_stop_proc) (I2C_DEVICE *i2c)
typedef uint32_t STDCALL(* i2c_device_read_proc) (I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
typedef uint32_t STDCALL(* i2c_device_write_proc) (I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
typedef uint32_t STDCALL(* i2c_device_write_read_proc) (I2C_DEVICE *i2c, uint16_t address, void *initial, uint32_t len, void *data, uint32_t size, uint32_t flags, uint32_t *count)
typedef uint32_t STDCALL(* i2c_device_write_write_proc) (I2C_DEVICE *i2c, uint16_t address, void *initial, uint32_t len, void *data, uint32_t size, uint32_t flags, uint32_t *count)
typedef uint32_t STDCALL(* i2c_device_get_rate_proc) (I2C_DEVICE *i2c)
typedef uint32_t STDCALL(* i2c_device_set_rate_proc) (I2C_DEVICE *i2c, uint32_t rate)
typedef uint16_t STDCALL(* i2c_device_get_address_proc) (I2C_DEVICE *i2c)
typedef uint32_t STDCALL(* i2c_device_set_address_proc) (I2C_DEVICE *i2c, uint16_t address)
typedef uint32_t STDCALL(* i2c_device_get_properties_proc) (I2C_DEVICE *i2c, I2C_PROPERTIES *properties)

Functions

uint32_t STDCALL i2c_device_start (I2C_DEVICE *i2c, uint32_t rate)
 Start the specified I2C device ready for reading and writing.
uint32_t STDCALL i2c_device_stop (I2C_DEVICE *i2c)
 Stop the specified I2C device and terminate reading and writing.
uint32_t STDCALL i2c_device_read (I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t *count)
 Read data from the specified I2C device.
uint32_t STDCALL i2c_device_read_ex (I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
 Read data from the specified I2C device.
uint32_t STDCALL i2c_device_write (I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t *count)
 Write data to the specified I2C device.
uint32_t STDCALL i2c_device_write_ex (I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
 Write data to the specified I2C device.
uint32_t STDCALL i2c_device_write_read (I2C_DEVICE *i2c, uint16_t address, void *initial, uint32_t len, void *data, uint32_t size, uint32_t *count)
 Write data to and Read data from the specified I2C device in one operation Useful for devices that require a register address specified before a read (eg EEPROM devices).
uint32_t STDCALL i2c_device_write_read_ex (I2C_DEVICE *i2c, uint16_t address, void *initial, uint32_t len, void *data, uint32_t size, uint32_t flags, uint32_t *count)
 Write data to and Read data from the specified I2C device in one operation Useful for devices that require a register address specified before a read (eg EEPROM devices).
uint32_t STDCALL i2c_device_write_write (I2C_DEVICE *i2c, uint16_t address, void *initial, uint32_t len, void *data, uint32_t size, uint32_t *count)
 Write 2 data blocks to the specified I2C device in one operation Useful for devices that require a register address specified before a write (eg EEPROM devices).
uint32_t STDCALL i2c_device_write_write_ex (I2C_DEVICE *i2c, uint16_t address, void *initial, uint32_t len, void *data, uint32_t size, uint32_t flags, uint32_t *count)
 Write 2 data blocks to the specified I2C device in one operation Useful for devices that require a register address specified before a write (eg EEPROM devices).
uint32_t STDCALL i2c_device_get_rate (I2C_DEVICE *i2c)
 Get the clock rate of the specified I2C device.
uint32_t STDCALL i2c_device_set_rate (I2C_DEVICE *i2c, uint32_t rate)
 Set the clock rate for the specified I2C device.
uint16_t STDCALL i2c_device_get_address (I2C_DEVICE *i2c)
 Get the slave address for the specified I2C device.
uint32_t STDCALL i2c_device_set_address (I2C_DEVICE *i2c, uint16_t address)
 Set the slave address for the specified I2C device.
uint32_t STDCALL i2c_device_properties (I2C_DEVICE *i2c, I2C_PROPERTIES *properties)
 Get the properties for the specified I2C device.
uint32_t STDCALL i2c_device_get_properties (I2C_DEVICE *i2c, I2C_PROPERTIES *properties)
 Get the properties for the specified I2C device.
I2C_DEVICE *STDCALL i2c_device_create (void)
 Create a new I2C entry.
I2C_DEVICE *STDCALL i2c_device_create_ex (uint32_t size)
 Create a new I2C entry.
uint32_t STDCALL i2c_device_destroy (I2C_DEVICE *i2c)
 Destroy an existing I2C entry.
uint32_t STDCALL i2c_device_register (I2C_DEVICE *i2c)
 Register a new I2C in the I2C table.
uint32_t STDCALL i2c_device_deregister (I2C_DEVICE *i2c)
 Deregister an I2C from the I2C table.
I2C_DEVICE *STDCALL i2c_device_find (uint32_t i2cid)
 Find an I2C device by ID in the I2C table.
I2C_DEVICE *STDCALL i2c_device_find_by_name (const char *name)
 Find an I2C device by name in the device table.
I2C_DEVICE *STDCALL i2c_device_find_by_description (const char *description)
 Find an I2C device by description in the device table.
uint32_t STDCALL i2c_device_enumerate (i2c_enumerate_cb callback, void *data)
 Enumerate all I2C devices in the I2C table.
uint32_t STDCALL i2c_device_notification (I2C_DEVICE *i2c, i2c_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
 Register a notification for I2C device changes.
uint32_t STDCALL i2c_slave_start (I2C_DEVICE *i2c)
 Start the specified I2C slave ready for reading and writing.
uint32_t STDCALL i2c_slave_stop (I2C_DEVICE *i2c)
 Stop the specified I2C slave and terminate reading and writing.
uint32_t STDCALL i2c_slave_read (I2C_DEVICE *i2c, void *buffer, uint32_t size, uint32_t *count)
 Read data from the specified I2C slave.
uint32_t STDCALL i2c_slave_write (I2C_DEVICE *i2c, void *buffer, uint32_t size, uint32_t *count)
 Write data to the specified I2C slave.
uint16_t STDCALL i2c_slave_get_address (I2C_DEVICE *i2c)
 Get the address for the specified I2C slave.
uint32_t STDCALL i2c_slave_set_address (I2C_DEVICE *i2c, uint16_t address)
 Set the address for the specified I2C slave.
uint32_t STDCALL i2c_slave_get_properties (I2C_DEVICE *i2c, I2C_PROPERTIES *properties)
 Get the properties for the specified I2C slave.
I2C_DEVICE *STDCALL i2c_slave_create (void)
 Create a new I2C slave entry.
I2C_DEVICE *STDCALL i2c_slave_create_ex (uint32_t size)
 Create a new I2C slave entry.
uint32_t STDCALL i2c_slave_destroy (I2C_DEVICE *i2c)
 Destroy an existing I2C slave entry.
uint32_t STDCALL i2c_slave_register (I2C_DEVICE *i2c)
 Register a new I2C slave in the I2C table.
uint32_t STDCALL i2c_slave_deregister (I2C_DEVICE *i2c)
 Deregister an I2C slave from the I2C table.
I2C_DEVICE *STDCALL i2c_slave_find (uint32_t i2cid)
 Find an I2C slave by ID in the I2C table.
I2C_DEVICE *STDCALL i2c_slave_find_by_name (const char *name)
 Find an I2C slave by name in the device table.
I2C_DEVICE *STDCALL i2c_slave_find_by_description (const char *description)
 Find an I2C slave by description in the device table.
uint32_t STDCALL i2c_get_count (void)
 Get the current I2C count.
I2C_DEVICE *STDCALL i2c_device_get_default (void)
 Get the current default I2C device.
uint32_t STDCALL i2c_device_set_default (I2C_DEVICE *i2c)
 Set the current default I2C device.
I2C_DEVICE *STDCALL i2c_device_check (I2C_DEVICE *i2c)
 Check if the supplied I2C is in the I2C table.
BOOL STDCALL i2c_device_is_slave (I2C_DEVICE *i2c)
 Check if the supplied I2C is a slave device.
uint32_t STDCALL i2c_type_to_string (uint32_t i2ctype, char *string, uint32_t len)
 Convert an I2C type value to a string.
uint32_t STDCALL i2c_state_to_string (uint32_t i2cstate, char *string, uint32_t len)
 Convert an I2C state value to a string.
BOOL STDCALL i2c_is7bit_address (uint16_t address)
 Determine if the supplied address is a 7bit address.
BOOL STDCALL i2c_is10bit_address (uint16_t address)
 Determine if the supplied address is a 10bit address.

Macro Definition Documentation

◆ I2C_NAME_PREFIX

#define I2C_NAME_PREFIX   "I2C"

Name prefix for I2C Devices.

I2C specific constants

◆ I2CSLAVE_NAME_PREFIX

#define I2CSLAVE_NAME_PREFIX   "I2CSlave"

Name prefix for I2C Slave Devices.

◆ I2C_TYPE_NONE

#define I2C_TYPE_NONE   0

I2C Device Types

◆ I2C_TYPE_MASTER

#define I2C_TYPE_MASTER   1

◆ I2C_TYPE_SLAVE

#define I2C_TYPE_SLAVE   2

◆ I2C_TYPE_MAX

#define I2C_TYPE_MAX   2

◆ I2C_STATE_DISABLED

#define I2C_STATE_DISABLED   0

I2C Device States

◆ I2C_STATE_ENABLED

#define I2C_STATE_ENABLED   1

◆ I2C_STATE_MAX

#define I2C_STATE_MAX   1

◆ I2C_FLAG_NONE

#define I2C_FLAG_NONE   0x00000000

I2C Device Flags

◆ I2C_FLAG_SLAVE

#define I2C_FLAG_SLAVE   0x00000001

Device is a slave not a master.

◆ I2C_FLAG_10BIT

#define I2C_FLAG_10BIT   0x00000002

Device supports 10bit addressing.

◆ I2C_FLAG_16BIT

#define I2C_FLAG_16BIT   0x00000004

Device supports 16bit addressing.

◆ I2C_FLAG_DMA

#define I2C_FLAG_DMA   0x00000008

Device supports DMA transfers.

◆ I2C_TRANSFER_NONE

#define I2C_TRANSFER_NONE   0x00000000

I2C Transfer Flags

◆ I2C_TRANSFER_DMA

#define I2C_TRANSFER_DMA   0x00000001

Use DMA for transfer (Write/Read) (If supported) (Note: Buffers must be DMA compatible).

◆ I2C_TRANSFER_IGNORE_NAK

#define I2C_TRANSFER_IGNORE_NAK   0x00000002

Ignore NAK responses and continue (For compatibility with unusual devices).

Typedef Documentation

◆ I2C_PROPERTIES

I2C specific types I2C Properties

◆ I2C_DEVICE

typedef struct _I2C_DEVICE I2C_DEVICE

I2C Device

◆ i2c_enumerate_cb

typedef uint32_t STDCALL(* i2c_enumerate_cb) (I2C_DEVICE *i2c, void *data)

I2C Enumeration Callback

◆ i2c_notification_cb

typedef uint32_t STDCALL(* i2c_notification_cb) (DEVICE *device, void *data, uint32_t notification)

I2C Notification Callback

◆ i2c_device_start_proc

typedef uint32_t STDCALL(* i2c_device_start_proc) (I2C_DEVICE *i2c, uint32_t rate)

I2C Device Methods

◆ i2c_device_stop_proc

typedef uint32_t STDCALL(* i2c_device_stop_proc) (I2C_DEVICE *i2c)

◆ i2c_device_read_proc

typedef uint32_t STDCALL(* i2c_device_read_proc) (I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)

◆ i2c_device_write_proc

typedef uint32_t STDCALL(* i2c_device_write_proc) (I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)

◆ i2c_device_write_read_proc

typedef uint32_t STDCALL(* i2c_device_write_read_proc) (I2C_DEVICE *i2c, uint16_t address, void *initial, uint32_t len, void *data, uint32_t size, uint32_t flags, uint32_t *count)

◆ i2c_device_write_write_proc

typedef uint32_t STDCALL(* i2c_device_write_write_proc) (I2C_DEVICE *i2c, uint16_t address, void *initial, uint32_t len, void *data, uint32_t size, uint32_t flags, uint32_t *count)

◆ i2c_device_get_rate_proc

typedef uint32_t STDCALL(* i2c_device_get_rate_proc) (I2C_DEVICE *i2c)

◆ i2c_device_set_rate_proc

typedef uint32_t STDCALL(* i2c_device_set_rate_proc) (I2C_DEVICE *i2c, uint32_t rate)

◆ i2c_device_get_address_proc

typedef uint16_t STDCALL(* i2c_device_get_address_proc) (I2C_DEVICE *i2c)

◆ i2c_device_set_address_proc

typedef uint32_t STDCALL(* i2c_device_set_address_proc) (I2C_DEVICE *i2c, uint16_t address)

◆ i2c_device_get_properties_proc

typedef uint32_t STDCALL(* i2c_device_get_properties_proc) (I2C_DEVICE *i2c, I2C_PROPERTIES *properties)

Function Documentation

◆ i2c_device_start()

uint32_t STDCALL i2c_device_start ( I2C_DEVICE * i2c,
uint32_t rate )

Start the specified I2C device ready for reading and writing.

I2C Functions

Parameters
I2CThe I2C device to start
RateThe clock rate to set for the device (0 to use the default rate)
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_stop()

uint32_t STDCALL i2c_device_stop ( I2C_DEVICE * i2c)

Stop the specified I2C device and terminate reading and writing.

Parameters
I2CThe I2C device to stop
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_read()

uint32_t STDCALL i2c_device_read ( I2C_DEVICE * i2c,
uint16_t address,
void * buffer,
uint32_t size,
uint32_t * count )

Read data from the specified I2C device.

Parameters
I2CThe I2C device to read from
AddressThe slave address to read from (I2C_ADDRESS_INVALID to use the current address)
BufferPointer to a buffer to receive the data
SizeThe size of the buffer
CountThe number of bytes read on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_read_ex()

uint32_t STDCALL i2c_device_read_ex ( I2C_DEVICE * i2c,
uint16_t address,
void * buffer,
uint32_t size,
uint32_t flags,
uint32_t * count )

Read data from the specified I2C device.

Parameters
I2CThe I2C device to read from
AddressThe slave address to read from (I2C_ADDRESS_INVALID to use the current address)
BufferPointer to a buffer to receive the data
SizeThe size of the buffer
FlagsThe flags for this transfer (eg I2C_TRANSFER_DMA)
CountThe number of bytes read on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_write()

uint32_t STDCALL i2c_device_write ( I2C_DEVICE * i2c,
uint16_t address,
void * buffer,
uint32_t size,
uint32_t * count )

Write data to the specified I2C device.

Parameters
I2CThe I2C device to write to
AddressThe slave address to write to (I2C_ADDRESS_INVALID to use the current address)
BufferPointer to a buffer of data to transmit
SizeThe size of the buffer
CountThe number of bytes written on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_write_ex()

uint32_t STDCALL i2c_device_write_ex ( I2C_DEVICE * i2c,
uint16_t address,
void * buffer,
uint32_t size,
uint32_t flags,
uint32_t * count )

Write data to the specified I2C device.

Parameters
I2CThe I2C device to write to
AddressThe slave address to write to (I2C_ADDRESS_INVALID to use the current address)
BufferPointer to a buffer of data to transmit
SizeThe size of the buffer
FlagsThe flags for this transfer (eg I2C_TRANSFER_DMA)
CountThe number of bytes written on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_write_read()

uint32_t STDCALL i2c_device_write_read ( I2C_DEVICE * i2c,
uint16_t address,
void * initial,
uint32_t len,
void * data,
uint32_t size,
uint32_t * count )

Write data to and Read data from the specified I2C device in one operation Useful for devices that require a register address specified before a read (eg EEPROM devices).

Parameters
I2CThe I2C device to write to and read from
AddressThe slave address to write to (I2C_ADDRESS_INVALID to use the current address)
InitialPointer to the initial buffer to transmit
LenThe size of the initial buffer
DataPointer to a buffer to receive the data
SizeThe size of the data buffer
CountThe number of bytes read on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_write_read_ex()

uint32_t STDCALL i2c_device_write_read_ex ( I2C_DEVICE * i2c,
uint16_t address,
void * initial,
uint32_t len,
void * data,
uint32_t size,
uint32_t flags,
uint32_t * count )

Write data to and Read data from the specified I2C device in one operation Useful for devices that require a register address specified before a read (eg EEPROM devices).

Parameters
I2CThe I2C device to write to and read from
AddressThe slave address to write to (I2C_ADDRESS_INVALID to use the current address)
InitialPointer to the initial buffer to transmit
LenThe size of the initial buffer
DataPointer to a buffer to receive the data
SizeThe size of the data buffer
FlagsThe flags for this transfer (eg I2C_TRANSFER_DMA)
CountThe number of bytes read on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_write_write()

uint32_t STDCALL i2c_device_write_write ( I2C_DEVICE * i2c,
uint16_t address,
void * initial,
uint32_t len,
void * data,
uint32_t size,
uint32_t * count )

Write 2 data blocks to the specified I2C device in one operation Useful for devices that require a register address specified before a write (eg EEPROM devices).

Parameters
I2CThe I2C device to write to
AddressThe slave address to write to (I2C_ADDRESS_INVALID to use the current address)
InitialPointer to the initial buffer to transmit
LenThe size of the initial buffer
DataPointer to a buffer of data to transmit
SizeThe size of the data buffer
CountThe number of bytes of data written on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_write_write_ex()

uint32_t STDCALL i2c_device_write_write_ex ( I2C_DEVICE * i2c,
uint16_t address,
void * initial,
uint32_t len,
void * data,
uint32_t size,
uint32_t flags,
uint32_t * count )

Write 2 data blocks to the specified I2C device in one operation Useful for devices that require a register address specified before a write (eg EEPROM devices).

Parameters
I2CThe I2C device to write to
AddressThe slave address to write to (I2C_ADDRESS_INVALID to use the current address)
InitialPointer to the initial buffer to transmit
LenThe size of the initial buffer
DataPointer to a buffer of data to transmit
SizeThe size of the data buffer
FlagsThe flags for this transfer (eg I2C_TRANSFER_DMA)
CountThe number of bytes of data written on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_get_rate()

uint32_t STDCALL i2c_device_get_rate ( I2C_DEVICE * i2c)

Get the clock rate of the specified I2C device.

Parameters
I2CThe I2C device to get the clock rate from
Returns
The clock rate in Hz or 0 on failure

◆ i2c_device_set_rate()

uint32_t STDCALL i2c_device_set_rate ( I2C_DEVICE * i2c,
uint32_t rate )

Set the clock rate for the specified I2C device.

Parameters
I2CThe I2C device to set the clock rate for
RateThe clock rate to set in Hz
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_get_address()

uint16_t STDCALL i2c_device_get_address ( I2C_DEVICE * i2c)

Get the slave address for the specified I2C device.

Parameters
I2CThe I2C device to get the slave address from
Returns
The slave address or I2C_ADDRESS_INVALID on failure

◆ i2c_device_set_address()

uint32_t STDCALL i2c_device_set_address ( I2C_DEVICE * i2c,
uint16_t address )

Set the slave address for the specified I2C device.

Parameters
I2CThe I2C device to set the slave address for
AddressThe slave address to set
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_properties()

uint32_t STDCALL i2c_device_properties ( I2C_DEVICE * i2c,
I2C_PROPERTIES * properties )

Get the properties for the specified I2C device.

Parameters
I2CThe I2C device to get properties from
PropertiesPointer to a TI2CProperties structure to fill in
Returns
ERROR_SUCCESS if completed or another error code on failure
Note
Replaced by I2CDeviceGetProperties for consistency

◆ i2c_device_get_properties()

uint32_t STDCALL i2c_device_get_properties ( I2C_DEVICE * i2c,
I2C_PROPERTIES * properties )

Get the properties for the specified I2C device.

Parameters
I2CThe I2C device to get properties from
PropertiesPointer to a TI2CProperties structure to fill in
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_create()

I2C_DEVICE *STDCALL i2c_device_create ( void )

Create a new I2C entry.

Returns
Pointer to new I2C entry or nil if I2C could not be created

◆ i2c_device_create_ex()

I2C_DEVICE *STDCALL i2c_device_create_ex ( uint32_t size)

Create a new I2C entry.

Parameters
SizeSize in bytes to allocate for new I2C (Including the I2C entry)
Returns
Pointer to new I2C entry or nil if I2C could not be created

◆ i2c_device_destroy()

uint32_t STDCALL i2c_device_destroy ( I2C_DEVICE * i2c)

Destroy an existing I2C entry.

Parameters
I2CThe I2C device to destroy
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_register()

uint32_t STDCALL i2c_device_register ( I2C_DEVICE * i2c)

Register a new I2C in the I2C table.

Parameters
I2CThe I2C device to register
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_deregister()

uint32_t STDCALL i2c_device_deregister ( I2C_DEVICE * i2c)

Deregister an I2C from the I2C table.

Parameters
I2CThe I2C device to deregister
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_find()

I2C_DEVICE *STDCALL i2c_device_find ( uint32_t i2cid)

Find an I2C device by ID in the I2C table.

Parameters
I2CIdThe ID number of the I2C device to find
Returns
Pointer to I2C device entry or nil if not found

◆ i2c_device_find_by_name()

I2C_DEVICE *STDCALL i2c_device_find_by_name ( const char * name)

Find an I2C device by name in the device table.

Parameters
NameThe name of the I2C device to find (eg I2C0)
Returns
Pointer to I2C device entry or nil if not found

◆ i2c_device_find_by_description()

I2C_DEVICE *STDCALL i2c_device_find_by_description ( const char * description)

Find an I2C device by description in the device table.

Parameters
DescriptionThe description of the I2C to find (eg BCM2837 BSC1 Master I2C)
Returns
Pointer to I2C device entry or nil if not found

◆ i2c_device_enumerate()

uint32_t STDCALL i2c_device_enumerate ( i2c_enumerate_cb callback,
void * data )

Enumerate all I2C devices in the I2C table.

Parameters
CallbackThe callback function to call for each I2C device in the table
DataA private data pointer to pass to callback for each I2C device in the table
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_device_notification()

uint32_t STDCALL i2c_device_notification ( I2C_DEVICE * i2c,
i2c_notification_cb callback,
void * data,
uint32_t notification,
uint32_t flags )

Register a notification for I2C device changes.

Parameters
DeviceThe I2C device to notify changes for (Optional, pass nil for all I2C devices)
CallbackThe function to call when a notification event occurs
DataA private data pointer to pass to callback when a notification event occurs
NotificationThe events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
FlagsThe flags to control the notification (eg NOTIFIER_FLAG_WORKER)

◆ i2c_slave_start()

uint32_t STDCALL i2c_slave_start ( I2C_DEVICE * i2c)

Start the specified I2C slave ready for reading and writing.

I2C Slave Functions

Parameters
I2CThe I2C slave to start
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_slave_stop()

uint32_t STDCALL i2c_slave_stop ( I2C_DEVICE * i2c)

Stop the specified I2C slave and terminate reading and writing.

Parameters
I2CThe I2C slave to stop
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_slave_read()

uint32_t STDCALL i2c_slave_read ( I2C_DEVICE * i2c,
void * buffer,
uint32_t size,
uint32_t * count )

Read data from the specified I2C slave.

Parameters
I2CThe I2C slave to read from
BufferPointer to a buffer to receive the data
SizeThe size of the buffer
CountThe number of bytes read on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_slave_write()

uint32_t STDCALL i2c_slave_write ( I2C_DEVICE * i2c,
void * buffer,
uint32_t size,
uint32_t * count )

Write data to the specified I2C slave.

Parameters
I2CThe I2C slave to write to
BufferPointer to a buffer of data to transmit
SizeThe size of the buffer
CountThe number of bytes written on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_slave_get_address()

uint16_t STDCALL i2c_slave_get_address ( I2C_DEVICE * i2c)

Get the address for the specified I2C slave.

Parameters
I2CThe I2C slave to get the address from
Returns
The address or I2C_ADDRESS_INVALID on failure

◆ i2c_slave_set_address()

uint32_t STDCALL i2c_slave_set_address ( I2C_DEVICE * i2c,
uint16_t address )

Set the address for the specified I2C slave.

Parameters
I2CThe I2C slave to set the address for
AddressThe address to set
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_slave_get_properties()

uint32_t STDCALL i2c_slave_get_properties ( I2C_DEVICE * i2c,
I2C_PROPERTIES * properties )

Get the properties for the specified I2C slave.

Parameters
I2CThe I2C slave to get properties from
PropertiesPointer to a TI2CProperties structure to fill in
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_slave_create()

I2C_DEVICE *STDCALL i2c_slave_create ( void )

Create a new I2C slave entry.

Returns
Pointer to new I2C slave entry or nil if I2C could not be created

◆ i2c_slave_create_ex()

I2C_DEVICE *STDCALL i2c_slave_create_ex ( uint32_t size)

Create a new I2C slave entry.

Parameters
SizeSize in bytes to allocate for new I2C (Including the I2C slave entry)
Returns
Pointer to new I2C slave entry or nil if I2C could not be created

◆ i2c_slave_destroy()

uint32_t STDCALL i2c_slave_destroy ( I2C_DEVICE * i2c)

Destroy an existing I2C slave entry.

Parameters
I2CThe I2C slave to destroy
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_slave_register()

uint32_t STDCALL i2c_slave_register ( I2C_DEVICE * i2c)

Register a new I2C slave in the I2C table.

Parameters
I2CThe I2C slave to register
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_slave_deregister()

uint32_t STDCALL i2c_slave_deregister ( I2C_DEVICE * i2c)

Deregister an I2C slave from the I2C table.

Parameters
I2CThe I2C slave to deregister
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ i2c_slave_find()

I2C_DEVICE *STDCALL i2c_slave_find ( uint32_t i2cid)

Find an I2C slave by ID in the I2C table.

Parameters
I2CIdThe ID number of the I2C slave to find
Returns
Pointer to I2C slave entry or nil if not found

◆ i2c_slave_find_by_name()

I2C_DEVICE *STDCALL i2c_slave_find_by_name ( const char * name)

Find an I2C slave by name in the device table.

Parameters
NameThe name of the I2C slave to find (eg I2CSlave0)
Returns
Pointer to I2C slave entry or nil if not found

◆ i2c_slave_find_by_description()

I2C_DEVICE *STDCALL i2c_slave_find_by_description ( const char * description)

Find an I2C slave by description in the device table.

Parameters
DescriptionThe description of the I2C slave to find (eg BCM2837 I2C Slave)
Returns
Pointer to I2C slave entry or nil if not found

◆ i2c_get_count()

uint32_t STDCALL i2c_get_count ( void )

Get the current I2C count.

I2C Helper Functions

◆ i2c_device_get_default()

I2C_DEVICE *STDCALL i2c_device_get_default ( void )

Get the current default I2C device.

◆ i2c_device_set_default()

uint32_t STDCALL i2c_device_set_default ( I2C_DEVICE * i2c)

Set the current default I2C device.

◆ i2c_device_check()

I2C_DEVICE *STDCALL i2c_device_check ( I2C_DEVICE * i2c)

Check if the supplied I2C is in the I2C table.

◆ i2c_device_is_slave()

BOOL STDCALL i2c_device_is_slave ( I2C_DEVICE * i2c)

Check if the supplied I2C is a slave device.

◆ i2c_type_to_string()

uint32_t STDCALL i2c_type_to_string ( uint32_t i2ctype,
char * string,
uint32_t len )

Convert an I2C type value to a string.

◆ i2c_state_to_string()

uint32_t STDCALL i2c_state_to_string ( uint32_t i2cstate,
char * string,
uint32_t len )

Convert an I2C state value to a string.

◆ i2c_is7bit_address()

BOOL STDCALL i2c_is7bit_address ( uint16_t address)

Determine if the supplied address is a 7bit address.

◆ i2c_is10bit_address()

BOOL STDCALL i2c_is10bit_address ( uint16_t address)

Determine if the supplied address is a 10bit address.