Initialize UART serial
This commit is contained in:
+15
-1
@@ -10,10 +10,13 @@
|
||||
use defmt::info;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::Timer;
|
||||
use embedded_io::Write;
|
||||
use esp_hal::Blocking;
|
||||
use esp_hal::clock::CpuClock;
|
||||
use esp_hal::spi::master::{Spi, Config as SpiConfig};
|
||||
use esp_hal::time::Rate;
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use esp_hal::uart::{Config, Uart};
|
||||
use ws2812_rs::{WS2812SPI, SendColorBySPI, Color};
|
||||
|
||||
#[panic_handler]
|
||||
@@ -54,6 +57,9 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let led = WS2812SPI::new(spi);
|
||||
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!");
|
||||
|
||||
// Idle forever
|
||||
@@ -63,7 +69,7 @@ async fn main(spawner: Spawner) -> ! {
|
||||
}
|
||||
|
||||
#[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 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;
|
||||
}
|
||||
}
|
||||
|
||||
#[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