@@ -89,7 +89,7 @@ List of drivers and examples currently using the I2C interface:
89
89
90
90
- ** Add** ` i2c_set_clock_stretching ` function to the API.
91
91
92
- Enables or disables clock stretching for the I2C peripheral when in slave mode
92
+ Enables or disables clock stretching for the I2C peripheral when in slave mode.
93
93
94
94
- ** Add** ` i2c_timeout ` function to the API.
95
95
@@ -109,7 +109,7 @@ List of drivers and examples currently using the I2C interface:
109
109
110
110
- ** Add** a return value to the ` i2c_frequency ` which indicates the frequency that the peripheral was configured to.
111
111
112
- The frequency requested may not be supported by the I2C peripheral, the peripheral will select the nearest supported frequency instead (but not greater then requested), this selected frequency will be returned to inform the caller of the difference.
112
+ The frequency requested may not be supported by the I2C peripheral, the peripheral will select the nearest supported frequency instead (but not greater then requested), the selected frequency will be returned to inform the caller of the difference.
113
113
114
114
- ** Change** the ` stop ` parameter for the transfer function from an ` int ` value to a ` bool ` value.
115
115
@@ -149,7 +149,7 @@ The main changes involve removing the slave specific read/write functions and ro
149
149
150
150
- ** Remove** the ` i2c_slave_mode ` function, add an ` is_slave ` parameter to the ` i2c_init ` function.
151
151
152
- The decision to initialise the peripheral in master or slave mode should be decided at construction time. This simplifies the API as it removes the need for two separate functions to initialise slave mode ` i2c_slave_mode ` and ` i2c_slave_address ` .
152
+ The decision to initialize the peripheral in master or slave mode should be decided at construction time. This simplifies the API as it removes the need for two separate functions to initialize slave mode ` i2c_slave_mode ` and ` i2c_slave_address ` .
153
153
154
154
- ** Remove** the I2C slave specific transfer functions: ` i2c_slave_read ` , ` i2c_slave_write ` .
155
155
@@ -175,15 +175,15 @@ The main changes involve removing the slave specific read/write functions and ro
175
175
176
176
- ** Remove** the ` i2c_irq_handler_asynch ` function from the API.
177
177
178
- The event is now passed as an argument to the callback this method is no longer required.
178
+ The event is now passed as an argument to the callback, this method is no longer required.
179
179
180
180
- ** Remove** the ` event ` parameter from the ` i2c_transfer_async ` function.
181
181
182
- The callback will now be invoked on any event with the event as an argument.
182
+ The callback is now invoked on any event with the event as an argument.
183
183
184
184
- ** Remove** the ` i2c_active ` function from the API.
185
185
186
- The async callback is now always invoked on async operation termination (unless cancelled ), this status can be tracked from driver layer without any HAL request.
186
+ The async callback is now always invoked on async operation termination (unless canceled ), this status can be tracked from driver layer without any HAL request.
187
187
188
188
### The new API
189
189
@@ -219,13 +219,13 @@ typedef struct {
219
219
*/
220
220
void i2c_get_capabilities (i2c_capabilities_t * capabilities);
221
221
222
- /** Initialize the I2C peripheral. It sets the default parameters for I2C
223
- * peripheral, and configures its pins.
222
+ /** Initialize the I2C peripheral. It sets the default parameters for the I2C
223
+ * peripheral and configures its pins.
224
224
*
225
225
* @param obj The I2C object
226
226
* @param sda The sda pin
227
227
* @param scl The scl pin
228
- * @param is_slave Choose whether the peripheral is initialised as master or
228
+ * @param is_slave Choose whether the peripheral is initialized as master or
229
229
* slave.
230
230
* /
231
231
void i2c_init(i2c_t * obj, PinName sda, PinName scl, bool is_slave);
@@ -236,13 +236,13 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl, bool is_slave);
236
236
* /
237
237
void i2c_free(i2c_t * obj);
238
238
239
- /** Configure the frequency in Hz the I2C peripheral should operate at .
239
+ /** Configure the frequency in Hz at which I2C peripheral should operate.
240
240
*
241
241
* @param obj The I2C object
242
242
* @param frequency Frequency in Hz
243
243
*
244
- * @returns The actual frequency that the peripheral will be generating to
245
- * allow a user adjust its strategy in case the target cannot be
244
+ * @returns The actual frequency that the peripheral generates to
245
+ * allow a user to adjust its strategy in case the target cannot be
246
246
* reached.
247
247
* /
248
248
uint32_t i2c_frequency(i2c_t * obj, uint32_t frequency);
@@ -260,10 +260,10 @@ void i2c_set_clock_stretching(i2c_t *obj, bool enabled);
260
260
* @param obj The I2C object
261
261
* @param timeout Transmission timeout in microseconds.
262
262
*
263
- * @note If no timeout is set the default timeout is used.
263
+ * @note If no timeout is set, the default timeout is used.
264
264
* Default timeout value is based on I2C frequency.
265
265
* Byte timeout is computed as triple amount of time it would take
266
- * to send 10bit over I2C and is expressed by the formula:
266
+ * to send 10 bit over I2C and is expressed by the formula:
267
267
* byte_timeout = 3 * (1/frequency * 10 * 1000000)
268
268
* /
269
269
void i2c_timeout(i2c_t * obj, uint32_t timeout);
@@ -282,85 +282,85 @@ void i2c_stop(i2c_t *obj);
282
282
283
283
/** Blocking sending data
284
284
*
285
- * This function transmits data, when the peripheral is configured as Master to
286
- * the selected slave, and when configured as Slave transmits data to the
285
+ * This function transmits data when the peripheral is configured as Master to
286
+ * the selected slave and when configured as Slave transmits data to the
287
287
* Master.
288
288
*
289
- * This function is blocking, it will return when the transfer is complete or a
289
+ * This function is blocking; it returns when the transfer is complete or a
290
290
* timeout event is triggered. The number of bytes transmitted is returned by
291
291
* the function after the operation is completed. Transmit operation cannot be
292
- * cancelled or aborted.
292
+ * canceled or aborted.
293
293
*
294
- * The data buffer must stay allocated during the duration of the transfer and
294
+ * The data buffer must stay allocated during the duration of the transfer, and
295
295
* the contents must not be modified. The value of the specified ` address ` is
296
- * ignored when configured in slave mode, in master mode it contains the
296
+ * ignored when configured in slave mode. In master mode, it contains the
297
297
* address of the target peripheral. This is a 7-bit value unless 10-bit
298
- * addressing is configured and supported by the target.
298
+ * addressing is configured, and the target supports it .
299
299
*
300
300
* When in master mode the operation consists of:
301
- * - Address the slave as a Master transmitter.
302
- * - Transmit data to the addressed slave.
303
- * - Generate a STOP condition if the specified ` stop ` field is true.
301
+ * - Addressing the slave as a Master transmitter.
302
+ * - Transmitting data to the addressed slave.
303
+ * - Generating a STOP condition if the specified ` stop ` field is true.
304
304
*
305
305
* @param obj The I2C object
306
306
* @param address 7/10-bit address (last bit is 0)
307
307
* @param data The buffer for sending
308
308
* @param length Number of bytes to write
309
- * @param stop If true, stop will be generated after the transfer is done
309
+ * @param stop If true, stop is generated after the transfer is done
310
310
*
311
311
* @note If the current platform supports multimaster operation the peripheral
312
- * will perform arbitration automatically when detecting collisions and
313
- * complete the transfer or return I2C_ERROR_ARBITRATION_LOST
314
- * when loses arbitration.
312
+ * performs arbitration automatically when detecting collisions and
313
+ * completes the transfer or returns I2C_ERROR_ARBITRATION_LOST
314
+ * when it loses arbitration.
315
315
*
316
316
* Additional time for arbitration or clock stretching should by count
317
317
* by setting appropriate timeout value.
318
318
*
319
- * When no transmision timeout was set by the user the default timeout value will
320
- * be used. It will count one additional byte for addressing stage:
319
+ * When no transmission timeout is set by the user the default timeout value is
320
+ * used. It counts one additional byte for addressing stage:
321
321
* default_timeout = (length + 1) * byte_timeout.
322
322
*
323
323
* @return
324
- * zero or non-zero - Number of written bytes
324
+ * zero or nonzero - Number of written bytes
325
325
* negative - I2C_ERROR_XXX status
326
326
* /
327
327
int32_t i2c_write(i2c_t * obj, uint16_t address, const uint8_t * data, uint32_t length, bool stop);
328
328
329
329
/** Blocking reading data
330
330
*
331
- * This function receives data, when the peripheral is configured as Master
332
- * from the selected slave, and when configured as Slave from the Master.
331
+ * This function receives data when the peripheral is configured as Master
332
+ * from the selected slave and when configured as Slave from the Master.
333
333
*
334
- * This function is blocking, it will return when the transfer is complete or a
334
+ * This function is blocking; it returns when the transfer is complete or a
335
335
* timeout event is triggered. The number of bytes received is returned by
336
336
* the function after the operation is completed. Receive operation cannot be
337
- * cancelled or aborted.
337
+ * canceled or aborted.
338
338
*
339
- * When in master mode the operation consists of:
340
- * - Address the slave as a Master receiver.
341
- * - Receive data from the addressed slave.
342
- * - Generate a STOP condition if the specified ` stop ` field is true.
339
+ * When in master mode, the operation consists of:
340
+ * - Addressing the slave as a Master receiver.
341
+ * - Receiving data from the addressed slave.
342
+ * - Generating a STOP condition if the specified ` stop ` field is true.
343
343
*
344
344
* @param obj The I2C object
345
345
* @param address 7/10-bit address (last bit is 1)
346
346
* @param data The buffer for receiving
347
347
* @param length Number of bytes to read
348
- * @param stop If true, stop will be generated after the transfer is done
348
+ * @param stop If true, stop is generated after the transfer is done
349
349
*
350
350
* @note If the current platform supports multimaster operation the peripheral
351
- * will perform arbitration automatically when detecting collisions and
352
- * complete the transfer or return I2C_ERROR_ARBITRATION_LOST
353
- * when loses arbitration.
351
+ * performs arbitration automatically when detecting collisions and
352
+ * completes the transfer or returns I2C_ERROR_ARBITRATION_LOST
353
+ * when it loses arbitration.
354
354
*
355
355
* Additional time for arbitration or clock stretching should by count
356
356
* by setting appropriate timeout value.
357
357
*
358
- * When no transmision timeout was set by the user the default timeout value will
359
- * be used. It will count one additional byte for addressing stage:
358
+ * When no transmission timeout is set by the user the default timeout value is
359
+ * used. It counts one additional byte for addressing stage:
360
360
* default_timeout = (length + 1) * byte_timeout.
361
361
*
362
362
* @return
363
- * zero or non-zero - Number of written bytes
363
+ * zero or nonzero - Number of written bytes
364
364
* negative - I2C_ERROR_XXX status
365
365
* /
366
366
int32_t i2c_read(i2c_t * obj, uint16_t address, uint8_t * data, uint32_t length, bool stop);
@@ -389,7 +389,7 @@ i2c_slave_status_t i2c_slave_status(i2c_t *obj);
389
389
* @note This function does nothing when configured in master mode.
390
390
*
391
391
* @param obj The I2C object
392
- * @param address The address to be set - 7bit or 10bit
392
+ * @param address The address to be set - 7 bit or 10 bit
393
393
* /
394
394
void i2c_slave_address(i2c_t * obj, uint16_t address);
395
395
@@ -418,8 +418,8 @@ typedef void (*i2c_async_handler_f)(i2c_t *obj, i2c_async_event_t *event, void *
418
418
* @param tx_length The number of bytes to transmit
419
419
* @param rx The receive buffer
420
420
* @param rx_length The number of bytes to receive
421
- * @param address The address to be set - 7bit or 10bit
422
- * @param stop If true, stop will be generated after the transfer is done
421
+ * @param address The address to be set - 7 bit or 10 bit
422
+ * @param stop If true, stop is generated after the transfer is done
423
423
* @param handler The I2C IRQ handler to be set
424
424
* @param ctx The context pointer
425
425
* @return true if the transfer was successfully scheduled, false otherwise
@@ -440,42 +440,42 @@ void i2c_abort_async(i2c_t *obj);
440
440
441
441
## Behaviours
442
442
443
- ### Defined behaviours
443
+ ### Defined behaviour
444
444
445
445
- `i2c_init`:
446
- - Initialises the peripheral pins specified in the input parameters.
447
- - Initialises the peripheral in master mode if `is_slave` is false.
448
- - Initialises the peripheral in slave mode if `is_slave` is true and `supports_slave_mode` is true.
446
+ - Initializes the peripheral pins specified in the input parameters.
447
+ - Initializes the peripheral in master mode if `is_slave` is false.
448
+ - Initializes the peripheral in slave mode if `is_slave` is true and `supports_slave_mode` is true.
449
449
- `i2c_free`:
450
- - Resets the pins used to initialise the peripheral to their default state.
450
+ - Resets the pins used to initialize the peripheral to their default state.
451
451
- Disables the peripheral clock.
452
452
- `i2c_get_capabilities`:
453
- - Fills the contents of the `i2c_capabilities_t` parameter
453
+ - Fills the contents of the `i2c_capabilities_t` parameter.
454
454
- `i2c_frequency`:
455
- - Returns the actual frequency that will be used.
455
+ - Returns the actual frequency used.
456
456
- Sets the frequency to use for the transfer.
457
457
- Must leave all other configuration unchanged.
458
458
- `i2c_set_clock_stretching`:
459
459
- Enables or disables clock stretching for the peripheral when in slave mode.
460
460
- Does nothing when called in master mode.
461
461
- `i2c_timeout`:
462
- - Sets the transmision timeout to use for the following blocking transfers.
463
- - If the timeout is not set the default timeout is used.
464
- - Default timeout value is based on I2C frequency. Is computed as triple amount of time it would take to send data over I2C
462
+ - Sets the transmission timeout to use for the following blocking transfers.
463
+ - If the timeout is not set, the default timeout is used.
464
+ - The default timeout value is based on I2C frequency. It's computed as triple the amount of time it would take to send data over I2C
465
465
- `i2c_write`:
466
466
- Writes `length` number of symbols to the bus.
467
467
- Returns the number of symbols sent to the bus.
468
- - Returns an error code if transfer fails.
468
+ - Returns an error code if the transfer fails.
469
469
- Generates a stop condition on the bus at the end of the transfer if `stop` parameter is true.
470
470
- Handles transfer collisions and loss of arbitration if the platform supports multimaster in hardware.
471
- - The transfer will timeout and return `I2C_ERROR_TIMEOUT ` if the transfer takes longer than the configured timeout duration.
471
+ - The transfer times out and returns `I2C_ERROR_TIMEOUT ` if the transfer takes longer than the configured timeout duration.
472
472
- `i2c_read`:
473
473
- Reads `length` symbols from the bus.
474
474
- Returns the number of symbols received from the bus.
475
- - Returns an error code if transfer fails.
475
+ - Returns an error code if the transfer fails.
476
476
- Generates a stop condition on the bus at the end of the transfer if `stop` parameter is true.
477
477
- Handles transfer collisions and loss of arbitration if the platform supports multimaster in hardware.
478
- - The transfer will timeout and return `I2C_ERROR_TIMEOUT ` if the transfer takes longer than the configured timeout duration.
478
+ - The transfer timeouts and returns `I2C_ERROR_TIMEOUT ` if the transfer takes longer than the configured timeout duration.
479
479
- `i2c_start`:
480
480
- Generates I2C START condition on the bus in master mode.
481
481
- Does nothing if called when the peripheral is configured in slave mode.
@@ -497,16 +497,16 @@ void i2c_abort_async(i2c_t *obj);
497
497
- May handle transfer collisions and loss of arbitration if the platform supports multimaster in hardware and enabled in API.
498
498
- `i2c_async_event_t` must be filled with the number of symbols sent to the bus during transfer.
499
499
- `i2c_abort_async`:
500
- - Aborts any on-going async transfers.
500
+ - Aborts any ongoing async transfers.
501
501
502
- ### Undefined behaviours
502
+ ### Undefined behaviour
503
503
504
504
- Use of a `null` pointer as an argument to any function.
505
505
- Calling any `I2C` function before calling `i2c_init` or after calling `i2c_free`.
506
- - Initialising the `I2C` peripheral with invalid `SDA` and `SCL` pins.
507
- - Initialising the peripheral in slave mode if slave mode is not supported, indicated by `i2c_get_capabilities`.
508
- - Operating the peripheral in slave mode without first specifying and address using `i2c_slave_address`
509
- - Setting an address using `i2c_slave_address` after initialising the peripheral in master mode.
506
+ - Initializing the `I2C` peripheral with invalid `SDA` and `SCL` pins.
507
+ - Initializing the peripheral in slave mode if slave mode is not supported, indicated by `i2c_get_capabilities`.
508
+ - Operating the peripheral in slave mode without first specifying an address using `i2c_slave_address`
509
+ - Setting an address using `i2c_slave_address` after initializing the peripheral in master mode.
510
510
- Setting an address to an `I2C` reserved value.
511
511
- Setting an address larger than the 7-bit supported maximum if 10-bit addressing is not supported.
512
512
- Setting an address larger than the 10-bit supported maximum.
0 commit comments