stuff
This commit is contained in:
parent
30b7800f9a
commit
3ffdbd2ca3
3 changed files with 33 additions and 12 deletions
|
@ -6,6 +6,7 @@ use core::slice;
|
||||||
|
|
||||||
use defmt::{assert, assert_eq, panic, *};
|
use defmt::{assert, assert_eq, panic, *};
|
||||||
use embassy::executor::Spawner;
|
use embassy::executor::Spawner;
|
||||||
|
use embassy::time::{Duration, Timer};
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_rp::gpio::{Flex, Level, Output, Pin};
|
use embassy_rp::gpio::{Flex, Level, Output, Pin};
|
||||||
use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29};
|
use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29};
|
||||||
|
|
32
src/lib.rs
32
src/lib.rs
|
@ -243,7 +243,7 @@ impl<'a> Control<'a> {
|
||||||
info!("Configuring misc stuff...");
|
info!("Configuring misc stuff...");
|
||||||
|
|
||||||
self.set_iovar_u32("bus:txglom", 0).await;
|
self.set_iovar_u32("bus:txglom", 0).await;
|
||||||
self.set_iovar_u32("apsta", 1).await;
|
//self.set_iovar_u32("apsta", 1).await;
|
||||||
self.set_iovar("cur_etheraddr", &[02, 03, 04, 05, 06, 07]).await;
|
self.set_iovar("cur_etheraddr", &[02, 03, 04, 05, 06, 07]).await;
|
||||||
|
|
||||||
let country = countries::WORLD_WIDE_XX;
|
let country = countries::WORLD_WIDE_XX;
|
||||||
|
@ -257,9 +257,13 @@ impl<'a> Control<'a> {
|
||||||
// set country takes some time, next ioctls fail if we don't wait.
|
// set country takes some time, next ioctls fail if we don't wait.
|
||||||
Timer::after(Duration::from_millis(100)).await;
|
Timer::after(Duration::from_millis(100)).await;
|
||||||
|
|
||||||
// self.set_iovar_u32("ampdu_ba_wsize", 8).await;
|
self.ioctl_set_u32(64, 0, 0).await; // WLC_SET_ANTDIV
|
||||||
// self.set_iovar_u32("ampdu_mpdu", 4).await;
|
|
||||||
// self.set_iovar_u32("ampdu_rx_factor", 0).await; // this crashes
|
self.set_iovar_u32("bus:txglom", 0).await;
|
||||||
|
//self.set_iovar_u32("apsta", 1).await;
|
||||||
|
self.set_iovar_u32("ampdu_ba_wsize", 8).await;
|
||||||
|
self.set_iovar_u32("ampdu_mpdu", 4).await;
|
||||||
|
//self.set_iovar_u32("ampdu_rx_factor", 0).await; // this crashes
|
||||||
|
|
||||||
Timer::after(Duration::from_millis(100)).await;
|
Timer::after(Duration::from_millis(100)).await;
|
||||||
|
|
||||||
|
@ -275,6 +279,12 @@ impl<'a> Control<'a> {
|
||||||
|
|
||||||
Timer::after(Duration::from_millis(100)).await;
|
Timer::after(Duration::from_millis(100)).await;
|
||||||
|
|
||||||
|
self.ioctl_set_u32(86, 0, 0).await; // no power save
|
||||||
|
self.ioctl_set_u32(110, 0, 1).await; // SET_GMODE = auto
|
||||||
|
self.ioctl_set_u32(142, 0, 0).await; // SET_BAND = any
|
||||||
|
|
||||||
|
Timer::after(Duration::from_millis(100)).await;
|
||||||
|
|
||||||
info!("INIT DONE");
|
info!("INIT DONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,11 +504,11 @@ impl<'a, PWR: Pin, CS: Pin, CLK: Pin, DIO: Pin> Runner<'a, PWR, CS, CLK, DIO> {
|
||||||
let mut val = self.read8(FUNC_BACKPLANE, REG_BACKPLANE_SLEEP_CSR);
|
let mut val = self.read8(FUNC_BACKPLANE, REG_BACKPLANE_SLEEP_CSR);
|
||||||
val |= 0x01; // SBSDIO_SLPCSR_KEEP_SDIO_ON
|
val |= 0x01; // SBSDIO_SLPCSR_KEEP_SDIO_ON
|
||||||
self.write8(FUNC_BACKPLANE, REG_BACKPLANE_SLEEP_CSR, val);
|
self.write8(FUNC_BACKPLANE, REG_BACKPLANE_SLEEP_CSR, val);
|
||||||
|
*/
|
||||||
|
|
||||||
// clear pulls
|
// clear pulls
|
||||||
self.write8(FUNC_BACKPLANE, REG_BACKPLANE_PULL_UP, 0);
|
self.write8(FUNC_BACKPLANE, REG_BACKPLANE_PULL_UP, 0);
|
||||||
let _ = self.read8(FUNC_BACKPLANE, REG_BACKPLANE_PULL_UP);
|
let _ = self.read8(FUNC_BACKPLANE, REG_BACKPLANE_PULL_UP);
|
||||||
*/
|
|
||||||
|
|
||||||
info!("init done ");
|
info!("init done ");
|
||||||
}
|
}
|
||||||
|
@ -595,14 +605,12 @@ impl<'a, PWR: Pin, CS: Pin, CLK: Pin, DIO: Pin> Runner<'a, PWR, CS, CLK, DIO> {
|
||||||
let packet = &payload[packet_start..];
|
let packet = &payload[packet_start..];
|
||||||
//info!("rx {:02x}", &packet[..(packet.len() as usize).min(36)]);
|
//info!("rx {:02x}", &packet[..(packet.len() as usize).min(36)]);
|
||||||
|
|
||||||
let evt = EventHeader::from_bytes(&packet[24..][..EventHeader::SIZE].try_into().unwrap());
|
let mut evt = EventHeader::from_bytes(&packet[24..][..EventHeader::SIZE].try_into().unwrap());
|
||||||
let evt_num = evt.event_type.to_be() as u8;
|
evt.byteswap();
|
||||||
let evt_data_len = evt.datalen.to_be() as u8;
|
let evt_data = &packet[24 + EventHeader::SIZE..][..evt.datalen as usize];
|
||||||
let evt_data = &packet[24 + EventHeader::SIZE..][..evt_data_len as usize];
|
|
||||||
info!(
|
info!(
|
||||||
"=== EVENT {} ({}) {} {:02x}",
|
"=== EVENT {}: {} {:02x}",
|
||||||
events::Event::from(evt_num),
|
events::Event::from(evt.event_type as u8),
|
||||||
evt_num,
|
|
||||||
evt,
|
evt,
|
||||||
evt_data
|
evt_data
|
||||||
);
|
);
|
||||||
|
|
|
@ -92,6 +92,18 @@ pub struct EventHeader {
|
||||||
}
|
}
|
||||||
impl_bytes!(EventHeader);
|
impl_bytes!(EventHeader);
|
||||||
|
|
||||||
|
impl EventHeader {
|
||||||
|
pub fn byteswap(&mut self) {
|
||||||
|
self.version = self.version.to_be();
|
||||||
|
self.flags = self.flags.to_be();
|
||||||
|
self.event_type = self.event_type.to_be();
|
||||||
|
self.status = self.status.to_be();
|
||||||
|
self.reason = self.reason.to_be();
|
||||||
|
self.auth_type = self.auth_type.to_be();
|
||||||
|
self.datalen = self.datalen.to_be();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct DownloadHeader {
|
pub struct DownloadHeader {
|
||||||
|
|
Loading…
Reference in a new issue