aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-07-11 22:44:42 +0200
committerDario Nieuwenhuis <[email protected]>2022-07-11 22:44:42 +0200
commit3ffdbd2ca3ed7cc3da95c391f1928342afb55e10 (patch)
tree05173dd196d6034b1d217bf8162d7334577a4376
parent30b7800f9ae0a7f26e292dbe55cc67fbe2d1b131 (diff)
stuff
-rw-r--r--examples/rpi-pico-w/src/main.rs1
-rw-r--r--src/lib.rs32
-rw-r--r--src/structs.rs12
3 files changed, 33 insertions, 12 deletions
diff --git a/examples/rpi-pico-w/src/main.rs b/examples/rpi-pico-w/src/main.rs
index d4aae8479..bef820d31 100644
--- a/examples/rpi-pico-w/src/main.rs
+++ b/examples/rpi-pico-w/src/main.rs
@@ -6,6 +6,7 @@ use core::slice;
6 6
7use defmt::{assert, assert_eq, panic, *}; 7use defmt::{assert, assert_eq, panic, *};
8use embassy::executor::Spawner; 8use embassy::executor::Spawner;
9use embassy::time::{Duration, Timer};
9use embassy::util::Forever; 10use embassy::util::Forever;
10use embassy_rp::gpio::{Flex, Level, Output, Pin}; 11use embassy_rp::gpio::{Flex, Level, Output, Pin};
11use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29}; 12use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29};
diff --git a/src/lib.rs b/src/lib.rs
index 040caed86..271917971 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -243,7 +243,7 @@ impl<'a> Control<'a> {
243 info!("Configuring misc stuff..."); 243 info!("Configuring misc stuff...");
244 244
245 self.set_iovar_u32("bus:txglom", 0).await; 245 self.set_iovar_u32("bus:txglom", 0).await;
246 self.set_iovar_u32("apsta", 1).await; 246 //self.set_iovar_u32("apsta", 1).await;
247 self.set_iovar("cur_etheraddr", &[02, 03, 04, 05, 06, 07]).await; 247 self.set_iovar("cur_etheraddr", &[02, 03, 04, 05, 06, 07]).await;
248 248
249 let country = countries::WORLD_WIDE_XX; 249 let country = countries::WORLD_WIDE_XX;
@@ -257,9 +257,13 @@ impl<'a> Control<'a> {
257 // set country takes some time, next ioctls fail if we don't wait. 257 // set country takes some time, next ioctls fail if we don't wait.
258 Timer::after(Duration::from_millis(100)).await; 258 Timer::after(Duration::from_millis(100)).await;
259 259
260 // self.set_iovar_u32("ampdu_ba_wsize", 8).await; 260 self.ioctl_set_u32(64, 0, 0).await; // WLC_SET_ANTDIV
261 // self.set_iovar_u32("ampdu_mpdu", 4).await; 261
262 // self.set_iovar_u32("ampdu_rx_factor", 0).await; // this crashes 262 self.set_iovar_u32("bus:txglom", 0).await;
263 //self.set_iovar_u32("apsta", 1).await;
264 self.set_iovar_u32("ampdu_ba_wsize", 8).await;
265 self.set_iovar_u32("ampdu_mpdu", 4).await;
266 //self.set_iovar_u32("ampdu_rx_factor", 0).await; // this crashes
263 267
264 Timer::after(Duration::from_millis(100)).await; 268 Timer::after(Duration::from_millis(100)).await;
265 269
@@ -275,6 +279,12 @@ impl<'a> Control<'a> {
275 279
276 Timer::after(Duration::from_millis(100)).await; 280 Timer::after(Duration::from_millis(100)).await;
277 281
282 self.ioctl_set_u32(86, 0, 0).await; // no power save
283 self.ioctl_set_u32(110, 0, 1).await; // SET_GMODE = auto
284 self.ioctl_set_u32(142, 0, 0).await; // SET_BAND = any
285
286 Timer::after(Duration::from_millis(100)).await;
287
278 info!("INIT DONE"); 288 info!("INIT DONE");
279 } 289 }
280 290
@@ -494,11 +504,11 @@ impl<'a, PWR: Pin, CS: Pin, CLK: Pin, DIO: Pin> Runner<'a, PWR, CS, CLK, DIO> {
494 let mut val = self.read8(FUNC_BACKPLANE, REG_BACKPLANE_SLEEP_CSR); 504 let mut val = self.read8(FUNC_BACKPLANE, REG_BACKPLANE_SLEEP_CSR);
495 val |= 0x01; // SBSDIO_SLPCSR_KEEP_SDIO_ON 505 val |= 0x01; // SBSDIO_SLPCSR_KEEP_SDIO_ON
496 self.write8(FUNC_BACKPLANE, REG_BACKPLANE_SLEEP_CSR, val); 506 self.write8(FUNC_BACKPLANE, REG_BACKPLANE_SLEEP_CSR, val);
507 */
497 508
498 // clear pulls 509 // clear pulls
499 self.write8(FUNC_BACKPLANE, REG_BACKPLANE_PULL_UP, 0); 510 self.write8(FUNC_BACKPLANE, REG_BACKPLANE_PULL_UP, 0);
500 let _ = self.read8(FUNC_BACKPLANE, REG_BACKPLANE_PULL_UP); 511 let _ = self.read8(FUNC_BACKPLANE, REG_BACKPLANE_PULL_UP);
501 */
502 512
503 info!("init done "); 513 info!("init done ");
504 } 514 }
@@ -595,14 +605,12 @@ impl<'a, PWR: Pin, CS: Pin, CLK: Pin, DIO: Pin> Runner<'a, PWR, CS, CLK, DIO> {
595 let packet = &payload[packet_start..]; 605 let packet = &payload[packet_start..];
596 //info!("rx {:02x}", &packet[..(packet.len() as usize).min(36)]); 606 //info!("rx {:02x}", &packet[..(packet.len() as usize).min(36)]);
597 607
598 let evt = EventHeader::from_bytes(&packet[24..][..EventHeader::SIZE].try_into().unwrap()); 608 let mut evt = EventHeader::from_bytes(&packet[24..][..EventHeader::SIZE].try_into().unwrap());
599 let evt_num = evt.event_type.to_be() as u8; 609 evt.byteswap();
600 let evt_data_len = evt.datalen.to_be() as u8; 610 let evt_data = &packet[24 + EventHeader::SIZE..][..evt.datalen as usize];
601 let evt_data = &packet[24 + EventHeader::SIZE..][..evt_data_len as usize];
602 info!( 611 info!(
603 "=== EVENT {} ({}) {} {:02x}", 612 "=== EVENT {}: {} {:02x}",
604 events::Event::from(evt_num), 613 events::Event::from(evt.event_type as u8),
605 evt_num,
606 evt, 614 evt,
607 evt_data 615 evt_data
608 ); 616 );
diff --git a/src/structs.rs b/src/structs.rs
index 8a98d5227..beda9f364 100644
--- a/src/structs.rs
+++ b/src/structs.rs
@@ -92,6 +92,18 @@ pub struct EventHeader {
92} 92}
93impl_bytes!(EventHeader); 93impl_bytes!(EventHeader);
94 94
95impl EventHeader {
96 pub fn byteswap(&mut self) {
97 self.version = self.version.to_be();
98 self.flags = self.flags.to_be();
99 self.event_type = self.event_type.to_be();
100 self.status = self.status.to_be();
101 self.reason = self.reason.to_be();
102 self.auth_type = self.auth_type.to_be();
103 self.datalen = self.datalen.to_be();
104 }
105}
106
95#[derive(Clone, Copy)] 107#[derive(Clone, Copy)]
96#[repr(C)] 108#[repr(C)]
97pub struct DownloadHeader { 109pub struct DownloadHeader {