38#define I2C_NAME_PREFIX "I2C"
39#define I2CSLAVE_NAME_PREFIX "I2CSlave"
42#define I2C_TYPE_NONE 0
43#define I2C_TYPE_MASTER 1
44#define I2C_TYPE_SLAVE 2
49#define I2C_STATE_DISABLED 0
50#define I2C_STATE_ENABLED 1
52#define I2C_STATE_MAX 1
55#define I2C_FLAG_NONE 0x00000000
56#define I2C_FLAG_SLAVE 0x00000001
57#define I2C_FLAG_10BIT 0x00000002
58#define I2C_FLAG_16BIT 0x00000004
59#define I2C_FLAG_DMA 0x00000008
62#define I2C_TRANSFER_NONE 0x00000000
63#define I2C_TRANSFER_DMA 0x00000001
64#define I2C_TRANSFER_IGNORE_NAK 0x00000002
struct _DEVICE DEVICE
Definition devices.h:373
#define STDCALL
Definition globaltypes.h:45
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
HANDLE SEMAPHORE_HANDLE
Definition globaltypes.h:107
HANDLE MUTEX_HANDLE
Definition globaltypes.h:105
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_destroy(I2C_DEVICE *i2c)
Destroy an existing I2C entry.
BOOL STDCALL i2c_is7bit_address(uint16_t address)
Determine if the supplied address is a 7bit address.
uint32_t STDCALL(* i2c_device_write_proc)(I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
Definition i2c.h:93
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_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 re...
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_start_proc)(I2C_DEVICE *i2c, uint32_t rate)
Definition i2c.h:89
uint32_t STDCALL i2c_device_get_properties(I2C_DEVICE *i2c, I2C_PROPERTIES *properties)
Get the properties for the specified I2C device.
uint32_t STDCALL i2c_device_register(I2C_DEVICE *i2c)
Register a new I2C in the I2C table.
uint32_t STDCALL(* i2c_device_read_proc)(I2C_DEVICE *i2c, uint16_t address, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
Definition i2c.h:92
uint32_t STDCALL(* i2c_device_get_rate_proc)(I2C_DEVICE *i2c)
Definition i2c.h:97
uint32_t STDCALL i2c_device_start(I2C_DEVICE *i2c, uint32_t rate)
Start the specified I2C device ready for reading and writing.
I2C_DEVICE *STDCALL i2c_device_find_by_description(const char *description)
Find an I2C device by description in the device table.
I2C_DEVICE *STDCALL i2c_device_find(uint32_t i2cid)
Find an I2C device by ID in the I2C 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_device_deregister(I2C_DEVICE *i2c)
Deregister an I2C from 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_destroy(I2C_DEVICE *i2c)
Destroy an existing I2C slave entry.
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 re...
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 re...
uint32_t STDCALL i2c_slave_register(I2C_DEVICE *i2c)
Register a new I2C slave in the I2C table.
I2C_DEVICE *STDCALL i2c_device_create(void)
Create a new I2C entry.
struct _I2C_PROPERTIES I2C_PROPERTIES
Definition i2c.h:69
uint32_t STDCALL i2c_get_count(void)
Get the current I2C count.
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_stop(I2C_DEVICE *i2c)
Stop the specified I2C device and terminate reading and writing.
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)
Definition i2c.h:94
I2C_DEVICE *STDCALL i2c_device_find_by_name(const char *name)
Find an I2C device by name in the device table.
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_state_to_string(uint32_t i2cstate, char *string, uint32_t len)
Convert an I2C state value to a string.
uint32_t STDCALL(* i2c_enumerate_cb)(I2C_DEVICE *i2c, void *data)
Definition i2c.h:84
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.
uint32_t STDCALL(* i2c_device_stop_proc)(I2C_DEVICE *i2c)
Definition i2c.h:90
uint32_t STDCALL i2c_device_enumerate(i2c_enumerate_cb callback, void *data)
Enumerate all I2C devices 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_device_check(I2C_DEVICE *i2c)
Check if the supplied I2C is in the I2C table.
uint32_t STDCALL i2c_slave_start(I2C_DEVICE *i2c)
Start the specified I2C slave ready for reading and writing.
uint32_t STDCALL(* i2c_notification_cb)(DEVICE *device, void *data, uint32_t notification)
Definition i2c.h:86
uint32_t STDCALL(* i2c_device_set_rate_proc)(I2C_DEVICE *i2c, uint32_t rate)
Definition i2c.h:98
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 re...
I2C_DEVICE *STDCALL i2c_device_get_default(void)
Get the current default I2C device.
uint32_t STDCALL(* i2c_device_get_properties_proc)(I2C_DEVICE *i2c, I2C_PROPERTIES *properties)
Definition i2c.h:103
uint32_t STDCALL i2c_device_get_rate(I2C_DEVICE *i2c)
Get the clock rate of the specified I2C device.
I2C_DEVICE *STDCALL i2c_slave_create_ex(uint32_t size)
Create a new I2C slave entry.
uint32_t STDCALL(* i2c_device_set_address_proc)(I2C_DEVICE *i2c, uint16_t address)
Definition i2c.h:101
uint32_t STDCALL i2c_slave_stop(I2C_DEVICE *i2c)
Stop the specified I2C slave and terminate reading and writing.
uint16_t STDCALL(* i2c_device_get_address_proc)(I2C_DEVICE *i2c)
Definition i2c.h:100
I2C_DEVICE *STDCALL i2c_device_create_ex(uint32_t size)
Create a new I2C entry.
uint16_t STDCALL i2c_slave_get_address(I2C_DEVICE *i2c)
Get the address for the specified I2C slave.
struct _I2C_DEVICE I2C_DEVICE
Definition i2c.h:81
uint32_t STDCALL i2c_device_set_default(I2C_DEVICE *i2c)
Set the current default I2C device.
BOOL STDCALL i2c_device_is_slave(I2C_DEVICE *i2c)
Check if the supplied I2C is a slave device.
uint32_t STDCALL i2c_slave_write(I2C_DEVICE *i2c, void *buffer, uint32_t size, uint32_t *count)
Write data to 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.
uint16_t STDCALL i2c_device_get_address(I2C_DEVICE *i2c)
Get the slave address for the specified I2C device.
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.
I2C_DEVICE *STDCALL i2c_slave_create(void)
Create a new I2C slave entry.
BOOL STDCALL i2c_is10bit_address(uint16_t address)
Determine if the supplied address is a 10bit address.
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)
Definition i2c.h:95
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_slave_get_properties(I2C_DEVICE *i2c, I2C_PROPERTIES *properties)
Get the properties for the specified I2C slave.
uint32_t STDCALL i2c_device_set_rate(I2C_DEVICE *i2c, uint32_t rate)
Set the clock rate 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.
MUTEX_HANDLE lock
Device lock.
Definition i2c.h:129
uint32_t writecount
Definition i2c.h:125
uint32_t i2cstate
I2C state (eg I2C_STATE_ENABLED).
Definition i2c.h:111
i2c_device_get_properties_proc devicegetproperties
A Device specific DeviceGetProperties method implementing the standard I2C device interface (Or nil i...
Definition i2c.h:122
DEVICE device
The Device entry for this I2C.
Definition i2c.h:108
i2c_device_set_address_proc devicesetaddress
A Device specific DeviceSetAddress method implementing the standard I2C device interface (Or nil if t...
Definition i2c.h:121
I2C_PROPERTIES properties
Device properties.
Definition i2c.h:133
uint32_t writeerrors
Definition i2c.h:127
i2c_device_write_proc devicewrite
A Device specific DeviceWrite method implementing the standard I2C device interface (Mandatory).
Definition i2c.h:115
I2C_DEVICE * next
Next entry in I2C table.
Definition i2c.h:136
i2c_device_stop_proc devicestop
A Device specific DeviceStop method implementing the standard I2C device interface (Mandatory).
Definition i2c.h:113
i2c_device_write_read_proc devicewriteread
A Device specific DeviceWriteRead method implementing the standard I2C device interface (Or nil if th...
Definition i2c.h:116
uint32_t readerrors
Definition i2c.h:126
I2C_DEVICE * prev
Previous entry in I2C table.
Definition i2c.h:135
i2c_device_read_proc deviceread
A Device specific DeviceRead method implementing the standard I2C device interface (Mandatory).
Definition i2c.h:114
uint32_t readcount
Definition i2c.h:124
i2c_device_set_rate_proc devicesetrate
A Device specific DeviceSetRate method implementing the standard I2C device interface (Or nil if the ...
Definition i2c.h:119
i2c_device_get_rate_proc devicegetrate
A Device specific DeviceGetRate method implementing the standard I2C device interface (Or nil if the ...
Definition i2c.h:118
uint32_t clockrate
Clock rate (Hz).
Definition i2c.h:131
SEMAPHORE_HANDLE wait
Read/Write wait event.
Definition i2c.h:130
i2c_device_write_write_proc devicewritewrite
A Device specific DeviceWriteWrite method implementing the standard I2C device interface (Or nil if t...
Definition i2c.h:117
uint32_t i2cid
Unique Id of this I2C in the I2C table.
Definition i2c.h:110
uint16_t slaveaddress
Slave address.
Definition i2c.h:132
i2c_device_start_proc devicestart
A Device specific DeviceStart method implementing the standard I2C device interface (Mandatory).
Definition i2c.h:112
i2c_device_get_address_proc devicegetaddress
A Device specific DeviceGetAddress method implementing the standard I2C device interface (Or nil if t...
Definition i2c.h:120
uint32_t maxclock
Maximum supported clock rate.
Definition i2c.h:75
uint32_t flags
Device flags (eg I2C_FLAG_SLAVE).
Definition i2c.h:72
uint32_t minclock
Minimum supported clock rate.
Definition i2c.h:74
uint32_t maxsize
Maximum supported data transfer size.
Definition i2c.h:73
uint32_t clockrate
Current clock rate.
Definition i2c.h:76
uint16_t slaveaddress
Current slave address.
Definition i2c.h:77