-
Notifications
You must be signed in to change notification settings - Fork 116
do hw reset when touch IC cannot communicate with MCU #999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ static PebbleMutex *s_i2c_lock; | |
|
|
||
| static void prv_exti_cb(bool *should_context_switch); | ||
| static void cst816_hw_reset(void); | ||
| void touch_sensor_set_enabled(bool enabled); | ||
|
|
||
| static bool prv_read_data(uint16_t register_address, uint8_t *result, uint16_t size, bool is_work_mode) { | ||
| mutex_lock(s_i2c_lock); | ||
|
|
@@ -251,14 +252,17 @@ void touch_sensor_init(void) { | |
| static void prv_process_pending_messages(void* context) { | ||
| s_callback_scheduled = false; | ||
|
|
||
| const uint64_t current_time_ms = ticks_to_milliseconds(rtc_get_ticks()); | ||
| uint8_t data[CST816_TOUCH_DATA_SIZE] = {0}; | ||
| bool rv = prv_read_data(CST816_TOUCH_DATA_REG, data, CST816_TOUCH_DATA_SIZE, 1); | ||
| if (!rv) { | ||
| PBL_LOG_ERR("Failed to read touch data, dropping event"); | ||
| PBL_LOG_ERR("Failed to read touch data, trying to recover"); | ||
| touch_handle_update(0, TouchState_FingerUp, NULL, 0, current_time_ms); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if there was no down event before?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when it happens on touch down status, the upper layer may not know the hardware been reset with default FingerUp status, so force report the FingerUp event to upper layer. |
||
| exti_disable(CST816->int_exti); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When do hw reset, don't know if the INT pin is stable or not, so force disable interrupt during reset cycle. |
||
| touch_sensor_set_enabled(true); | ||
| return; | ||
| } | ||
|
|
||
| const uint64_t current_time_ms = ticks_to_milliseconds(rtc_get_ticks()); | ||
| uint8_t press = data[0] & 0x0F; | ||
| GPoint point = { | ||
| .x = (((uint16_t)(data[1] & 0x0F)) << 8) | data[2], | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not be needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function is called before implementation, so declare it here.