Difference between revisions of "Unit I2C"
(13 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
---- | ---- | ||
− | '''Ultibo I2C | + | '''Ultibo I2C Interface unit''' |
I2C (Inter-Integrated Circuit) is a serial bus for communication between peripheral components. | I2C (Inter-Integrated Circuit) is a serial bus for communication between peripheral components. | ||
Line 12: | Line 12: | ||
Each device is assigned a 7bit address which is used by the host (or master) to signal the device that a message written to the bus is intended for that device or that the host wants to read data from that device. | Each device is assigned a 7bit address which is used by the host (or master) to signal the device that a message written to the bus is intended for that device or that the host wants to read data from that device. | ||
+ | |||
+ | A small number of devices and hosts support 10bit addressing which expands the number of available addresses. The 10bit address format is defined here https://www.i2c-bus.org/addressing/10-bit-addressing/ and the reserved addresses are defined on this page https://www.i2c-bus.org/addressing/ | ||
Speeds range from 10Kbps to 3.4Mbps although the typical speed is either 100Kbps or 400Kbps. | Speeds range from 10Kbps to 3.4Mbps although the typical speed is either 100Kbps or 400Kbps. | ||
Line 30: | Line 32: | ||
| <code>I2C_NAME_PREFIX = 'I2C';</code> | | <code>I2C_NAME_PREFIX = 'I2C';</code> | ||
| Name prefix for I2C Devices | | Name prefix for I2C Devices | ||
+ | |- | ||
+ | | <code>I2CSLAVE_NAME_PREFIX = 'I2CSlave';</code> | ||
+ | | Name prefix for I2C Slave Devices | ||
|- | |- | ||
|} | |} | ||
Line 35: | Line 40: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''I2C device type | + | <div style="font-size: 14px; padding-left: 12px;">'''I2C device type''' <code> I2C_TYPE_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 41: | Line 46: | ||
| <code>I2C_TYPE_NONE = 0;</code> | | <code>I2C_TYPE_NONE = 0;</code> | ||
| style="width: 50%;"| | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>I2C_TYPE_MASTER = 1;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>I2C_TYPE_SLAVE = 2;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>I2C_TYPE_MAX = 2;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|I2C Type Names | ||
+ | |- | ||
+ | |colspan="2"|<code>I2C_TYPE_NAMES:array[I2C_TYPE_NONE..I2C_TYPE_MAX] of String = ('I2C_TYPE_NONE', 'I2C_TYPE_MASTER', 'I2C_TYPE_SLAVE');</code> | ||
|- | |- | ||
|} | |} | ||
Line 46: | Line 68: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''I2C device state | + | <div style="font-size: 14px; padding-left: 12px;">'''I2C device state''' <code> I2C_STATE_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 55: | Line 77: | ||
| <code>I2C_STATE_ENABLED = 1;</code> | | <code>I2C_STATE_ENABLED = 1;</code> | ||
| | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>I2C_STATE_MAX = 1;</code> | ||
+ | | style="width: 50%;"| | ||
|- | |- | ||
|} | |} | ||
Line 60: | Line 87: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''I2C device flag | + | <div style="font-size: 14px; padding-left: 12px;">'''I2C device flag''' <code> I2C_FLAG_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 80: | Line 107: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''I2C logging | + | <div style="font-size: 14px; padding-left: 12px;">'''I2C logging''' <code> I2C_LOG_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 89: | Line 116: | ||
| <code>I2C_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code> | | <code>I2C_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code> | ||
| I2C informational messages, such as a device being attached or detached | | I2C informational messages, such as a device being attached or detached | ||
+ | |- | ||
+ | | <code>I2C_LOG_LEVEL_WARN = LOG_LEVEL_WARN;</code> | ||
+ | | I2C warning messages | ||
|- | |- | ||
| <code>I2C_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code> | | <code>I2C_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code> | ||
Line 103: | Line 133: | ||
---- | ---- | ||
− | '' | + | |
+ | '''I2C properties''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PI2CProperties = ^TI2CProperties;</code> | ||
+ | |||
+ | <code>TI2CProperties = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>Flags:LongWord;</code> | ||
+ | | Device flags (eg I2C_FLAG_SLAVE) | ||
+ | |- | ||
+ | | <code>MaxSize:LongWord;</code> | ||
+ | | Maximum supported data transfer size | ||
+ | |- | ||
+ | | <code>MinClock:LongWord;</code> | ||
+ | | Minimum supported clock rate | ||
+ | |- | ||
+ | | <code>MaxClock:LongWord;</code> | ||
+ | | Maximum supported clock rate | ||
+ | |- | ||
+ | | <code>ClockRate:LongWord;</code> | ||
+ | | Current clock rate | ||
+ | |- | ||
+ | | <code>SlaveAddress:Word;</code> | ||
+ | | Current slave address | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''I2C enumeration callback''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CEnumerate = function(I2C:PI2CDevice; Data:Pointer):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C notification callback''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device start''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceStart = function(I2C:PI2CDevice;Rate:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device stop''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceStop = function(I2C:PI2CDevice):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device read''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceRead = function(I2C:PI2CDevice; Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device write''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceWrite = function(I2C:PI2CDevice; Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device write read''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceWriteRead = function(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device write write''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceWriteWrite = function(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device get rate''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceGetRate = function(I2C:PI2CDevice):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device set rate''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceSetRate = function(I2C:PI2CDevice; Rate:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device get address''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceGetAddress = function(I2C:PI2CDevice):Word;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device set address''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceSetAddress = function(I2C:PI2CDevice; Address:Word):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device get properties''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TI2CDeviceGetProperties = function(I2C:PI2CDevice; Properties:PI2CProperties):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''I2C device''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PI2CDevice = ^TI2CDevice;</code> | ||
+ | |||
+ | <code>TI2CDevice = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|''Device Properties'' | ||
+ | |- | ||
+ | | <code>Device:TDevice;</code> | ||
+ | | The Device entry for this I2C | ||
+ | |- | ||
+ | |colspan="2"|''I2C Properties'' | ||
+ | |- | ||
+ | | <code>I2CId:LongWord;</code> | ||
+ | | Unique Id of this I2C in the I2C table | ||
+ | |- | ||
+ | | <code>I2CState:LongWord;</code> | ||
+ | | I2C state (eg I2C_STATE_ENABLED) | ||
+ | |- | ||
+ | | <code>DeviceStart:TI2CDeviceStart;</code> | ||
+ | | A Device specific DeviceStart method implementing the standard I2C device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceStop:TI2CDeviceStop;</code> | ||
+ | | A Device specific DeviceStop method implementing the standard I2C device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceRead:TI2CDeviceRead;</code> | ||
+ | | A Device specific DeviceRead method implementing the standard I2C device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceWrite:TI2CDeviceWrite;</code> | ||
+ | | A Device specific DeviceWrite method implementing the standard I2C device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceWriteRead:TI2CDeviceWriteRead;</code> | ||
+ | | A Device specific DeviceWriteRead method implementing the standard I2C device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceWriteWrite:TI2CDeviceWriteWrite;</code> | ||
+ | | A Device specific DeviceWriteWrite method implementing the standard I2C device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceGetRate:TI2CDeviceGetRate;</code> | ||
+ | | A Device specific DeviceGetRate method implementing the standard I2C device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceSetRate:TI2CDeviceSetRate;</code> | ||
+ | | A Device specific DeviceSetRate method implementing the standard I2C device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceGetAddress:TI2CDeviceGetAddress;</code> | ||
+ | | A Device specific DeviceGetAddress method implementing the standard I2C device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceSetAddress:TI2CDeviceSetAddress;</code> | ||
+ | | A Device specific DeviceSetAddress method implementing the standard I2C device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceGetProperties:TI2CDeviceGetProperties;</code> | ||
+ | | A Device specific DeviceGetProperties method implementing the standard I2C device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | |colspan="2"|''Statistics Properties'' | ||
+ | |- | ||
+ | | <code>ReadCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>WriteCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>ReadErrors:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>WriteErrors:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''Driver Properties'' | ||
+ | |- | ||
+ | | <code>Lock:TMutexHandle;</code> | ||
+ | | Device lock | ||
+ | |- | ||
+ | | <code>Wait:TSemaphoreHandle;</code> | ||
+ | | Read/Write wait event | ||
+ | |- | ||
+ | | <code>ClockRate:LongWord;</code> | ||
+ | | Clock rate (Hz) | ||
+ | |- | ||
+ | | <code>SlaveAddress:Word;</code> | ||
+ | | Slave address | ||
+ | |- | ||
+ | | <code>Properties:TI2CProperties;</code> | ||
+ | | Device properties | ||
+ | |- | ||
+ | |colspan="2"|''Internal Properties'' | ||
+ | |- | ||
+ | | <code>Prev:PI2CDevice;</code> | ||
+ | | Previous entry in I2C table | ||
+ | |- | ||
+ | | <code>Next:PI2CDevice;</code> | ||
+ | | Next entry in I2C table | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === | ||
Line 114: | Line 388: | ||
|- | |- | ||
| <code>I2C_DEFAULT_LOG_LEVEL:LongWord = I2C_LOG_LEVEL_DEBUG;</code> | | <code>I2C_DEFAULT_LOG_LEVEL:LongWord = I2C_LOG_LEVEL_DEBUG;</code> | ||
− | | style="width: | + | | style="width: 40%;"|Minimum level for I2C messages. Only messages with level greater than or equal to this will be printed. |
|- | |- | ||
|} | |} | ||
Line 120: | Line 394: | ||
|- | |- | ||
| <code>I2C_LOG_ENABLED:Boolean;</code> | | <code>I2C_LOG_ENABLED:Boolean;</code> | ||
− | | style="width: | + | | style="width: 40%;"| |
|- | |- | ||
|} | |} | ||
Line 137: | Line 411: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| Called only during system startup | | Called only during system startup | ||
|- | |- | ||
Line 152: | Line 426: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to start | | The I2C device to start | ||
|- | |- | ||
− | ! | + | ! Rate |
− | | The clock rate to set for the device (0 to use the default rate | + | | The clock rate to set for the device (0 to use the default rate) |
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 170: | Line 444: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to stop | | The I2C device to stop | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 185: | Line 459: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to read from | | The I2C device to read from | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to read from (I2C_ADDRESS_INVALID to use the current address) | | The slave address to read from (I2C_ADDRESS_INVALID to use the current address) | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer to receive the data | | Pointer to a buffer to receive the data | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the buffer | | The size of the buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes read on return | | The number of bytes read on return | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 212: | Line 486: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to write to | | The I2C device to write to | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer of data to transmit | | Pointer to a buffer of data to transmit | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the buffer | | The size of the buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes written on return | | The number of bytes written on return | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 235: | Line 509: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function I2CDeviceWriteRead(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceWriteRead(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write data to and Read data from the specified I2C device in one operation | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write data to and Read data from the specified I2C device in one operation</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to write to and read from | | The I2C device to write to and read from | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | ||
|- | |- | ||
− | ! | + | ! Initial |
| Pointer to the initial buffer to transmit | | Pointer to the initial buffer to transmit | ||
|- | |- | ||
− | ! | + | ! Len |
| The size of the initial buffer | | The size of the initial buffer | ||
|- | |- | ||
− | ! | + | ! Data |
| Pointer to a buffer to receive the data | | Pointer to a buffer to receive the data | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the data buffer | | The size of the data buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes read on return | | The number of bytes read on return | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | Useful for devices that require a register address specified before a read (eg EEPROM devices) | ||
|- | |- | ||
|} | |} | ||
Line 268: | Line 545: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function I2CDeviceWriteWrite(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceWriteWrite(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write 2 data blocks to the specified I2C device in one operation | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write 2 data blocks to the specified I2C device in one operation</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to write to | | The I2C device to write to | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | ||
|- | |- | ||
− | ! | + | ! Initial |
| Pointer to the initial buffer to transmit | | Pointer to the initial buffer to transmit | ||
|- | |- | ||
− | ! | + | ! Len |
| The size of the initial buffer | | The size of the initial buffer | ||
|- | |- | ||
− | ! | + | ! Data |
| Pointer to a buffer of data to transmit | | Pointer to a buffer of data to transmit | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the data buffer | | The size of the data buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes of data written on return | | The number of bytes of data written on return | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | Useful for devices that require a register address specified before a write (eg EEPROM devices) | ||
|- | |- | ||
|} | |} | ||
Line 305: | Line 585: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to get the clock rate from | | The I2C device to get the clock rate from | ||
|- | |- | ||
− | ! | + | ! Return |
| The clock rate in Hz or 0 on failure | | The clock rate in Hz or 0 on failure | ||
|- | |- | ||
Line 320: | Line 600: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to set the clock rate for | | The I2C device to set the clock rate for | ||
|- | |- | ||
− | ! | + | ! Rate |
| The clock rate to set in Hz | | The clock rate to set in Hz | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 338: | Line 618: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to get the slave address from | | The I2C device to get the slave address from | ||
|- | |- | ||
− | ! | + | ! Return |
| The slave address or I2C_ADDRESS_INVALID on failure | | The slave address or I2C_ADDRESS_INVALID on failure | ||
|- | |- | ||
Line 353: | Line 633: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to set the slave address for | | The I2C device to set the slave address for | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to set | | The slave address to set | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 366: | Line 646: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceProperties(I2C:PI2CDevice; Properties:PI2CProperties):LongWord;</pre> | + | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceProperties(I2C:PI2CDevice; Properties:PI2CProperties):LongWord; inline;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified I2C device</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified I2C device</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device to get properties from | | The I2C device to get properties from | ||
|- | |- | ||
− | ! | + | ! Properties |
| Pointer to a TI2CProperties structure to fill in | | Pointer to a TI2CProperties structure to fill in | ||
|- | |- | ||
− | ! ''' | + | ! Return |
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | Replaced by I2CDeviceGetProperties for consistency | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceGetProperties(I2C:PI2CDevice; Properties:PI2CProperties):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified I2C device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C device to get properties from | ||
+ | |- | ||
+ | ! Properties | ||
+ | | Pointer to a TI2CProperties structure to fill in | ||
+ | |- | ||
+ | ! Return | ||
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 389: | Line 690: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to new I2C entry or nil if I2C could not be created | | Pointer to new I2C entry or nil if I2C could not be created | ||
|- | |- | ||
Line 401: | Line 702: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Size |
| Size in bytes to allocate for new I2C (Including the I2C entry) | | Size in bytes to allocate for new I2C (Including the I2C entry) | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to new I2C entry or nil if I2C could not be created | | Pointer to new I2C entry or nil if I2C could not be created | ||
|- | |- | ||
Line 416: | Line 717: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
− | | | + | | The I2C device to destroy |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 428: | Line 732: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
− | | | + | | The I2C device to register |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 436: | Line 743: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function I2CDeviceDeregister(I2C:PI2CDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceDeregister(I2C:PI2CDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister an I2C from the I2C table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
− | | | + | | The I2C device to deregister |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 448: | Line 758: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function I2CDeviceFind(I2CId:LongWord):PI2CDevice;</pre> | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceFind(I2CId:LongWord):PI2CDevice;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find an I2C device by ID in the I2C table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2CId |
− | | | + | | The ID number of the I2C device to find |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to I2C device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 460: | Line 773: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function I2CDeviceFindByName(const Name:String):PI2CDevice; inline;</pre> | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceFindByName(const Name:String):PI2CDevice; inline;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find an I2C device by name in the device table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Name |
− | | | + | | The name of the I2C device to find (eg I2C0) |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to I2C device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 472: | Line 788: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function I2CDeviceFindByDescription(const Description:String):PI2CDevice; inline;</pre> | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceFindByDescription(const Description:String):PI2CDevice; inline;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find an I2C device by description in the device table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Description |
− | | | + | | The description of the I2C to find (eg BCM2837 BSC1 Master I2C) |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to I2C device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 484: | Line 803: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function I2CDeviceEnumerate(Callback:TI2CEnumerate; Data:Pointer):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceEnumerate(Callback:TI2CEnumerate; Data:Pointer):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Enumerate all I2C devices in the I2C table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Callback |
− | | | + | | The callback function to call for each I2C device in the table |
+ | |- | ||
+ | ! Data | ||
+ | | A private data pointer to pass to callback for each I2C device in the table | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 496: | Line 821: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function I2CDeviceNotification(I2C:PI2CDevice; Callback:TI2CNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceNotification(I2C:PI2CDevice; Callback:TI2CNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a notification for I2C device changes</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! ''' | + | ! Device |
− | | | + | | The I2C device to notify changes for (Optional, pass nil for all I2C devices) |
+ | |- | ||
+ | ! Callback | ||
+ | | The function to call when a notification event occurs | ||
+ | |- | ||
+ | ! Data | ||
+ | | A private data pointer to pass to callback when a notification event occurs | ||
+ | |- | ||
+ | ! Notification | ||
+ | | The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER) | ||
+ | |- | ||
+ | ! Flags | ||
+ | | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''I2C slave functions''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveStart(I2C:PI2CDevice):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start the specified I2C slave ready for reading and writing</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to start | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveStop(I2C:PI2CDevice):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Stop the specified I2C slave and terminate reading and writing</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to stop | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveRead(I2C:PI2CDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Read data from the specified I2C slave</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to read from | ||
+ | |- | ||
+ | ! Buffer | ||
+ | | Pointer to a buffer to receive the data | ||
+ | |- | ||
+ | ! Size | ||
+ | | The size of the buffer | ||
+ | |- | ||
+ | ! Count | ||
+ | | The number of bytes read on return | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveWrite(I2C:PI2CDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write data to the specified I2C slave</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to write to | ||
+ | |- | ||
+ | ! Buffer | ||
+ | | Pointer to a buffer of data to transmit | ||
+ | |- | ||
+ | ! Size | ||
+ | | The size of the buffer | ||
+ | |- | ||
+ | ! Count | ||
+ | | The number of bytes written on return | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveGetAddress(I2C:PI2CDevice):Word; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the address for the specified I2C slave</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to get the address from | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveSetAddress(I2C:PI2CDevice; Address:Word):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the address for the specified I2C slave</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to set the address for | ||
+ | |- | ||
+ | ! Address | ||
+ | | The address to set | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveGetProperties(I2C:PI2CDevice; Properties:PI2CProperties):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified I2C slave</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to get properties from | ||
+ | |- | ||
+ | ! Properties | ||
+ | | Pointer to a TI2CProperties structure to fill in | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveCreate:PI2CDevice;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new I2C slave entry</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to new I2C slave entry or nil if I2C could not be created | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveCreateEx(Size:LongWord):PI2CDevice;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new I2C slave entry</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Size | ||
+ | | Size in bytes to allocate for new I2C (Including the I2C slave entry) | ||
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to new I2C slave entry or nil if I2C could not be created | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveDestroy(I2C:PI2CDevice):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Destroy an existing I2C slave entry</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to destroy | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveRegister(I2C:PI2CDevice):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a new I2C slave in the I2C table</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to register | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveDeregister(I2C:PI2CDevice):LongWord; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister an I2C slave from the I2C table</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2C | ||
+ | | The I2C slave to deregister | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveFind(I2CId:LongWord):PI2CDevice;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find an I2C slave by ID in the I2C table</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! I2CId | ||
+ | | The ID number of the I2C slave to find | ||
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to I2C slave entry or nil if not found | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveFindByName(const Name:String):PI2CDevice; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find an I2C slave by name in the device table</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Name | ||
+ | | The name of the I2C slave to find (eg I2CSlave0) | ||
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to I2C slave entry or nil if not found | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CSlaveFindByDescription(const Description:String):PI2CDevice; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find an I2C slave by description in the device table</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Description | ||
+ | | The description of the I2C slave to find (eg BCM2837 I2C Slave) | ||
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to I2C slave entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 515: | Line 1,101: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 527: | Line 1,113: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Rate |
| The clock rate to set for the device (0 to use the default rate) | | The clock rate to set for the device (0 to use the default rate) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 542: | Line 1,128: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 554: | Line 1,140: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to read from (I2C_ADDRESS_INVALID to use the current address) | | The slave address to read from (I2C_ADDRESS_INVALID to use the current address) | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer to receive the data | | Pointer to a buffer to receive the data | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the buffer | | The size of the buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes read on return | | The number of bytes read on return | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 578: | Line 1,164: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer of data to transmit | | Pointer to a buffer of data to transmit | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the buffer | | The size of the buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes written on return | | The number of bytes written on return | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 598: | Line 1,184: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SysI2CWriteRead(Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SysI2CWriteRead(Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write data to and Read data from the default I2C device in one operation | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write data to and Read data from the default I2C device in one operation</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | ||
|- | |- | ||
− | ! | + | ! Initial |
| Pointer to the initial buffer to transmit | | Pointer to the initial buffer to transmit | ||
|- | |- | ||
− | ! | + | ! Len |
| The size of the initial buffer | | The size of the initial buffer | ||
|- | |- | ||
− | ! | + | ! Data |
| Pointer to a buffer to receive the data | | Pointer to a buffer to receive the data | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the data buffer | | The size of the data buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes read on return | | The number of bytes read on return | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | Useful for devices that require a register address specified before a read (eg EEPROM devices) | ||
|- | |- | ||
|} | |} | ||
Line 628: | Line 1,217: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function SysI2CWriteWrite(Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function SysI2CWriteWrite(Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write 2 data blocks to the default I2C device in one operation | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write 2 data blocks to the default I2C device in one operation</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) | ||
|- | |- | ||
− | ! | + | ! Initial |
| Pointer to the initial buffer to transmit | | Pointer to the initial buffer to transmit | ||
|- | |- | ||
− | ! | + | ! Len |
| The size of the initial buffer | | The size of the initial buffer | ||
|- | |- | ||
− | ! | + | ! Data |
| Pointer to a buffer of data to transmit | | Pointer to a buffer of data to transmit | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the data buffer | | The size of the data buffer | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of bytes of data written on return | | The number of bytes of data written on return | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | Useful for devices that require a register address specified before a write (eg EEPROM devices) | ||
|- | |- | ||
|} | |} | ||
Line 662: | Line 1,254: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| The clock rate in Hz or 0 on failure | | The clock rate in Hz or 0 on failure | ||
|- | |- | ||
Line 674: | Line 1,266: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Rate |
| The clock rate to set in Hz | | The clock rate to set in Hz | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 689: | Line 1,281: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| The slave address or I2C_ADDRESS_INVALID on failure | | The slave address or I2C_ADDRESS_INVALID on failure | ||
|- | |- | ||
Line 701: | Line 1,293: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Address |
| The slave address to set | | The slave address to set | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 714: | Line 1,306: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function I2CGetCount:LongWord | + | <pre style="border: 0; padding-bottom:0px;">function I2CGetCount:LongWord;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current I2C count</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current I2C count</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 726: | Line 1,318: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceGetDefault:PI2CDevice | + | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceGetDefault:PI2CDevice;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default I2C device</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default I2C device</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 743: | Line 1,335: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 755: | Line 1,347: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! '''Note''' | + | ! Note |
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CDeviceIsSlave(I2C:PI2CDevice):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if the supplied I2C is a slave device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CTypeToString(I2CType:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert an I2C type value to a string</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CStateToString(I2CState:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert an I2C state value to a string</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CIs7BitAddress(Address:Word):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Determine if the supplied address is a 7bit address</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">function I2CIs10BitAddress(Address:Word):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Determine if the supplied address is a 10bit address</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
| None documented | | None documented | ||
|- | |- | ||
Line 767: | Line 1,419: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 779: | Line 1,431: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! ''' | + | ! Note |
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">procedure I2CLogWarn(I2C:PI2CDevice; const AText:String); inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
| None documented | | None documented | ||
|- | |- | ||
Line 791: | Line 1,455: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 803: | Line 1,467: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- |
Latest revision as of 03:47, 15 December 2022
Return to Unit Reference
Description
Ultibo I2C Interface unit
I2C (Inter-Integrated Circuit) is a serial bus for communication between peripheral components.
Originally invented by Phillips the I2C protocol is used by thousands of common chips that perform a wide range of tasks such as real time clocks, temperature and other sensors, small LCD displays and many more.
Each device is assigned a 7bit address which is used by the host (or master) to signal the device that a message written to the bus is intended for that device or that the host wants to read data from that device.
A small number of devices and hosts support 10bit addressing which expands the number of available addresses. The 10bit address format is defined here https://www.i2c-bus.org/addressing/10-bit-addressing/ and the reserved addresses are defined on this page https://www.i2c-bus.org/addressing/
Speeds range from 10Kbps to 3.4Mbps although the typical speed is either 100Kbps or 400Kbps.
This unit implements the standardized interface for I2C devices and allows reading or writing to a specific address, setting a clock rate for the communication and determining device properties.
For the purpose of this interface a device is the I2C controller attached to the local system and may be either a master or a slave. Since the protocol does not include any form of enumeration or identification the interface does not attempt to represent the devices connected to the bus,any driver written to communicate with a connected I2C device should know (or allow configuration of) the address to read and write to and the specific message format required for that device. The Intel System Management Bus (SMBus) is a variation of the I2C bus and in certain cases the two are compatible with each other.
Constants
I2C_*
I2C_NAME_PREFIX = 'I2C';
|
Name prefix for I2C Devices |
I2CSLAVE_NAME_PREFIX = 'I2CSlave';
|
Name prefix for I2C Slave Devices |
I2C_TYPE_*
I2C_TYPE_NONE = 0;
|
|
I2C_TYPE_MASTER = 1;
|
|
I2C_TYPE_SLAVE = 2;
|
|
I2C_TYPE_MAX = 2;
|
|
I2C Type Names | |
I2C_TYPE_NAMES:array[I2C_TYPE_NONE..I2C_TYPE_MAX] of String = ('I2C_TYPE_NONE', 'I2C_TYPE_MASTER', 'I2C_TYPE_SLAVE');
|
I2C_STATE_*
I2C_STATE_DISABLED = 0;
|
|
I2C_STATE_ENABLED = 1;
|
|
I2C_STATE_MAX = 1;
|
I2C_FLAG_*
I2C_FLAG_NONE = $00000000;
|
|
I2C_FLAG_SLAVE = $00000001;
|
Device is a slave not a master |
I2C_FLAG_10BIT = $00000002;
|
Device supports 10bit addressing |
I2C_FLAG_16BIT = $00000004;
|
Device supports 16bit addressing |
I2C_LOG_*
I2C_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;
|
I2C debugging messages |
I2C_LOG_LEVEL_INFO = LOG_LEVEL_INFO;
|
I2C informational messages, such as a device being attached or detached |
I2C_LOG_LEVEL_WARN = LOG_LEVEL_WARN;
|
I2C warning messages |
I2C_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;
|
I2C error messages |
I2C_LOG_LEVEL_NONE = LOG_LEVEL_NONE;
|
No I2C messages |
Type definitions
I2C properties
PI2CProperties = ^TI2CProperties;
TI2CProperties = record
Flags:LongWord;
|
Device flags (eg I2C_FLAG_SLAVE) |
MaxSize:LongWord;
|
Maximum supported data transfer size |
MinClock:LongWord;
|
Minimum supported clock rate |
MaxClock:LongWord;
|
Maximum supported clock rate |
ClockRate:LongWord;
|
Current clock rate |
SlaveAddress:Word;
|
Current slave address |
I2C enumeration callback
TI2CEnumerate = function(I2C:PI2CDevice; Data:Pointer):LongWord;
|
I2C notification callback
TI2CNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
|
I2C device start
TI2CDeviceStart = function(I2C:PI2CDevice;Rate:LongWord):LongWord;
|
I2C device stop
TI2CDeviceStop = function(I2C:PI2CDevice):LongWord;
|
I2C device read
TI2CDeviceRead = function(I2C:PI2CDevice; Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
|
I2C device write
TI2CDeviceWrite = function(I2C:PI2CDevice; Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
|
I2C device write read
TI2CDeviceWriteRead = function(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;
|
I2C device write write
TI2CDeviceWriteWrite = function(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;
|
I2C device get rate
TI2CDeviceGetRate = function(I2C:PI2CDevice):LongWord;
|
I2C device set rate
TI2CDeviceSetRate = function(I2C:PI2CDevice; Rate:LongWord):LongWord;
|
I2C device get address
TI2CDeviceGetAddress = function(I2C:PI2CDevice):Word;
|
I2C device set address
TI2CDeviceSetAddress = function(I2C:PI2CDevice; Address:Word):LongWord;
|
I2C device get properties
TI2CDeviceGetProperties = function(I2C:PI2CDevice; Properties:PI2CProperties):LongWord;
|
I2C device
PI2CDevice = ^TI2CDevice;
TI2CDevice = record
Device Properties | |
Device:TDevice;
|
The Device entry for this I2C |
I2C Properties | |
I2CId:LongWord;
|
Unique Id of this I2C in the I2C table |
I2CState:LongWord;
|
I2C state (eg I2C_STATE_ENABLED) |
DeviceStart:TI2CDeviceStart;
|
A Device specific DeviceStart method implementing the standard I2C device interface (Mandatory) |
DeviceStop:TI2CDeviceStop;
|
A Device specific DeviceStop method implementing the standard I2C device interface (Mandatory) |
DeviceRead:TI2CDeviceRead;
|
A Device specific DeviceRead method implementing the standard I2C device interface (Mandatory) |
DeviceWrite:TI2CDeviceWrite;
|
A Device specific DeviceWrite method implementing the standard I2C device interface (Mandatory) |
DeviceWriteRead:TI2CDeviceWriteRead;
|
A Device specific DeviceWriteRead method implementing the standard I2C device interface (Or nil if the default method is suitable) |
DeviceWriteWrite:TI2CDeviceWriteWrite;
|
A Device specific DeviceWriteWrite method implementing the standard I2C device interface (Or nil if the default method is suitable) |
DeviceGetRate:TI2CDeviceGetRate;
|
A Device specific DeviceGetRate method implementing the standard I2C device interface (Or nil if the default method is suitable) |
DeviceSetRate:TI2CDeviceSetRate;
|
A Device specific DeviceSetRate method implementing the standard I2C device interface (Or nil if the default method is suitable) |
DeviceGetAddress:TI2CDeviceGetAddress;
|
A Device specific DeviceGetAddress method implementing the standard I2C device interface (Or nil if the default method is suitable) |
DeviceSetAddress:TI2CDeviceSetAddress;
|
A Device specific DeviceSetAddress method implementing the standard I2C device interface (Or nil if the default method is suitable) |
DeviceGetProperties:TI2CDeviceGetProperties;
|
A Device specific DeviceGetProperties method implementing the standard I2C device interface (Or nil if the default method is suitable) |
Statistics Properties | |
ReadCount:LongWord;
|
|
WriteCount:LongWord;
|
|
ReadErrors:LongWord;
|
|
WriteErrors:LongWord;
|
|
Driver Properties | |
Lock:TMutexHandle;
|
Device lock |
Wait:TSemaphoreHandle;
|
Read/Write wait event |
ClockRate:LongWord;
|
Clock rate (Hz) |
SlaveAddress:Word;
|
Slave address |
Properties:TI2CProperties;
|
Device properties |
Internal Properties | |
Prev:PI2CDevice;
|
Previous entry in I2C table |
Next:PI2CDevice;
|
Next entry in I2C table |
Public variables
I2C logging
I2C_DEFAULT_LOG_LEVEL:LongWord = I2C_LOG_LEVEL_DEBUG;
|
Minimum level for I2C messages. Only messages with level greater than or equal to this will be printed. |
I2C_LOG_ENABLED:Boolean;
|
Function declarations
Initialization functions
procedure I2CInit;
Note | Called only during system startup |
---|
I2C functions
function I2CDeviceStart(I2C:PI2CDevice; Rate:LongWord):LongWord;
I2C | The I2C device to start |
---|---|
Rate | The clock rate to set for the device (0 to use the default rate) |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceStop(I2C:PI2CDevice):LongWord;
I2C | The I2C device to stop |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceRead(I2C:PI2CDevice; Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
I2C | The I2C device to read from |
---|---|
Address | The slave address to read from (I2C_ADDRESS_INVALID to use the current address) |
Buffer | Pointer to a buffer to receive the data |
Size | The size of the buffer |
Count | The number of bytes read on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceWrite(I2C:PI2CDevice; Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
I2C | The I2C device to write to |
---|---|
Address | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) |
Buffer | Pointer to a buffer of data to transmit |
Size | The size of the buffer |
Count | The number of bytes written on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceWriteRead(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;
I2C | The I2C device to write to and read from |
---|---|
Address | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) |
Initial | Pointer to the initial buffer to transmit |
Len | The size of the initial buffer |
Data | Pointer to a buffer to receive the data |
Size | The size of the data buffer |
Count | The number of bytes read on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
Note | Useful for devices that require a register address specified before a read (eg EEPROM devices) |
function I2CDeviceWriteWrite(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;
I2C | The I2C device to write to |
---|---|
Address | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) |
Initial | Pointer to the initial buffer to transmit |
Len | The size of the initial buffer |
Data | Pointer to a buffer of data to transmit |
Size | The size of the data buffer |
Count | The number of bytes of data written on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
Note | Useful for devices that require a register address specified before a write (eg EEPROM devices) |
function I2CDeviceGetRate(I2C:PI2CDevice):LongWord;
I2C | The I2C device to get the clock rate from |
---|---|
Return | The clock rate in Hz or 0 on failure |
function I2CDeviceSetRate(I2C:PI2CDevice; Rate:LongWord):LongWord;
I2C | The I2C device to set the clock rate for |
---|---|
Rate | The clock rate to set in Hz |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceGetAddress(I2C:PI2CDevice):Word;
I2C | The I2C device to get the slave address from |
---|---|
Return | The slave address or I2C_ADDRESS_INVALID on failure |
function I2CDeviceSetAddress(I2C:PI2CDevice; Address:Word):LongWord;
I2C | The I2C device to set the slave address for |
---|---|
Address | The slave address to set |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceProperties(I2C:PI2CDevice; Properties:PI2CProperties):LongWord; inline;
I2C | The I2C device to get properties from |
---|---|
Properties | Pointer to a TI2CProperties structure to fill in |
Return | ERROR_SUCCESS if completed or another error code on failure |
Note | Replaced by I2CDeviceGetProperties for consistency |
function I2CDeviceGetProperties(I2C:PI2CDevice; Properties:PI2CProperties):LongWord;
I2C | The I2C device to get properties from |
---|---|
Properties | Pointer to a TI2CProperties structure to fill in |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceCreate:PI2CDevice;
Return | Pointer to new I2C entry or nil if I2C could not be created |
---|
function I2CDeviceCreateEx(Size:LongWord):PI2CDevice;
Size | Size in bytes to allocate for new I2C (Including the I2C entry) |
---|---|
Return | Pointer to new I2C entry or nil if I2C could not be created |
function I2CDeviceDestroy(I2C:PI2CDevice):LongWord;
I2C | The I2C device to destroy |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceRegister(I2C:PI2CDevice):LongWord;
I2C | The I2C device to register |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceDeregister(I2C:PI2CDevice):LongWord;
I2C | The I2C device to deregister |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceFind(I2CId:LongWord):PI2CDevice;
I2CId | The ID number of the I2C device to find |
---|---|
Return | Pointer to I2C device entry or nil if not found |
function I2CDeviceFindByName(const Name:String):PI2CDevice; inline;
Name | The name of the I2C device to find (eg I2C0) |
---|---|
Return | Pointer to I2C device entry or nil if not found |
function I2CDeviceFindByDescription(const Description:String):PI2CDevice; inline;
Description | The description of the I2C to find (eg BCM2837 BSC1 Master I2C) |
---|---|
Return | Pointer to I2C device entry or nil if not found |
function I2CDeviceEnumerate(Callback:TI2CEnumerate; Data:Pointer):LongWord;
Callback | The callback function to call for each I2C device in the table |
---|---|
Data | A private data pointer to pass to callback for each I2C device in the table |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CDeviceNotification(I2C:PI2CDevice; Callback:TI2CNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Device | The I2C device to notify changes for (Optional, pass nil for all I2C devices) |
---|---|
Callback | The function to call when a notification event occurs |
Data | A private data pointer to pass to callback when a notification event occurs |
Notification | The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER) |
Flags | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) |
I2C slave functions
function I2CSlaveStart(I2C:PI2CDevice):LongWord; inline;
I2C | The I2C slave to start |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveStop(I2C:PI2CDevice):LongWord; inline;
I2C | The I2C slave to stop |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveRead(I2C:PI2CDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;
I2C | The I2C slave to read from |
---|---|
Buffer | Pointer to a buffer to receive the data |
Size | The size of the buffer |
Count | The number of bytes read on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveWrite(I2C:PI2CDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;
I2C | The I2C slave to write to |
---|---|
Buffer | Pointer to a buffer of data to transmit |
Size | The size of the buffer |
Count | The number of bytes written on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveGetAddress(I2C:PI2CDevice):Word; inline;
I2C | The I2C slave to get the address from |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveSetAddress(I2C:PI2CDevice; Address:Word):LongWord; inline;
I2C | The I2C slave to set the address for |
---|---|
Address | The address to set |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveGetProperties(I2C:PI2CDevice; Properties:PI2CProperties):LongWord; inline;
I2C | The I2C slave to get properties from |
---|---|
Properties | Pointer to a TI2CProperties structure to fill in |
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveCreate:PI2CDevice;
Return | Pointer to new I2C slave entry or nil if I2C could not be created |
---|
function I2CSlaveCreateEx(Size:LongWord):PI2CDevice;
Size | Size in bytes to allocate for new I2C (Including the I2C slave entry) |
---|---|
Return | Pointer to new I2C slave entry or nil if I2C could not be created |
function I2CSlaveDestroy(I2C:PI2CDevice):LongWord; inline;
I2C | The I2C slave to destroy |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveRegister(I2C:PI2CDevice):LongWord; inline;
I2C | The I2C slave to register |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveDeregister(I2C:PI2CDevice):LongWord; inline;
I2C | The I2C slave to deregister |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function I2CSlaveFind(I2CId:LongWord):PI2CDevice;
I2CId | The ID number of the I2C slave to find |
---|---|
Return | Pointer to I2C slave entry or nil if not found |
function I2CSlaveFindByName(const Name:String):PI2CDevice; inline;
Name | The name of the I2C slave to find (eg I2CSlave0) |
---|---|
Return | Pointer to I2C slave entry or nil if not found |
function I2CSlaveFindByDescription(const Description:String):PI2CDevice; inline;
Description | The description of the I2C slave to find (eg BCM2837 I2C Slave) |
---|---|
Return | Pointer to I2C slave entry or nil if not found |
RTL I2C functions
function SysI2CAvailable:Boolean;
Note | None documented |
---|
function SysI2CStart(Rate:LongWord):LongWord;
Rate | The clock rate to set for the device (0 to use the default rate) |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function SysI2CStop:LongWord;
Return | ERROR_SUCCESS if completed or another error code on failure |
---|
function SysI2CRead(Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Address | The slave address to read from (I2C_ADDRESS_INVALID to use the current address) |
---|---|
Buffer | Pointer to a buffer to receive the data |
Size | The size of the buffer |
Count | The number of bytes read on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
function SysI2CWrite(Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Address | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) |
---|---|
Buffer | Pointer to a buffer of data to transmit |
Size | The size of the buffer |
Count | The number of bytes written on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
function SysI2CWriteRead(Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Address | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) |
---|---|
Initial | Pointer to the initial buffer to transmit |
Len | The size of the initial buffer |
Data | Pointer to a buffer to receive the data |
Size | The size of the data buffer |
Count | The number of bytes read on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
Note | Useful for devices that require a register address specified before a read (eg EEPROM devices) |
function SysI2CWriteWrite(Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Address | The slave address to write to (I2C_ADDRESS_INVALID to use the current address) |
---|---|
Initial | Pointer to the initial buffer to transmit |
Len | The size of the initial buffer |
Data | Pointer to a buffer of data to transmit |
Size | The size of the data buffer |
Count | The number of bytes of data written on return |
Return | ERROR_SUCCESS if completed or another error code on failure |
Note | Useful for devices that require a register address specified before a write (eg EEPROM devices) |
function SysI2CGetRate:LongWord;
Return | The clock rate in Hz or 0 on failure |
---|
function SysI2CSetRate(Rate:LongWord):LongWord;
Rate | The clock rate to set in Hz |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function SysI2CGetAddress:Word;
Return | The slave address or I2C_ADDRESS_INVALID on failure |
---|
function SysI2CSetAddress(Address:Word):LongWord;
Address | The slave address to set |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
I2C helper functions
function I2CGetCount:LongWord;
Note | None documented |
---|
function I2CDeviceGetDefault:PI2CDevice;
Note | None documented |
---|
function I2CDeviceSetDefault(I2C:PI2CDevice):LongWord;
Note | None documented |
---|
function I2CDeviceCheck(I2C:PI2CDevice):PI2CDevice;
Note | None documented |
---|
function I2CDeviceIsSlave(I2C:PI2CDevice):Boolean;
Note | None documented |
---|
function I2CTypeToString(I2CType:LongWord):String;
Note | None documented |
---|
function I2CStateToString(I2CState:LongWord):String;
Note | None documented |
---|
function I2CIs7BitAddress(Address:Word):Boolean;
Note | None documented |
---|
function I2CIs10BitAddress(Address:Word):Boolean;
Note | None documented |
---|
procedure I2CLog(Level:LongWord; I2C:PI2CDevice; const AText:String);
Note | None documented |
---|
procedure I2CLogInfo(I2C:PI2CDevice; const AText:String); inline;
Note | None documented |
---|
procedure I2CLogWarn(I2C:PI2CDevice; const AText:String); inline;
Note | None documented |
---|
procedure I2CLogError(I2C:PI2CDevice; const AText:String); inline;
Note | None documented |
---|
procedure I2CLogDebug(I2C:PI2CDevice; const AText:String); inline;
Note | None documented |
---|
Return to Unit Reference