lint
This commit is contained in:
		| @@ -25,7 +25,15 @@ pub(crate) async fn upload_bluetooth_firmware<PWR: OutputPin, SPI: SpiBusCyw43>( | ||||
|     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<PWR: OutputPin, SPI: SpiBusCyw43>( | ||||
|             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<PWR: OutputPin, SPI: SpiBusCyw43>( | ||||
|             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<PWR: OutputPin, SPI: SpiBusCyw43>(bus: &mut Bu | ||||
| } | ||||
|  | ||||
| pub(crate) async fn wait_bt_awake<PWR: OutputPin, SPI: SpiBusCyw43>(bus: &mut Bus<PWR, SPI>) { | ||||
|    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<PWR: OutputPin, SPI: SpiBusCyw43>(bus: &mut Bus< | ||||
|     bus.bp_write32(HOST_CTRL_REG_ADDR, new_val).await; | ||||
| } | ||||
|  | ||||
| pub(crate) async fn init_bluetooth<PWR: OutputPin, SPI: SpiBusCyw43>(bus: &mut Bus<PWR, SPI>, firmware_offsets: &[(u32, usize)], firmware: &[u8]) { | ||||
| pub(crate) async fn init_bluetooth<PWR: OutputPin, SPI: SpiBusCyw43>( | ||||
|     bus: &mut Bus<PWR, SPI>, | ||||
|     firmware_offsets: &[(u32, usize)], | ||||
|     firmware: &[u8], | ||||
| ) { | ||||
|     Timer::after(Duration::from_millis(100)).await; | ||||
|     debug!("init_bluetooth"); | ||||
|     Timer::after(Duration::from_millis(100)).await; | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -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"); | ||||
|   | ||||
| @@ -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; | ||||
|     } | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -65,4 +65,4 @@ async fn main(spawner: Spawner) { | ||||
|         control.gpio_set(0, false).await; | ||||
|         Timer::after(delay).await; | ||||
|     } | ||||
| } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user