-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
Describe the bug
When using the i2c_sam0 driver, SCL remains low indefinitely after a bus transaction. SCL should be released when a bus transaction completes. LOWTOUT is intended to guard against situations where SCL is held low too long.
The i2c_sam0 driver enables LOWTOUT (SCL low timeout). However, the driver does not initialize GCLK_SERCOM_SLOW which is required to enable the timeout (see 28.5.3 and 28.6.3.1).
To Reproduce
Steps to reproduce the behavior:
- use blinky example
- Add opt3001 i2c peripheral (actually, any i2c peripheral)
- make
- observe SCL
- See error
Expected behavior
SCL will be released after the LOWTOUT timeout.
I applied the following patch to i2c_sam0_initialize() to test the expected behaviour:
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID_SERCOMX_SLOW | GCLK_CLKCTRL_GEN_GCLK2 |
GCLK_CLKCTRL_CLKEN;
Impact
When SCL is held low, the pull up resistors on the bus consume power on the order of 500uA or more (depending on the value of the pull up resistor). This bug rules out any low power applications that require the i2c driver.