diff options
author | David Hoelscher <[email protected]> | 2024-01-17 07:05:38 -0600 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-17 14:05:38 +0100 |
commit | e9bd7d7ad308f9c72c86863bf9f19382c7e2d892 (patch) | |
tree | c46ce87aaa57b8f49dc0a2b56527f0bc606038ab /docs/i2c_driver.md | |
parent | 2b0965944d9065daa65cd25540cf2dd007f23eda (diff) | |
download | qmk_firmware-e9bd7d7ad308f9c72c86863bf9f19382c7e2d892.tar.gz qmk_firmware-e9bd7d7ad308f9c72c86863bf9f19382c7e2d892.zip |
I2C driver cleanup (#21273)
* remove i2c_start and i2c_stop from i2c drivers
* remove static i2c_address variable from chibios i2c driver
Diffstat (limited to 'docs/i2c_driver.md')
-rw-r--r-- | docs/i2c_driver.md | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/docs/i2c_driver.md b/docs/i2c_driver.md index 2457e8e7b9..868715a62c 100644 --- a/docs/i2c_driver.md +++ b/docs/i2c_driver.md @@ -138,23 +138,6 @@ void i2c_init(void) { --- -### `i2c_status_t i2c_start(uint8_t address, uint16_t timeout)` :id=api-i2c-start - -Start an I2C transaction. - -#### Arguments :id=api-i2c-start-arguments - - - `uint8_t address` - The 7-bit I2C address of the device (ie. without the read/write bit - this will be set automatically). - - `uint16_t timeout` - The time in milliseconds to wait for a response from the target device. - -#### Return Value :id=api-i2c-start-return - -`I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`. - ---- - ### `i2c_status_t i2c_transmit(uint8_t address, uint8_t *data, uint16_t length, uint16_t timeout)` :id=api-i2c-transmit Send multiple bytes to the selected I2C device. @@ -285,6 +268,21 @@ Reads from a register with a 16-bit address (big endian) on the I2C device. --- -### `i2c_status_t i2c_stop(void)` :id=api-i2c-stop +### `i2c_status_t i2c_ping_address(uint8_t address, uint16_t timeout)` :id=api-i2c-ping-address -Stop the current I2C transaction. +Pings the I2C bus for a specific address. + +On ChibiOS a "best effort" attempt is made by reading a single byte from register 0 at the requested address. This should generally work except for I2C devices that do not not respond to a register 0 read request, which will result in a false negative result (unsucessful response to ping attempt). + +This function is weakly defined, meaning it can be overridden if necessary for your particular use case: + +#### Arguments + + - `uint8_t address` + The 7-bit I2C address of the device (ie. without the read/write bit - this will be set automatically). + - `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`. |