Alternate LED state to demonstrate HW bringup
This commit is contained in:
Generated
+11
@@ -1092,6 +1092,7 @@ dependencies = [
|
|||||||
"esp-rtos",
|
"esp-rtos",
|
||||||
"rtt-target",
|
"rtt-target",
|
||||||
"static_cell",
|
"static_cell",
|
||||||
|
"ws2812-rs",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1570,6 +1571,16 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ws2812-rs"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a31238e916943f43bc2cc4572e121688091483c89b31eec5e861f54853d60a4d"
|
||||||
|
dependencies = [
|
||||||
|
"embassy-time",
|
||||||
|
"embedded-hal 1.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xtensa-lx"
|
name = "xtensa-lx"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
|
|||||||
@@ -28,6 +28,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"
|
||||||
|
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|||||||
+15
-5
@@ -11,7 +11,10 @@ use defmt::info;
|
|||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use esp_hal::clock::CpuClock;
|
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::timer::timg::TimerGroup;
|
||||||
|
use ws2812_rs::{WS2812SPI, SendColorBySPI, Color};
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(_: &core::panic::PanicInfo) -> ! {
|
fn panic(_: &core::panic::PanicInfo) -> ! {
|
||||||
@@ -42,15 +45,22 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||||
esp_rtos::start(timg0.timer0);
|
esp_rtos::start(timg0.timer0);
|
||||||
|
|
||||||
info!("Embassy initialized!");
|
|
||||||
|
|
||||||
// TODO: Spawn some tasks
|
// TODO: Spawn some tasks
|
||||||
let _ = spawner;
|
let _ = spawner;
|
||||||
|
|
||||||
|
const LED_SPI_HZ: u32 = 3_200_000;
|
||||||
|
let spi = Spi::new(peripherals.SPI2,
|
||||||
|
SpiConfig::default().with_frequency(Rate::from_hz(LED_SPI_HZ)))
|
||||||
|
.unwrap()
|
||||||
|
.with_mosi(peripherals.GPIO48);
|
||||||
|
let mut led = WS2812SPI::new(spi);
|
||||||
|
|
||||||
|
info!("Padmapper initialized!");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
info!("Hello world!");
|
led.color_send_by_spi(Color([0, 0, 8]), LED_SPI_HZ).unwrap();
|
||||||
|
Timer::after(Duration::from_secs(1)).await;
|
||||||
|
led.color_send_by_spi(Color([8, 0, 8]), LED_SPI_HZ).unwrap();
|
||||||
Timer::after(Duration::from_secs(1)).await;
|
Timer::after(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0/examples
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user