From 145a5cb7621706c55c18a74e4c8e2a49124429bd Mon Sep 17 00:00:00 2001 From: Brandon Ros Date: Tue, 22 Aug 2023 18:33:43 -0400 Subject: [PATCH] lint --- cyw43/src/bluetooth.rs | 30 ++++++++++++++++++++----- cyw43/src/bus.rs | 11 +++++---- cyw43/src/lib.rs | 4 +++- cyw43/src/runner.rs | 14 ++++++++++-- examples/rp/src/bin/bluetooth_blinky.rs | 12 ++++++++-- examples/rp/src/bin/wifi_blinky.rs | 2 +- 6 files changed, 57 insertions(+), 16 deletions(-) diff --git a/cyw43/src/bluetooth.rs b/cyw43/src/bluetooth.rs index 35a1bfdf..0289ff2a 100644 --- a/cyw43/src/bluetooth.rs +++ b/cyw43/src/bluetooth.rs @@ -25,7 +25,15 @@ pub(crate) async fn upload_bluetooth_firmware( for (index, &(dest_addr, num_fw_bytes)) in firmware_offsets.iter().enumerate() { let fw_bytes = &firmware[(fw_bytes_pointer)..(fw_bytes_pointer + num_fw_bytes)]; assert!(fw_bytes.len() == num_fw_bytes); - debug!("index = {}/{} dest_addr = {:08x} num_fw_bytes = {} fw_bytes_pointer = {} fw_bytes = {:02x}", index, firmware_offsets.len(), dest_addr, num_fw_bytes, fw_bytes_pointer, fw_bytes); + debug!( + "index = {}/{} dest_addr = {:08x} num_fw_bytes = {} fw_bytes_pointer = {} fw_bytes = {:02x}", + index, + firmware_offsets.len(), + dest_addr, + num_fw_bytes, + fw_bytes_pointer, + fw_bytes + ); let mut dest_start_addr = dest_addr; let mut aligned_data_buffer_index: usize = 0; // pad start @@ -34,7 +42,10 @@ pub(crate) async fn upload_bluetooth_firmware( let padded_dest_start_addr = round_down(dest_start_addr, 4); let memory_value = bus.bp_read32(padded_dest_start_addr).await; let memory_value_bytes = memory_value.to_le_bytes(); // TODO: le or be - debug!("pad start padded_dest_start_addr = {:08x} memory_value_bytes = {:02x}", padded_dest_start_addr, memory_value_bytes); + debug!( + "pad start padded_dest_start_addr = {:08x} memory_value_bytes = {:02x}", + padded_dest_start_addr, memory_value_bytes + ); // Copy the previous memory value's bytes to the start for i in 0..num_pad_bytes as usize { aligned_data_buffer[aligned_data_buffer_index] = memory_value_bytes[i]; @@ -61,7 +72,10 @@ pub(crate) async fn upload_bluetooth_firmware( let padded_dest_end_addr = round_down(dest_end_addr, 4); let memory_value = bus.bp_read32(padded_dest_end_addr).await; let memory_value_bytes = memory_value.to_le_bytes(); // TODO: le or be - debug!("pad end padded_dest_end_addr = {:08x} memory_value_bytes = {:02x}", padded_dest_end_addr, memory_value_bytes); + debug!( + "pad end padded_dest_end_addr = {:08x} memory_value_bytes = {:02x}", + padded_dest_end_addr, memory_value_bytes + ); // Append the necessary memory bytes to pad the end of aligned_data_buffer for i in offset..4 { aligned_data_buffer[aligned_data_buffer_index] = memory_value_bytes[i as usize]; @@ -106,8 +120,8 @@ pub(crate) async fn wait_bt_ready(bus: &mut Bu } pub(crate) async fn wait_bt_awake(bus: &mut Bus) { - debug!("wait_bt_awake"); - let mut success = false; + debug!("wait_bt_awake"); + let mut success = false; for _ in 0..300 { let val = bus.bp_read32(BT_CTRL_REG_ADDR).await; // TODO: do we need to swap endianness on this read? @@ -154,7 +168,11 @@ pub(crate) async fn bt_set_intr(bus: &mut Bus< bus.bp_write32(HOST_CTRL_REG_ADDR, new_val).await; } -pub(crate) async fn init_bluetooth(bus: &mut Bus, firmware_offsets: &[(u32, usize)], firmware: &[u8]) { +pub(crate) async fn init_bluetooth( + bus: &mut Bus, + firmware_offsets: &[(u32, usize)], + firmware: &[u8], +) { Timer::after(Duration::from_millis(100)).await; debug!("init_bluetooth"); Timer::after(Duration::from_millis(100)).await; diff --git a/cyw43/src/bus.rs b/cyw43/src/bus.rs index 32aed697..ed031861 100644 --- a/cyw43/src/bus.rs +++ b/cyw43/src/bus.rs @@ -252,14 +252,14 @@ where if len == 4 { bus_addr |= BACKPLANE_ADDRESS_32BIT_FLAG; } - + let val = self.readn(FUNC_BACKPLANE, bus_addr, len).await; debug!("backplane_readn addr = {:08x} len = {} val = {:08x}", addr, len, val); self.backplane_set_window(0x18000000).await; // CHIPCOMMON_BASE_ADDRESS - return val + return val; } async fn backplane_writen(&mut self, addr: u32, val: u32, len: u32) { @@ -307,7 +307,7 @@ where ) .await; } - + self.backplane_window = new_window; } @@ -345,7 +345,10 @@ where self.status = self.spi.cmd_read(cmd, &mut buf[..len]).await; - debug!("readn cmd = {:08x} addr = {:08x} len = {} buf = {:08x}", cmd, addr, len, buf); + debug!( + "readn cmd = {:08x} addr = {:08x} len = {} buf = {:08x}", + cmd, addr, len, buf + ); // if we read from the backplane, the result is in the second word, after the response delay if func == FUNC_BACKPLANE { diff --git a/cyw43/src/lib.rs b/cyw43/src/lib.rs index 84975f53..b51e8663 100644 --- a/cyw43/src/lib.rs +++ b/cyw43/src/lib.rs @@ -226,7 +226,9 @@ where let mut runner = Runner::new(ch_runner, Bus::new(pwr, spi), &state.ioctl_state, &state.events); - runner.init(firmware, bluetooth_firmware_offsets, bluetooth_firmware).await; + runner + .init(firmware, bluetooth_firmware_offsets, bluetooth_firmware) + .await; ( device, diff --git a/cyw43/src/runner.rs b/cyw43/src/runner.rs index 9858ca99..7dc22870 100644 --- a/cyw43/src/runner.rs +++ b/cyw43/src/runner.rs @@ -73,7 +73,12 @@ where } } - pub(crate) async fn init(&mut self, firmware: &[u8], bluetooth_firmware_offsets: Option<&[(u32, usize)]>, bluetooth_firmware: Option<&[u8]>) { + pub(crate) async fn init( + &mut self, + firmware: &[u8], + bluetooth_firmware_offsets: Option<&[(u32, usize)]>, + bluetooth_firmware: Option<&[u8]>, + ) { self.bus.init().await; // Init ALP (Active Low Power) clock @@ -119,7 +124,12 @@ where // Optionally load Bluetooth fimrware into RAM. if bluetooth_firmware_offsets.is_some() && bluetooth_firmware.is_some() { debug!("loading bluetooth fw"); - bluetooth::init_bluetooth(&mut self.bus, bluetooth_firmware_offsets.unwrap(), bluetooth_firmware.unwrap()).await; + bluetooth::init_bluetooth( + &mut self.bus, + bluetooth_firmware_offsets.unwrap(), + bluetooth_firmware.unwrap(), + ) + .await; } debug!("loading nvram"); diff --git a/examples/rp/src/bin/bluetooth_blinky.rs b/examples/rp/src/bin/bluetooth_blinky.rs index 19027484..2f8bf654 100644 --- a/examples/rp/src/bin/bluetooth_blinky.rs +++ b/examples/rp/src/bin/bluetooth_blinky.rs @@ -49,7 +49,15 @@ async fn main(spawner: Spawner) { let state = make_static!(cyw43::State::new()); let bluetooth_firmware_offsets = &cyw43_firmware::BLUETOOTH_FIRMWARE_OFFSETS; let bluetooth_firmware = &cyw43_firmware::BLUETOOTH_FIRMWARE; - let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw, Some(bluetooth_firmware_offsets), Some(bluetooth_firmware)).await; + let (_net_device, mut control, runner) = cyw43::new( + state, + pwr, + spi, + fw, + Some(bluetooth_firmware_offsets), + Some(bluetooth_firmware), + ) + .await; unwrap!(spawner.spawn(cyw43_runner_task(runner))); control.init(clm).await; @@ -67,4 +75,4 @@ async fn main(spawner: Spawner) { control.gpio_set(0, false).await; Timer::after(delay).await; } -} \ No newline at end of file +} diff --git a/examples/rp/src/bin/wifi_blinky.rs b/examples/rp/src/bin/wifi_blinky.rs index 51be50a0..33d43788 100644 --- a/examples/rp/src/bin/wifi_blinky.rs +++ b/examples/rp/src/bin/wifi_blinky.rs @@ -65,4 +65,4 @@ async fn main(spawner: Spawner) { control.gpio_set(0, false).await; Timer::after(delay).await; } -} \ No newline at end of file +}