Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/fw/drivers/touch/cst816/cst816.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ static bool cst816_fw_update(void) {
}

static void cst816_hw_reset(void) {
// Toggling the reset pin must not race an in-flight I2C transfer on another task: a chip hit by reset mid-byte stops ACKing and corrupts the transfer (touch_sensor_set_enabled is reachable synchronously from arbitrary tasks while the system task services IRQ-driven reads). Take the same per-transfer lock prv_read_data/prv_write_data use. No caller holds it already -- the only lock-takers are those two, neither of which resets -- so this cannot self-deadlock.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change makes sense, could all this verbose comment be removed, details kept in the commit?

mutex_lock(s_i2c_lock);
#ifdef RESET_PIN_CTRLBY_NPM1300
NPM1300_OPS.gpio_set(Npm1300_Gpio2, 0);
psleep(CST816_RESET_CYCLE_TIME);
Expand All @@ -234,6 +236,7 @@ static void cst816_hw_reset(void) {
gpio_output_set(&CST816->reset, false);
psleep(CST816_POR_DELAY_TIME);
#endif
mutex_unlock(s_i2c_lock);
}

void touch_sensor_init(void) {
Expand Down