cargo: update to esp-hal 1.0, and use esp-radio for less crashes
This commit is contained in:
@@ -29,7 +29,7 @@ fn gyro_raw_to_rads(raw: i16) -> f32 {
|
||||
(raw as f32 / 16.4) * (DEG2RAD)
|
||||
}
|
||||
|
||||
#[esp_hal::ram(rtc_fast, persistent)]
|
||||
#[esp_hal::ram(unstable(rtc_fast, persistent))]
|
||||
static mut MPU_WAS_CALIBRATED: u8 = 0;
|
||||
|
||||
#[embassy_executor::task]
|
||||
|
||||
@@ -16,10 +16,9 @@ pub async fn render(rmt: esp_hal::peripherals::RMT<'static>, gpio: AnyPin<'stati
|
||||
.expect("Failed to initialize RMT").into_async();
|
||||
let rmt_channel = rmt.channel0;
|
||||
|
||||
let rmt_buffer = [0u32; buffer_size_async(NUM_PIXELS)];
|
||||
let mut rmt_buffer = esp_hal_smartled::smart_led_buffer!(NUM_PIXELS);
|
||||
|
||||
//let target = SmartLedsAdapterAsync::new(rmt_channel, gpio, rmt_buffer);
|
||||
let target = SmartLedsAdapterAsync::new(rmt_channel, gpio, rmt_buffer);
|
||||
let target = SmartLedsAdapterAsync::new_with_color(rmt_channel, gpio, &mut rmt_buffer);
|
||||
|
||||
// Change this to adjust the power available; the USB spec says 500ma is the standard limit, but sometimes you can draw more from a power brick
|
||||
const POWER_MA : u32 = 500;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use alloc::string::ToString;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_sync::pubsub::DynSubscriber;
|
||||
use esp_wifi::{EspWifiController, wifi::{ClientConfiguration, WifiDevice}};
|
||||
use esp_radio::Controller;
|
||||
use esp_radio::wifi::{ClientConfig, WifiDevice};
|
||||
use log::*;
|
||||
use alloc::format;
|
||||
|
||||
@@ -24,19 +25,17 @@ static RESOURCES: StaticCell<StackResources<5>> = StaticCell::new();
|
||||
|
||||
// TODO: Wifi task needs to know when there is data to upload, so it only connects when needed.
|
||||
#[embassy_executor::task]
|
||||
pub async fn wireless_task(mut telemetry: DynSubscriber<'static, Telemetry>, wifi_init: &'static mut EspWifiController<'static>, wifi_device: esp_hal::peripherals::WIFI<'static>) {
|
||||
let (mut wifi, interfaces) = esp_wifi::wifi::new(wifi_init, wifi_device)
|
||||
pub async fn wireless_task(mut telemetry: DynSubscriber<'static, Telemetry>, wifi_init: &'static mut Controller<'static>, wifi_device: esp_hal::peripherals::WIFI<'static>) {
|
||||
let (mut wifi, interfaces) = esp_radio::wifi::new(wifi_init, wifi_device, esp_radio::wifi::Config::default())
|
||||
.expect("Failed to initialize WIFI!");
|
||||
wifi.set_configuration(&esp_wifi::wifi::Configuration::Client(
|
||||
ClientConfiguration {
|
||||
ssid: "The Frequency".to_string(),
|
||||
auth_method: esp_wifi::wifi::AuthMethod::WPA2Personal,
|
||||
password: "thepasswordkenneth".to_string(),
|
||||
..Default::default()
|
||||
}
|
||||
wifi.set_config(&esp_radio::wifi::ModeConfig::Client(
|
||||
ClientConfig::default()
|
||||
.with_ssid("The Frequencey".to_string())
|
||||
.with_auth_method(esp_radio::wifi::AuthMethod::Wpa2Personal)
|
||||
.with_password("thepasswordkenneth".to_string())
|
||||
)).unwrap();
|
||||
wifi.set_mode(esp_wifi::wifi::WifiMode::Sta).unwrap();
|
||||
wifi.set_power_saving(esp_wifi::config::PowerSaveMode::Maximum).unwrap();
|
||||
wifi.set_mode(esp_radio::wifi::WifiMode::Sta).unwrap();
|
||||
wifi.set_power_saving(esp_radio::wifi::PowerSaveMode::Maximum).unwrap();
|
||||
wifi.start_async().await.unwrap();
|
||||
|
||||
let device = interfaces.sta;
|
||||
@@ -46,7 +45,7 @@ pub async fn wireless_task(mut telemetry: DynSubscriber<'static, Telemetry>, wif
|
||||
let config = Config::dhcpv4(Default::default());
|
||||
let (stack, runner) = embassy_net::new(device, config, RESOURCES.init_with(|| { StackResources::new() }), seed as u64);
|
||||
info!("Launching network task");
|
||||
Spawner::for_current_executor().await.must_spawn(net_task(runner));
|
||||
unsafe { Spawner::for_current_executor().await }.must_spawn(net_task(runner));
|
||||
|
||||
loop {
|
||||
Backoff::from_secs(3).forever().attempt(async || {
|
||||
|
||||
Reference in New Issue
Block a user