Merge pull request #3117 from 9names/rp-example-fixes

RP network example fixes
This commit is contained in:
James Munns 2024-06-25 11:09:37 +00:00 committed by GitHub
commit 89cd0e7cca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 5 deletions

View file

@ -25,7 +25,7 @@ fixed = "1.23.1"
fixed-macro = "1.2"
# for web request example
reqwless = { git = "https://github.com/drogue-iot/reqwless", features = ["defmt",]}
reqwless = { version = "0.12.0", features = ["defmt",]}
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
serde-json-core = "0.5.1"

View file

@ -9,6 +9,7 @@ use defmt::*;
use embassy_executor::Spawner;
use embassy_net::tcp::TcpSocket;
use embassy_net::{Stack, StackResources};
use embassy_rp::clocks::RoscRng;
use embassy_rp::peripherals::USB;
use embassy_rp::usb::{Driver, InterruptHandler};
use embassy_rp::{bind_interrupts, peripherals};
@ -16,6 +17,7 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState
use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
use embassy_usb::{Builder, Config, UsbDevice};
use embedded_io_async::Write;
use rand::RngCore;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
@ -45,6 +47,7 @@ async fn net_task(stack: &'static Stack<Device<'static, MTU>>) -> ! {
#[embassy_executor::main]
async fn main(spawner: Spawner) {
let p = embassy_rp::init(Default::default());
let mut rng = RoscRng;
// Create the driver, from the HAL.
let driver = Driver::new(p.USB, Irqs);
@ -102,7 +105,7 @@ async fn main(spawner: Spawner) {
//});
// Generate random seed
let seed = 1234; // guaranteed random, chosen by a fair dice roll
let seed = rng.next_u64();
// Init network stack
static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new();

View file

@ -13,11 +13,13 @@ use embassy_executor::Spawner;
use embassy_net::tcp::TcpSocket;
use embassy_net::{Config, Stack, StackResources};
use embassy_rp::bind_interrupts;
use embassy_rp::clocks::RoscRng;
use embassy_rp::gpio::{Level, Output};
use embassy_rp::peripherals::{DMA_CH0, PIO0};
use embassy_rp::pio::{InterruptHandler, Pio};
use embassy_time::Duration;
use embedded_io_async::Write;
use rand::RngCore;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
@ -40,6 +42,7 @@ async fn main(spawner: Spawner) {
info!("Hello World!");
let p = embassy_rp::init(Default::default());
let mut rng = RoscRng;
let fw = include_bytes!("../../../../cyw43-firmware/43439A0.bin");
let clm = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin");
@ -74,7 +77,7 @@ async fn main(spawner: Spawner) {
});
// Generate random seed
let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random.
let seed = rng.next_u64();
// Init network stack
static STACK: StaticCell<Stack<cyw43::NetDriver<'static>>> = StaticCell::new();

View file

@ -13,11 +13,13 @@ use embassy_executor::Spawner;
use embassy_net::tcp::TcpSocket;
use embassy_net::{Config, Stack, StackResources};
use embassy_rp::bind_interrupts;
use embassy_rp::clocks::RoscRng;
use embassy_rp::gpio::{Level, Output};
use embassy_rp::peripherals::{DMA_CH0, PIO0};
use embassy_rp::pio::{InterruptHandler, Pio};
use embassy_time::{Duration, Timer};
use embedded_io_async::Write;
use rand::RngCore;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
@ -43,6 +45,7 @@ async fn main(spawner: Spawner) {
info!("Hello World!");
let p = embassy_rp::init(Default::default());
let mut rng = RoscRng;
let fw = include_bytes!("../../../../cyw43-firmware/43439A0.bin");
let clm = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin");
@ -77,7 +80,7 @@ async fn main(spawner: Spawner) {
//});
// Generate random seed
let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random.
let seed = rng.next_u64();
// Init network stack
static STACK: StaticCell<Stack<cyw43::NetDriver<'static>>> = StaticCell::new();

View file

@ -14,10 +14,12 @@ use embassy_net::dns::DnsSocket;
use embassy_net::tcp::client::{TcpClient, TcpClientState};
use embassy_net::{Config, Stack, StackResources};
use embassy_rp::bind_interrupts;
use embassy_rp::clocks::RoscRng;
use embassy_rp::gpio::{Level, Output};
use embassy_rp::peripherals::{DMA_CH0, PIO0};
use embassy_rp::pio::{InterruptHandler, Pio};
use embassy_time::{Duration, Timer};
use rand::RngCore;
use reqwless::client::{HttpClient, TlsConfig, TlsVerify};
use reqwless::request::Method;
use serde::Deserialize;
@ -46,6 +48,7 @@ async fn main(spawner: Spawner) {
info!("Hello World!");
let p = embassy_rp::init(Default::default());
let mut rng = RoscRng;
let fw = include_bytes!("../../../../cyw43-firmware/43439A0.bin");
let clm = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin");
@ -80,7 +83,7 @@ async fn main(spawner: Spawner) {
//});
// Generate random seed
let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random.
let seed = rng.next_u64();
// Init network stack
static STACK: StaticCell<Stack<cyw43::NetDriver<'static>>> = StaticCell::new();