stm32/i2cslave: Pass I2C instance to callbacks to support multi I2Cs. · csamuelson/circuitpython@137df81 · GitHub
Skip to content

Commit 137df81

Browse files
committed
stm32/i2cslave: Pass I2C instance to callbacks to support multi I2Cs.
By passing through the I2C instance to the application callbacks, the application can implement multiple I2C slave devices on different peripherals (eg I2C1 and I2C2). This commit also adds a proper rw argument to i2c_slave_process_addr_match for F7/H7/WB MCUs, and enables the i2c_slave_process_tx_end callback. Mboot is also updated for these changes. Signed-off-by: Damien George <damien@micropython.org>
1 parent 6475cdb commit 137df81

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

ports/stm32/i2cslave.c

Lines changed: 9 additions & 9 deletions

ports/stm32/i2cslave.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ static inline void i2c_slave_shutdown(i2c_slave_t *i2c, int irqn) {
6767
void i2c_slave_ev_irq_handler(i2c_slave_t *i2c);
6868

6969
// These should be provided externally
70-
int i2c_slave_process_addr_match(int rw);
71-
int i2c_slave_process_rx_byte(uint8_t val);
72-
void i2c_slave_process_rx_end(void);
73-
uint8_t i2c_slave_process_tx_byte(void);
70+
int i2c_slave_process_addr_match(i2c_slave_t *i2c, int rw);
71+
int i2c_slave_process_rx_byte(i2c_slave_t *i2c, uint8_t val);
72+
void i2c_slave_process_rx_end(i2c_slave_t *i2c);
73+
uint8_t i2c_slave_process_tx_byte(i2c_slave_t *i2c);
74+
void i2c_slave_process_tx_end(i2c_slave_t *i2c);
7475

7576
#endif // MICROPY_INCLUDED_STM32_I2CSLAVE_H

ports/stm32/mboot/main.c

Lines changed: 7 additions & 4 deletions

0 commit comments

Comments
 (0)