diff options
author | David Hoelscher <infinityis@users.noreply.github.com> | 2024-01-17 07:05:38 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-17 14:05:38 +0100 |
commit | e9bd7d7ad308f9c72c86863bf9f19382c7e2d892 (patch) | |
tree | c46ce87aaa57b8f49dc0a2b56527f0bc606038ab /docs | |
parent | 2b0965944d9065daa65cd25540cf2dd007f23eda (diff) |
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')
-rw-r--r-- | docs/i2c_driver.md | 36 | ||||
-rw-r--r-- | docs/ja/i2c_driver.md | 3 |
2 files changed, 18 insertions, 21 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`. diff --git a/docs/ja/i2c_driver.md b/docs/ja/i2c_driver.md index 1d8f70e163..92c4185370 100644 --- a/docs/ja/i2c_driver.md +++ b/docs/ja/i2c_driver.md @@ -23,12 +23,11 @@ I2C アドレスと他の技術詳細について、さらなる情報を得る | 関数 | 説明 | |-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `void i2c_init(void);` | I2C ドライバを初期化します。他のあらゆるトランザクションを開始する前に、この関数を一度だけ呼ぶ必要があります。 | -| `i2c_status_t i2c_start(uint8_t address, uint16_t timeout);` | I2C トランザクションを開始します。アドレスは方向ビットのない7ビットスレーブアドレスです。 | | `i2c_status_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);` | I2C 経由でデータを送信します。アドレスは方向ビットのない7ビットスレーブアドレスです。トランザクションのステータスを返します。 | | `i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);` | I2C 経由でデータを受信します。アドレスは方向ビットのない7ビットスレーブアドレスです。 `length` で指定した長さのバイト列を `data` に保存し、トランザクションのステータスを返します。 | | `i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);` | `i2c_transmit` と同様ですが、 `regaddr` でスレーブのデータ書き込み先のレジスタを指定します。 | | `i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);` | `i2c_receive` と同様ですが、 `regaddr` でスレーブのデータ読み込み先のレジスタを指定します。 | -| `i2c_status_t i2c_stop(void);` | I2C トランザクションを終了します。 | +| `i2c_status_t i2c_ping_address(uint8_t address, uint16_t timeout);` | I2C アドレスをテストします。アドレスは方向ビットのない7ビットスレーブアドレスです。 | ### 関数の戻り値 :id=function-return |