| 1 | use embassy_stm32::{ |
| 2 | Peri, gpio::{AnyPin, Level, Output, Speed}, lptim::pwm::Pwm |
| 3 | }; |
| 4 | use embassy_sync::{blocking_mutex::raw::ThreadModeRawMutex, mutex::Mutex}; |
| 5 | use embassy_time::Timer; |
| 6 | |
| 7 | pub enum SystemStatus { |
| 8 | OK, |
| 9 | FAIL, |
| 10 | } |
| 11 | |
| 12 | pub type SharedStatus = Mutex<ThreadModeRawMutex, SystemStatus>; |
| 13 | |
| 14 | #[embassy_executor::task] |
| 15 | pub async fn status_leds( |
| 16 | led_ok_pin: Peri<'static, AnyPin>, |
| 17 | led_fail_pin: Peri<'static, AnyPin>, |
| 18 | status: &'static SharedStatus, |
| 19 | ) { |
| 20 | let mut led_ok = Output::new(led_ok_pin, Level::Low, Speed::Low); |
| 21 | let mut led_fail = Output::new(led_fail_pin, Level::Low, Speed::Low); |
| 22 | |
| 23 | loop { |
| 24 | led_ok.set_high(); |
| 25 | led_fail.set_low(); |
| 26 | Timer::after_millis(500).await; |
| 27 | led_ok.set_low(); |
| 28 | led_fail.set_high(); |
| 29 | Timer::after_millis(500).await; |
| 30 | } |
| 31 | } |
| 32 | |