Thumbnail

steew/gilgamesh.git

Clone URL: https://git.buni.party/steew/gilgamesh.git

Viewing file on branch master

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