From 8cf276b99211cacd220d1be565e056389c2c07c7 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Sat, 30 Mar 2024 19:50:44 +0000 Subject: [PATCH] inky73: Add busy wait timeout. Add a timeout to fix Inky 7.3" hanging on batteries. Basically assumes the update has finished if it takes > 45s, and allows a subsequent attempt rather than hanging indefinitely. Raised, texted and fixed by w3stbam: https://github.com/pimoroni/pimoroni-pico/pull/900 Rewritten as mentioned in the PR. --- drivers/inky73/inky73.cpp | 5 +++-- drivers/inky73/inky73.hpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/inky73/inky73.cpp b/drivers/inky73/inky73.cpp index be54affa..449bf9ad 100644 --- a/drivers/inky73/inky73.cpp +++ b/drivers/inky73/inky73.cpp @@ -47,8 +47,9 @@ namespace pimoroni { return !(sr.read() & 128); } - void Inky73::busy_wait() { - while(is_busy()) { + void Inky73::busy_wait(uint timeout_ms) { + absolute_time_t timeout = make_timeout_time_ms(timeout_ms); + while(is_busy() && !time_reached(timeout)) { tight_loop_contents(); } } diff --git a/drivers/inky73/inky73.hpp b/drivers/inky73/inky73.hpp index 14c7b6ff..bed9ee75 100644 --- a/drivers/inky73/inky73.hpp +++ b/drivers/inky73/inky73.hpp @@ -70,7 +70,7 @@ namespace pimoroni { // Methods //-------------------------------------------------- public: - void busy_wait(); + void busy_wait(uint timeout_ms=45000); void reset(); void power_off();