Port the buttons module to the new hwlock API introduced in commit b46a9e7a ("Merge 'Port hardware locks to new mutex API'").
Additionally, fix issue #189 (closed). I can't tell for sure why this bug was triggered from USB mode but fixing it also fixes the USB issue. The bug in question is an unguarded I2C transaction (from the commit message):
The call to
epic_buttons_read()performs transactions on the I2C bus but is not guarded by locking the I2C hwlock. This leads to strange issues like USB mode deadlocking when writing large files.
Widen the hwlock I2C section to encompass the
MAX77650_getDebounceStatusnEN0()call as well. This fixes #189 (closed).
(We severely need to move the lock to the bus level ...)