diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-12-07 21:18:25 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-12-07 21:18:25 +0000 |
| commit | 86578acaa4d4dbed06ed4fcecec25884f6883e82 (patch) | |
| tree | 7f651450d96983a4f5b105cef782cd903ee35d57 | |
| parent | a869c3d1fe3607752fc2101a7a7f5d1f21567e49 (diff) | |
| parent | d1df927c03d837a50f49d349060e8e7b3aa511b9 (diff) | |
Merge pull request #3624 from embassy-rs/nfct-fix2
nrf/nfct: actually fix frame timing.
| -rw-r--r-- | embassy-nrf/src/nfct.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/embassy-nrf/src/nfct.rs b/embassy-nrf/src/nfct.rs index 85866063a..cbd3920ee 100644 --- a/embassy-nrf/src/nfct.rs +++ b/embassy-nrf/src/nfct.rs | |||
| @@ -212,15 +212,13 @@ impl<'d> NfcT<'d> { | |||
| 212 | #[cfg(not(feature = "nrf52832"))] | 212 | #[cfg(not(feature = "nrf52832"))] |
| 213 | r.autocolresconfig().write(|w| w.0 = 0b10); | 213 | r.autocolresconfig().write(|w| w.0 = 0b10); |
| 214 | 214 | ||
| 215 | // framedelaymax=4096 is needed to make it work with phones from | ||
| 216 | // a certain company named after some fruit. | ||
| 217 | r.framedelaymin().write(|w| w.set_framedelaymin(1152)); | ||
| 218 | r.framedelaymax().write(|w| w.set_framedelaymax(4096)); | ||
| 215 | r.framedelaymode().write(|w| { | 219 | r.framedelaymode().write(|w| { |
| 216 | w.set_framedelaymode(vals::Framedelaymode::WINDOW_GRID); | 220 | w.set_framedelaymode(vals::Framedelaymode::WINDOW_GRID); |
| 217 | }); | 221 | }); |
| 218 | r.framedelaymin().write(|w| { | ||
| 219 | w.set_framedelaymin(1152); | ||
| 220 | }); | ||
| 221 | r.framedelaymax().write(|w| { | ||
| 222 | w.set_framedelaymax(0xFFFF); // max | ||
| 223 | }); | ||
| 224 | 222 | ||
| 225 | info!("waiting for field"); | 223 | info!("waiting for field"); |
| 226 | poll_fn(|cx| { | 224 | poll_fn(|cx| { |
| @@ -269,6 +267,17 @@ impl<'d> NfcT<'d> { | |||
| 269 | #[cfg(not(feature = "nrf52832"))] | 267 | #[cfg(not(feature = "nrf52832"))] |
| 270 | r.autocolresconfig().write(|w| w.0 = 0b11u32); | 268 | r.autocolresconfig().write(|w| w.0 = 0b11u32); |
| 271 | 269 | ||
| 270 | // once anticoll is done, set framedelaymax to the maximum possible. | ||
| 271 | // this gives the firmware as much time as possible to reply. | ||
| 272 | // higher layer still has to reply faster than the FWT it specifies in the iso14443-4 ATS, | ||
| 273 | // but that's not our concern. | ||
| 274 | // | ||
| 275 | // nrf52832 field is 16bit instead of 20bit. this seems to force a too short timeout, maybe it's a SVD bug? | ||
| 276 | #[cfg(not(feature = "nrf52832"))] | ||
| 277 | r.framedelaymax().write(|w| w.set_framedelaymax(0xF_FFFF)); | ||
| 278 | #[cfg(feature = "nrf52832")] | ||
| 279 | r.framedelaymax().write(|w| w.set_framedelaymax(0xFFFF)); | ||
| 280 | |||
| 272 | return; | 281 | return; |
| 273 | } | 282 | } |
| 274 | } | 283 | } |
