From 8d920d7ed065301af15026d2c325494daa797848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Ekstr=C3=B6m?= Date: Fri, 24 Jun 2022 20:34:44 +0200 Subject: [PATCH] Bugfix to allow NULL tx pointer Also set the _clkHZ variable which is needed for timing operations such as erase. --- src/libgpiodJtagBitbang.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libgpiodJtagBitbang.cpp b/src/libgpiodJtagBitbang.cpp index 0dd7628..ccb0308 100644 --- a/src/libgpiodJtagBitbang.cpp +++ b/src/libgpiodJtagBitbang.cpp @@ -83,6 +83,10 @@ LibgpiodJtagBitbang::LibgpiodJtagBitbang( _curr_tdi = 0; _curr_tck = 0; _curr_tms = 1; + + // FIXME: I'm unsure how this value should be set. + // Maybe experiment, or think through what it should be. + _clkHZ = 5000000; } LibgpiodJtagBitbang::~LibgpiodJtagBitbang() @@ -191,16 +195,16 @@ int LibgpiodJtagBitbang::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool e if (end && (i == len - 1)) tms = 1; - tdi = (tx[i >> 3] & (1 << (i & 7))) ? 1 : 0; + if (tx) + tdi = (tx[i >> 3] & (1 << (i & 7))) ? 1 : 0; update_pins(0, tms, tdi); + update_pins(1, tms, tdi); if (rx) { if (read_tdo() > 0) rx[i >> 3] |= 1 << (i & 7); } - - update_pins(1, tms, tdi); } update_pins(0, tms, tdi);