I2C: add defined behavior

pull/11032/head
Przemyslaw Stekiel 2019-10-22 13:38:44 +02:00
parent d35e8e3001
commit b8d225e860
1 changed files with 63 additions and 0 deletions

View File

@ -70,9 +70,72 @@ extern "C" {
/**
* \defgroup hal_GeneralI2C I2C Configuration Functions
*
* # Defined behavior
* * ::i2c_init initialize the I2C peripheral
* * ::i2c_init sets the default parameters for I2C peripheral
* * ::i2c_init configures the pins used by I2C
* * ::i2c_frequency configure the I2C frequency
* * ::i2c_start sends START command
* * ::i2c_read reads `length` bytes from the I2C slave specified by `address` to the `data` buffer
* * ::i2c_read reads generates a stop condition on the bus at the end of the transfer if `stop` parameter is non-zero
* * ::i2c_read reads returns the number of symbols received from the bus
* * ::i2c_write writes `length` bytes to the I2C slave specified by `address` from the `data` buffer
* * ::i2c_write generates a stop condition on the bus at the end of the transfer if `stop` parameter is non-zero
* * ::i2c_write returns zero on success, error code otherwise
* * ::i2c_reset resets the I2C peripheral
* * ::i2c_byte_read reads and return one byte from the specfied I2C slave
* * ::i2c_byte_read uses `last` parameter to inform the slave that all bytes have been read
* * ::i2c_byte_write writes one byte to the specified I2C slave
* * ::i2c_byte_write returns 0 if NAK was received, 1 if ACK was received, 2 for timeout
* * ::i2c_slave_mode enables/disables I2S slave mode
* * ::i2c_slave_receive returns: 1 - read addresses, 2 - write to all slaves, 3 write addressed, 0 - the slave has not been addressed
* * ::i2c_slave_read reads `length` bytes from the I2C master to the `data` buffer
* * ::i2c_slave_read returns non-zero if a value is available, 0 otherwise
* * ::i2c_slave_write writes `length` bytes to the I2C master from the `data` buffer
* * ::i2c_slave_write returns non-zero if a value is available, 0 otherwise
* * ::i2c_slave_address configures I2C slave address
* * ::i2c_transfer_asynch starts I2C asynchronous transfer
* * ::i2c_transfer_asynch writes `tx_length` bytes to the I2C slave specified by `address` from the `tx` buffer
* * ::i2c_transfer_asynch reads `rx_length` bytes from the I2C slave specified by `address` to the `rx` buffer
* * ::i2c_transfer_asynch generates a stop condition on the bus at the end of the transfer if `stop` parameter is non-zero
* * The callback given to ::i2c_transfer_asynch is invoked when the transfer completes
* * ::i2c_transfer_asynch specifies the logical OR of events to be registered
* * The ::i2c_transfer_asynch function may use the `DMAUsage` hint to select the appropriate async algorithm
* * ::i2c_irq_handler_asynch returns event flags if a transfer termination condition was met, otherwise returns 0.
* * ::i2c_active returns non-zero if the I2C module is active or 0 if it is not
* * ::i2c_abort_asynch aborts an on-going async transfer
*
* # Undefined behavior
* * Calling ::i2c_init multiple times on the same `i2c_t`
* * Calling any function other than ::i2c_init on a non-initialized `i2c_t`
* * Initialising the `I2C` peripheral with invalid `SDA` and `SCL` pins.
* * Passing pins that cannot be on the same peripheral
* * Passing an invalid pointer as `obj` to any function
* * Use of a `null` pointer as an argument to any function.
* * Initialising the peripheral in slave mode if slave mode is not supported
* * Operating the peripheral in slave mode without first specifying and address using ::i2c_slave_address
* * Setting an address using i2c_slave_address after initialising the peripheral in master mode
* * Setting an address to an `I2C` reserved value
* * Specifying an invalid address when calling any `read` or `write` functions
* * Setting the length of the transfer or receive buffers to larger than the buffers are
* * Passing an invalid pointer as `handler`
* * Calling ::i2c_abort_async when no transfer is currently in progress
*
*
* @{
*/
/**
* \defgroup hal_GeneralI2C_tests I2C hal tests
* The I2C HAL tests ensure driver conformance to defined behaviour.
*
* To run the I2C hal tests use the command:
*
* mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-i2c
*
*/
/** Initialize the I2C peripheral. It sets the default parameters for I2C
* peripheral, and configures its specifieds pins.
*