diff --git a/cyw43/src/lib.rs b/cyw43/src/lib.rs index b51e8663..4b6b6149 100644 --- a/cyw43/src/lib.rs +++ b/cyw43/src/lib.rs @@ -214,8 +214,32 @@ pub async fn new<'a, PWR, SPI>( pwr: PWR, spi: SPI, firmware: &[u8], - bluetooth_firmware_offsets: Option<&[(u32, usize)]>, - bluetooth_firmware: Option<&[u8]>, +) -> (NetDriver<'a>, Control<'a>, Runner<'a, PWR, SPI>) +where + PWR: OutputPin, + SPI: SpiBusCyw43, +{ + let (ch_runner, device) = ch::new(&mut state.ch, ch::driver::HardwareAddress::Ethernet([0; 6])); + let state_ch = ch_runner.state_runner(); + + let mut runner = Runner::new(ch_runner, Bus::new(pwr, spi), &state.ioctl_state, &state.events); + + runner.init(firmware, None, None).await; + + ( + device, + Control::new(state_ch, &state.events, &state.ioctl_state), + runner, + ) +} + +pub async fn new_with_bluetooth<'a, PWR, SPI>( + state: &'a mut State, + pwr: PWR, + spi: SPI, + firmware: &[u8], + bluetooth_firmware_offsets: &[(u32, usize)], + bluetooth_firmware: &[u8], ) -> (NetDriver<'a>, Control<'a>, Runner<'a, PWR, SPI>) where PWR: OutputPin, @@ -227,7 +251,7 @@ 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) + .init(firmware, Some(bluetooth_firmware_offsets), Some(bluetooth_firmware)) .await; ( diff --git a/examples/rp/src/bin/bluetooth_blinky.rs b/examples/rp/src/bin/bluetooth_blinky.rs index 2f8bf654..aff4b505 100644 --- a/examples/rp/src/bin/bluetooth_blinky.rs +++ b/examples/rp/src/bin/bluetooth_blinky.rs @@ -49,15 +49,8 @@ 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_with_bluetooth(state, pwr, spi, fw, bluetooth_firmware_offsets, bluetooth_firmware).await; unwrap!(spawner.spawn(cyw43_runner_task(runner))); control.init(clm).await;