Skip to content

Commit

Permalink
Amend the XPT2046 driver to work without a CS line (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett authored Apr 27, 2024
1 parent d35e60f commit 78b058e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/lgfx/v1/touch/Touch_XPT2046.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ namespace lgfx
bool Touch_XPT2046::init(void)
{
_inited = false;
if (!isSPI()) return false;

lgfx::gpio_hi(_cfg.pin_cs);
lgfx::pinMode(_cfg.pin_cs, lgfx::pin_mode_t::output);
if (_cfg.pin_cs > -1) {
lgfx::gpio_hi(_cfg.pin_cs);
lgfx::pinMode(_cfg.pin_cs, lgfx::pin_mode_t::output);
}
if (_cfg.spi_host < 0)
{
pinMode(_cfg.pin_sclk, lgfx::pin_mode_t::output);
Expand Down Expand Up @@ -110,9 +111,11 @@ namespace lgfx
else
{
spi::beginTransaction(_cfg.spi_host, _cfg.freq, 0);
lgfx::gpio_lo(_cfg.pin_cs);
if (_cfg.pin_cs > -1)
lgfx::gpio_lo(_cfg.pin_cs);
spi::readBytes(_cfg.spi_host, data, 57);
lgfx::gpio_hi(_cfg.pin_cs);
if (_cfg.pin_cs > -1)
lgfx::gpio_hi(_cfg.pin_cs);
spi::endTransaction(_cfg.spi_host);
}

Expand Down

0 comments on commit 78b058e

Please sign in to comment.