aboutsummaryrefslogtreecommitdiff
path: root/docs/i2c_driver.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/i2c_driver.md')
-rw-r--r--docs/i2c_driver.md65
1 files changed, 53 insertions, 12 deletions
diff --git a/docs/i2c_driver.md b/docs/i2c_driver.md
index 3ec34a0f8..95c588af4 100644
--- a/docs/i2c_driver.md
+++ b/docs/i2c_driver.md
@@ -62,16 +62,13 @@ Then, modify your board's `mcuconf.h` to enable the peripheral you've chosen, fo
62 62
63Configuration-wise, you'll need to set up the peripheral as per your MCU's datasheet -- the defaults match the pins for a Proton-C, i.e. STM32F303. 63Configuration-wise, you'll need to set up the peripheral as per your MCU's datasheet -- the defaults match the pins for a Proton-C, i.e. STM32F303.
64 64
65|`config.h` Overrride |Description |Default| 65|`config.h` Overrride |Description |Default|
66|------------------------|-------------------------------------------------------------------------------------------|-------| 66|------------------------|--------------------------------------------------------------|-------|
67|`I2C_DRIVER` |I2C peripheral to use - I2C1 -> `I2CD1`, I2C2 -> `I2CD2` etc. |`I2CD1`| 67|`I2C_DRIVER` |I2C peripheral to use - I2C1 -> `I2CD1`, I2C2 -> `I2CD2` etc. |`I2CD1`|
68|`I2C1_BANK` (deprecated)|The bank of pins (`GPIOA`, `GPIOB`, `GPIOC`), superseded by `I2C1_SCL_BANK`/`I2C1_SDA_BANK`|`GPIOB`| 68|`I2C1_SCL_PIN` |The pin definition for SCL |`B6` |
69|`I2C1_SCL_BANK` |The bank of pins (`GPIOA`, `GPIOB`, `GPIOC`) to use for SCL |`GPIOB`| 69|`I2C1_SCL_PAL_MODE` |The alternate function mode for SCL |`4` |
70|`I2C1_SCL` |The pin number for SCL (0-15) |`6` | 70|`I2C1_SDA_PIN` |The pin definition for SDA |`B7` |
71|`I2C1_SCL_PAL_MODE` |The alternate function mode for SCL |`4` | 71|`I2C1_SDA_PAL_MODE` |The alternate function mode for SDA |`4` |
72|`I2C1_SDA_BANK` |The bank of pins (`GPIOA`, `GPIOB`, `GPIOC`) to use for SDA |`GPIOB`|
73|`I2C1_SDA` |The pin number for SDA (0-15) |`7` |
74|`I2C1_SDA_PAL_MODE` |The alternate function mode for SDA |`4` |
75 72
76The following configuration values depend on the specific MCU in use. 73The following configuration values depend on the specific MCU in use.
77 74
@@ -190,7 +187,7 @@ Receive multiple bytes from the selected SPI device.
190 187
191### `i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` 188### `i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)`
192 189
193Writes to a register on the I2C device. 190Writes to a register with an 8-bit address on the I2C device.
194 191
195#### Arguments 192#### Arguments
196 193
@@ -211,9 +208,32 @@ Writes to a register on the I2C device.
211 208
212--- 209---
213 210
211### `i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)`
212
213Writes to a register with a 16-bit address (big endian) on the I2C device.
214
215#### Arguments
216
217 - `uint8_t devaddr`
218 The 7-bit I2C address of the device.
219 - `uint16_t regaddr`
220 The register address to write to.
221 - `uint8_t *data`
222 A pointer to the data to transmit.
223 - `uint16_t length`
224 The number of bytes to write. Take care not to overrun the length of `data`.
225 - `uint16_t timeout`
226 The time in milliseconds to wait for a response from the target device.
227
228#### Return Value
229
230`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
231
232---
233
214### `i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` 234### `i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)`
215 235
216Reads from a register on the I2C device. 236Reads from a register with an 8-bit address on the I2C device.
217 237
218#### Arguments 238#### Arguments
219 239
@@ -232,6 +252,27 @@ Reads from a register on the I2C device.
232 252
233--- 253---
234 254
255### `i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)`
256
257Reads from a register with a 16-bit address (big endian) on the I2C device.
258
259#### Arguments
260
261 - `uint8_t devaddr`
262 The 7-bit I2C address of the device.
263 - `uint16_t regaddr`
264 The register address to read from.
265 - `uint16_t length`
266 The number of bytes to read. Take care not to overrun the length of `data`.
267 - `uint16_t timeout`
268 The time in milliseconds to wait for a response from the target device.
269
270#### Return Value
271
272`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`.
273
274---
275
235### `i2c_status_t i2c_stop(void)` 276### `i2c_status_t i2c_stop(void)`
236 277
237Stop the current I2C transaction. 278Stop the current I2C transaction.