Initialize UART serial
This commit is contained in:
Generated
+1
@@ -1086,6 +1086,7 @@ dependencies = [
|
|||||||
"defmt 1.0.1",
|
"defmt 1.0.1",
|
||||||
"embassy-executor",
|
"embassy-executor",
|
||||||
"embassy-time",
|
"embassy-time",
|
||||||
|
"embedded-io 0.7.1",
|
||||||
"esp-alloc",
|
"esp-alloc",
|
||||||
"esp-bootloader-esp-idf",
|
"esp-bootloader-esp-idf",
|
||||||
"esp-hal",
|
"esp-hal",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ rtt-target = { version = "0.6.2", features = ["defmt"] }
|
|||||||
critical-section = "1.2.0"
|
critical-section = "1.2.0"
|
||||||
static_cell = "2.1.1"
|
static_cell = "2.1.1"
|
||||||
ws2812-rs = "0.3.1"
|
ws2812-rs = "0.3.1"
|
||||||
|
embedded-io = "0.7.1"
|
||||||
|
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|||||||
+15
-1
@@ -10,10 +10,13 @@
|
|||||||
use defmt::info;
|
use defmt::info;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
|
use embedded_io::Write;
|
||||||
|
use esp_hal::Blocking;
|
||||||
use esp_hal::clock::CpuClock;
|
use esp_hal::clock::CpuClock;
|
||||||
use esp_hal::spi::master::{Spi, Config as SpiConfig};
|
use esp_hal::spi::master::{Spi, Config as SpiConfig};
|
||||||
use esp_hal::time::Rate;
|
use esp_hal::time::Rate;
|
||||||
use esp_hal::timer::timg::TimerGroup;
|
use esp_hal::timer::timg::TimerGroup;
|
||||||
|
use esp_hal::uart::{Config, Uart};
|
||||||
use ws2812_rs::{WS2812SPI, SendColorBySPI, Color};
|
use ws2812_rs::{WS2812SPI, SendColorBySPI, Color};
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
@@ -54,6 +57,9 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
let led = WS2812SPI::new(spi);
|
let led = WS2812SPI::new(spi);
|
||||||
spawner.spawn(heartbeat_task(led)).unwrap();
|
spawner.spawn(heartbeat_task(led)).unwrap();
|
||||||
|
|
||||||
|
let uart0: Uart<Blocking> = Uart::new(peripherals.UART0, Config::default()).unwrap();
|
||||||
|
spawner.spawn(serial_task(uart0)).unwrap();
|
||||||
|
|
||||||
info!("Padmapper initialized!");
|
info!("Padmapper initialized!");
|
||||||
|
|
||||||
// Idle forever
|
// Idle forever
|
||||||
@@ -63,7 +69,7 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
async fn heartbeat_task(mut led: WS2812SPI<Spi<'static, esp_hal::Blocking>>) {
|
async fn heartbeat_task(mut led: WS2812SPI<Spi<'static, Blocking>>) {
|
||||||
let on_color = Color([8, 0, 0]);
|
let on_color = Color([8, 0, 0]);
|
||||||
let off_color = Color([0, 0, 0]);
|
let off_color = Color([0, 0, 0]);
|
||||||
|
|
||||||
@@ -78,3 +84,11 @@ async fn heartbeat_task(mut led: WS2812SPI<Spi<'static, esp_hal::Blocking>>) {
|
|||||||
Timer::after_millis(700).await;
|
Timer::after_millis(700).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[embassy_executor::task]
|
||||||
|
async fn serial_task(mut uart: Uart<'static, Blocking>) {
|
||||||
|
loop {
|
||||||
|
let _ = uart.write_all(b"Hello from Padmapper!\r\n").unwrap();
|
||||||
|
Timer::after_secs(1).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user