renesas / fsp

Flexible Software Package (FSP) for Renesas RA MCU Family
https://renesas.github.io/fsp/
Other
182 stars 81 forks source link

Allow custom clock speeds for I2C #282

Closed alranel closed 1 week ago

alranel commented 11 months ago

Only three speed options are available:

/** Communication speed options */
typedef enum e_i2c_master_rate
{
    I2C_MASTER_RATE_STANDARD = 100000, ///< 100 kHz
    I2C_MASTER_RATE_FAST     = 400000, ///< 400 kHz
    I2C_MASTER_RATE_FASTPLUS = 1000000 ///< 1 MHz
} i2c_master_rate_t;

However, the I2C standard suggest you should allow the best match possible to the requested clock:

The I2C clock can be 0 Hz to 100 kHz, 0 Hz to 400 kHz, 0 Hz to 1 MHz and 0 Hz to 3.4 MHz, depending on the mode. This means that an I2C-bus running at less than 10 kHz is not SMBus compliant since the SMBus devices may time-out.

(This report was posted in the Arduino UNO R4 repository, since other Arduino boards allow users to set any clock within a given range).

renesas-brandon-hussey commented 5 months ago

This is being internally tracked using FSPRA-1487.