softi2c_master: improve pin configuration
This commit is contained in:
parent
ba1752a409
commit
e7d3a86e45
|
@ -83,11 +83,11 @@ bool softi2c_master_setup(uint16_t freq_khz)
|
|||
|
||||
// switch pins to open drain
|
||||
SCL_PORT->ODR.reg |= SCL_PIN; // ensure clock is high
|
||||
SCL_PORT->DDR.reg |= SCL_PIN; // switch pin to output
|
||||
SCL_PORT->CR1.reg &= ~SCL_PIN; // use in open-drain mode
|
||||
SCL_PORT->DDR.reg |= SCL_PIN; // switch pin to output
|
||||
SDA_PORT->ODR.reg |= SDA_PIN; // ensure data is high
|
||||
SDA_PORT->DDR.reg |= SDA_PIN; // switch pin to output
|
||||
SDA_PORT->CR1.reg &= ~SDA_PIN; // use in open-drain mode
|
||||
SDA_PORT->DDR.reg |= SDA_PIN; // switch pin to output
|
||||
|
||||
I2C_delay(); // give time to get high
|
||||
return (read_SCL() && read_SDA()); // line is ready when the two lines are high
|
||||
|
|
Loading…
Reference in New Issue