stm32: i2c: Support auto speed configuration
For both v1 and v2, support automatic calculation of timing registers for 100khz and 400khz i2c modes. Based on work by Chuck in https://github.com/libopencm3/libopencm3/pull/470 for v1
This commit is contained in:
@@ -362,6 +362,16 @@ specific memorymap.h header before including this header file.*/
|
||||
|
||||
/* --- I2C function prototypes---------------------------------------------- */
|
||||
|
||||
/**
|
||||
* I2C speed modes.
|
||||
*/
|
||||
enum i2c_speeds {
|
||||
i2c_speed_sm_100k,
|
||||
i2c_speed_fm_400k,
|
||||
i2c_speed_fmp_1m,
|
||||
i2c_speed_unknown
|
||||
};
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void i2c_reset(uint32_t i2c);
|
||||
@@ -395,6 +405,7 @@ void i2c_disable_dma(uint32_t i2c);
|
||||
void i2c_set_dma_last_transfer(uint32_t i2c);
|
||||
void i2c_clear_dma_last_transfer(uint32_t i2c);
|
||||
void i2c_transfer7(uint32_t i2c, uint8_t addr, uint8_t *w, size_t wn, uint8_t *r, size_t rn);
|
||||
void i2c_set_speed(uint32_t i2c, enum i2c_speeds speed, uint32_t clock_megahz);
|
||||
|
||||
END_DECLS
|
||||
|
||||
|
||||
@@ -386,6 +386,16 @@ specific memorymap.h header before including this header file.*/
|
||||
|
||||
/* --- I2C function prototypes---------------------------------------------- */
|
||||
|
||||
/**
|
||||
* I2C speed modes.
|
||||
*/
|
||||
enum i2c_speeds {
|
||||
i2c_speed_sm_100k,
|
||||
i2c_speed_fm_400k,
|
||||
i2c_speed_fmp_1m,
|
||||
i2c_speed_unknown
|
||||
};
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void i2c_reset(uint32_t i2c);
|
||||
@@ -431,6 +441,7 @@ void i2c_disable_rxdma(uint32_t i2c);
|
||||
void i2c_enable_txdma(uint32_t i2c);
|
||||
void i2c_disable_txdma(uint32_t i2c);
|
||||
void i2c_transfer7(uint32_t i2c, uint8_t addr, uint8_t *w, size_t wn, uint8_t *r, size_t rn);
|
||||
void i2c_set_speed(uint32_t i2c, enum i2c_speeds speed, uint32_t clock_megahz);
|
||||
|
||||
END_DECLS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user