summaryrefslogtreecommitdiff
path: root/docs/i2c_driver.md
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-10-07 10:29:35 +1100
committerGitHub <noreply@github.com>2021-10-07 10:29:35 +1100
commitbc1f5ef38172bc77a802fb779e5da60f800c231b (patch)
tree104a22b67c21e08c33a9d2ddedf04abc9710d5e4 /docs/i2c_driver.md
parent875e44faac31e5985e764c7b117ad4938e2e6027 (diff)
downloadqmk_firmware-bc1f5ef38172bc77a802fb779e5da60f800c231b.tar.gz
qmk_firmware-bc1f5ef38172bc77a802fb779e5da60f800c231b.zip
i2c_master: Add support for reading/writing to 16-bit registers (#14289)
Diffstat (limited to 'docs/i2c_driver.md')
-rw-r--r--docs/i2c_driver.md48
1 files changed, 46 insertions, 2 deletions
diff --git a/docs/i2c_driver.md b/docs/i2c_driver.md
index 9017b44ed7..95c588af44 100644
--- a/docs/i2c_driver.md
+++ b/docs/i2c_driver.md
@@ -187,7 +187,7 @@ Receive multiple bytes from the selected SPI device.
### `i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)`
-Writes to a register on the I2C device.
+Writes to a register with an 8-bit address on the I2C device.
#### Arguments
@@ -208,9 +208,32 @@ Writes to a register on the I2C device.
---
+### `i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)`
+
+Writes to a register with a 16-bit address (big endian) on the I2C device.
+
+#### Arguments
+
+ - `uint8_t devaddr`
+ The 7-bit I2C address of the device.
+ - `uint16_t regaddr`
+ The register address to write to.
+ - `uint8_t *data`
+ A pointer to the data to transmit.
+ - `uint16_t length`
+ The number of bytes to write. Take care not to overrun the length of `data`.
+ - `uint16_t timeout`
+ The time in milliseconds to wait for a response from the target device.
+
+#### Return Value
+
+`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
+
+---
+
### `i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)`
-Reads from a register on the I2C device.
+Reads from a register with an 8-bit address on the I2C device.
#### Arguments
@@ -229,6 +252,27 @@ Reads from a register on the I2C device.
---
+### `i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)`
+
+Reads from a register with a 16-bit address (big endian) on the I2C device.
+
+#### Arguments
+
+ - `uint8_t devaddr`
+ The 7-bit I2C address of the device.
+ - `uint16_t regaddr`
+ The register address to read from.
+ - `uint16_t length`
+ The number of bytes to read. Take care not to overrun the length of `data`.
+ - `uint16_t timeout`
+ The time in milliseconds to wait for a response from the target device.
+
+#### Return Value
+
+`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
+
+---
+
### `i2c_status_t i2c_stop(void)`
Stop the current I2C transaction.