diff options
| author | Daniel Bevenius <[email protected]> | 2022-09-09 14:15:19 +0200 |
|---|---|---|
| committer | Daniel Bevenius <[email protected]> | 2022-09-09 15:09:54 +0200 |
| commit | f0b7f43c4104ea15c860d557c4a507681cba0d0d (patch) | |
| tree | f876a7be222701a1a6be570f71c7d251d9622bac /src/lib.rs | |
| parent | 6b90ab86644b48fd4b687c1173d1f9284f568a3b (diff) | |
Use wrapping_sub in update_credit
This commit uses wrapping_sub for subtraction in update_credit.
The motivation for this is that currently the rpi-pico-w example panics
(at least for me) with the following error:
3.825277 INFO init done
└─ cyw43::{impl#4}::init::{async_fn#0} @ /embassy/cyw43/src/fmt.rs:138
3.825486 INFO Downloading CLM...
└─ cyw43::{impl#2}::init::{async_fn#0} @ /embassy/cyw43/src/fmt.rs:138
3.841328 WARN TX stalled
└─ cyw43::{impl#4}::run::{async_fn#0} @ /embassy/cyw43/src/fmt.rs:151
3.845549 ERROR panicked at 'attempt to subtract with overflow', /embassy/cyw43/src/lib.rs:919:16
└─ panic_probe::print_defmt::print @ .cargo/registry/src/github.com-1ecc6299db9ec823/panic-probe-0.3.0/src/lib.rs:91
────────────────────────────────────────────────────────────────────────────────
stack backtrace:
0: HardFaultTrampoline
<exception entry>
1: lib::inline::__udf
at ./asm/inline.rs:181:5
2: __udf
at ./asm/lib.rs:51:17
3: cortex_m::asm::udf
at .cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-0.7.6/src/asm.rs:43:5
4: rust_begin_unwind
at .cargo/registry/src/github.com-1ecc6299db9ec823/panic-probe-0.3.0/src/lib.rs:72:9
5: core::panicking::panic_fmt
at rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/panicking.rs:142:14
6: core::panicking::panic
at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/panicking.rs:48:5
7: cyw43::Runner<PWR,SPI>::update_credit
at /embassy/cyw43/src/lib.rs:919:16
8: cyw43::Runner<PWR,SPI>::rx
at /embassy/cyw43/src/lib.rs:808:9
9: cyw43::Runner<PWR,SPI>::run::{{closure}}
at /embassy/cyw43/src/lib.rs:727:21
10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/future/mod.rs:91:19
11: cyw43_example_rpi_pico_w::__wifi_task_task::{{closure}}
at src/main.rs:32:17
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs index 21b8b2d80..d9a21f4bb 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
| @@ -916,7 +916,7 @@ where | |||
| 916 | fn update_credit(&mut self, sdpcm_header: &SdpcmHeader) { | 916 | fn update_credit(&mut self, sdpcm_header: &SdpcmHeader) { |
| 917 | if sdpcm_header.channel_and_flags & 0xf < 3 { | 917 | if sdpcm_header.channel_and_flags & 0xf < 3 { |
| 918 | let mut sdpcm_seq_max = sdpcm_header.bus_data_credit; | 918 | let mut sdpcm_seq_max = sdpcm_header.bus_data_credit; |
| 919 | if sdpcm_seq_max - self.sdpcm_seq > 0x40 { | 919 | if sdpcm_seq_max.wrapping_sub(self.sdpcm_seq) > 0x40 { |
| 920 | sdpcm_seq_max = self.sdpcm_seq + 2; | 920 | sdpcm_seq_max = self.sdpcm_seq + 2; |
| 921 | } | 921 | } |
| 922 | self.sdpcm_seq_max = sdpcm_seq_max; | 922 | self.sdpcm_seq_max = sdpcm_seq_max; |
