Delay in `read_byte` may be too long
Opened this issue · 0 comments
nomis commented
Running on a LOLIN D1 mini I've had to decrease the delay in read_byte
to 16 or 17 swim clock cycles or there's always a timeout on bits 6, 7 or 8.
The decimal "indicate which bit failed" offset isn't very usable because stm8flash reports unknown error codes as hex.
--- src/driver/swim.c
+++ src/driver/swim.c
@@ -181,11 +182,11 @@ static int read_byte() {
uint32_t parity = 0;
uint32_t i;
for (i = 0; i < 9; i++) {
- sync_ccount(next + 18 * SWIM_CLOCK);
+ sync_ccount(next + 17 * SWIM_CLOCK);
int bit = read_bit(&next);
if (bit == SWIM_ERROR_READ_BIT_TIMEOUT) {
// indicate which bit failed (for debugging)
- return -i - 20;
+ return -i - 0x20;
}
result = result << 1 | !!bit;
parity ^= result;