|
6 | 6 | holding buffers for the duration of a data transfer." |
7 | 7 | )] |
8 | 8 |
|
| 9 | +use core::time::Duration; |
| 10 | + |
9 | 11 | use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; |
10 | 12 | use embassy_executor::Spawner; |
11 | 13 | use embassy_net::StackResources; |
@@ -71,6 +73,15 @@ async fn main(spawner: Spawner) -> ! { |
71 | 73 | let timg0 = TimerGroup::new(peripherals.TIMG0); |
72 | 74 | esp_rtos::start(timg0.timer0); |
73 | 75 |
|
| 76 | + let mut timg1 = TimerGroup::new(peripherals.TIMG1); |
| 77 | + let mut watchdog = timg1.wdt; |
| 78 | + let watchdog_timeout = Duration::from_secs(CONFIG.main_task_dur_secs); |
| 79 | + let _ = watchdog.start(watchdog_timeout); |
| 80 | + info!( |
| 81 | + "Main watchdog configured for {} seconds", |
| 82 | + CONFIG.main_task_dur_secs |
| 83 | + ); |
| 84 | + |
74 | 85 | // Init wifi |
75 | 86 | let radio_init = mk_static!( |
76 | 87 | Controller<'static>, |
@@ -146,7 +157,12 @@ async fn main(spawner: Spawner) -> ! { |
146 | 157 | spawner.spawn(anemo_task(anemo_pin, sender_anemo)).ok(); |
147 | 158 | spawner.spawn(as5600_task(as_i2c, sender_as5600)).ok(); |
148 | 159 | spawner.spawn(ina210_task(ina_i2c, sender_ina219)).ok(); |
149 | | - Timer::after_secs(CONFIG.main_task_dur_secs).await; |
| 160 | + |
| 161 | + for _ in 0..CONFIG.main_task_dur_secs as usize { |
| 162 | + Timer::after_secs(1).await; |
| 163 | + watchdog.feed(); |
| 164 | + } |
| 165 | + let _ = watchdog.disable(); |
150 | 166 |
|
151 | 167 | info!("Going to sleep..."); |
152 | 168 | transistor_pin.set_low(); |
|
0 commit comments