diff --git a/Changelog.txt b/Changelog.txt index 0bb547961..79f28f709 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -6,6 +6,7 @@ Version 6.4.0 - Fixed some quirks in the space/tab warning code - Fixed incorrect expansion of field[ptr][n]~~ - Fixed an incompatibility between _tx and debug() +- Fixed timeout in _rxraw() (test was wrong way around) - Improved range of sin and cos functions - Improved performance of flash access in littlefs (thanks, Evan!) - Updated -gbrk code to most recent from Chip, and add support for brk #0 interactive debug (thanks, Ada!) diff --git a/sys/nucode_util.spin b/sys/nucode_util.spin index 2c42b4d72..710fd454b 100644 --- a/sys/nucode_util.spin +++ b/sys/nucode_util.spin @@ -147,7 +147,7 @@ pri _rxraw(timeout = 0) : rxbyte = long | z, endtime, temp2, rxpin rxbyte := _rdpin(rxpin)>>24 quit if timeout - if _getcnt() - endtime < 0 + if endtime - _getcnt() < 0 quit '' diff --git a/sys/nucode_util.spin.h b/sys/nucode_util.spin.h index f323a00c8..85c969fd3 100644 --- a/sys/nucode_util.spin.h +++ b/sys/nucode_util.spin.h @@ -262,8 +262,8 @@ unsigned char sys_nucode_util_spin[] = { 0x3e, 0x3e, 0x32, 0x34, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x71, 0x75, 0x69, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x69, 0x66, 0x20, 0x5f, 0x67, 0x65, 0x74, 0x63, 0x6e, 0x74, 0x28, - 0x29, 0x20, 0x2d, 0x20, 0x65, 0x6e, 0x64, 0x74, 0x69, 0x6d, 0x65, 0x20, + 0x20, 0x69, 0x66, 0x20, 0x65, 0x6e, 0x64, 0x74, 0x69, 0x6d, 0x65, 0x20, + 0x2d, 0x20, 0x5f, 0x67, 0x65, 0x74, 0x63, 0x6e, 0x74, 0x28, 0x29, 0x20, 0x3c, 0x20, 0x30, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x71, 0x75, 0x69, 0x74, 0x0a, 0x0a, 0x27, 0x27, 0x0a, 0x27, 0x27, 0x20, 0x6d, 0x65, 0x6d, 0x73, 0x65, 0x74, 0x2f, 0x6d, 0x65, 0x6d, 0x6d, 0x6f, diff --git a/sys/p1_code.spin b/sys/p1_code.spin index 97e659c0c..665edd13c 100644 --- a/sys/p1_code.spin +++ b/sys/p1_code.spin @@ -162,7 +162,7 @@ pri _rxraw(timeout = 0) | val, waitcycles, i, bitcycles repeat if ina[_rxpin] == 0 quit - if waitcycles - cnt < 0 + if cnt - waitcycles < 0 return -1 else repeat until ina[_rxpin] == 0 diff --git a/sys/p1_code.spin.h b/sys/p1_code.spin.h index 972f0e1ae..471ce2d05 100644 --- a/sys/p1_code.spin.h +++ b/sys/p1_code.spin.h @@ -233,9 +233,9 @@ unsigned char sys_p1_code_spin[] = { 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x69, 0x6e, 0x61, 0x5b, 0x5f, 0x72, 0x78, 0x70, 0x69, 0x6e, 0x5d, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x71, 0x75, 0x69, 0x74, 0x0a, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x77, 0x61, 0x69, - 0x74, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x73, 0x20, 0x2d, 0x20, 0x63, 0x6e, - 0x74, 0x20, 0x3c, 0x20, 0x30, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x63, 0x6e, 0x74, + 0x20, 0x2d, 0x20, 0x77, 0x61, 0x69, 0x74, 0x63, 0x79, 0x63, 0x6c, 0x65, + 0x73, 0x20, 0x3c, 0x20, 0x30, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x2d, 0x31, 0x0a, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x20, 0x75, 0x6e, 0x74, 0x69, 0x6c, 0x20, diff --git a/sys/p2_code.spin b/sys/p2_code.spin index 7d8db438e..bcdf3819e 100644 --- a/sys/p2_code.spin +++ b/sys/p2_code.spin @@ -212,7 +212,7 @@ pri _rxraw(timeout = 0) : rxbyte = long | z, endtime, temp2, rxpin if_z shr temp2, #32 - 28 .breakone endasm - until z or (timeout and (_getcnt() - endtime < 0)) + until z or (timeout and (endtime - _getcnt() < 0)) if z rxbyte := temp2 & $ff _rx_temp := temp2 diff --git a/sys/p2_code.spin.h b/sys/p2_code.spin.h index 6d537a15c..047e81012 100644 --- a/sys/p2_code.spin.h +++ b/sys/p2_code.spin.h @@ -386,8 +386,8 @@ unsigned char sys_p2_code_spin[] = { 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x61, 0x73, 0x6d, 0x0a, 0x20, 0x20, 0x75, 0x6e, 0x74, 0x69, 0x6c, 0x20, 0x7a, 0x20, 0x6f, 0x72, 0x20, 0x28, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x61, - 0x6e, 0x64, 0x20, 0x28, 0x5f, 0x67, 0x65, 0x74, 0x63, 0x6e, 0x74, 0x28, - 0x29, 0x20, 0x2d, 0x20, 0x65, 0x6e, 0x64, 0x74, 0x69, 0x6d, 0x65, 0x20, + 0x6e, 0x64, 0x20, 0x28, 0x65, 0x6e, 0x64, 0x74, 0x69, 0x6d, 0x65, 0x20, + 0x2d, 0x20, 0x5f, 0x67, 0x65, 0x74, 0x63, 0x6e, 0x74, 0x28, 0x29, 0x20, 0x3c, 0x20, 0x30, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x7a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x78, 0x62, 0x79, 0x74, 0x65, 0x20, 0x3a, 0x3d, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x32, 0x20, 0x26, 0x20, 0x24,