Skip to content
Merged
Show file tree
Hide file tree
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
29 changes: 25 additions & 4 deletions src/lgfx/v1/panel/Panel_IT8951.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,14 @@ IT8951 Registers defines
_bus->endTransaction();
}

bool Panel_IT8951::_wait_busy(uint32_t timeout)
// Bounded poll of the BUSY pin, without touching chip-select.
// Returns false after `timeout` ms if BUSY never deasserts (e.g. the
// panel's boost converter browned out and left BUSY stuck), instead of
// spinning forever. Shared by _wait_busy() below and by _write_args(),
// which must keep CS asserted continuously across a multi-word burst
// and therefore can't use _wait_busy() directly.
bool Panel_IT8951::_wait_busy_pin(uint32_t timeout)
{
_bus->wait();
cs_control(true);
if (_cfg.pin_busy >= 0 && !lgfx::gpio_in(_cfg.pin_busy))
{
auto start_ms = millis();
Expand All @@ -264,6 +268,17 @@ IT8951 Registers defines
}
} while (!lgfx::gpio_in(_cfg.pin_busy));
}
return true;
}

bool Panel_IT8951::_wait_busy(uint32_t timeout)
{
_bus->wait();
cs_control(true);
if (!_wait_busy_pin(timeout))
{
return false;
}
cs_control(false);
return true;
}
Expand Down Expand Up @@ -339,7 +354,13 @@ IT8951 Registers defines
{
uint32_t buf = getSwap16(args[i]);
_bus->wait();
while (!lgfx::gpio_in(_cfg.pin_busy));
// CS must stay asserted for the whole multi-word burst, so this
// can't go through _wait_busy() (it toggles CS). A stuck BUSY
// line must still fail out here rather than hang forever.
if (!_wait_busy_pin())
{
return false;
}
Comment thread
lovyan03 marked this conversation as resolved.
_bus->writeData(buf, 16);
} while ( ++i < length );
return true;
Expand Down
1 change: 1 addition & 0 deletions src/lgfx/v1/panel/Panel_IT8951.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ namespace lgfx
uint16_t _vcom = 0;

bool _wait_busy( uint32_t timeout = 4096);
bool _wait_busy_pin( uint32_t timeout = 4096);
bool _write_command( uint16_t cmd);
bool _write_word( uint16_t data);
bool _write_args( uint16_t cmd, uint16_t *args, int32_t length);
Expand Down
Loading