atmega_hal/
wdt.rs

1#[allow(unused_imports)]
2pub use avr_hal_generic::wdt::{Timeout, WdtOps};
3
4pub type Wdt = avr_hal_generic::wdt::Wdt<crate::Atmega, crate::pac::WDT>;
5
6#[cfg(not(any(
7    feature = "atmega8",
8    feature = "atmega16",
9    feature = "atmega32a",
10    feature = "atmega128a"
11)))]
12avr_hal_generic::impl_wdt! {
13    hal: crate::Atmega,
14    peripheral: crate::pac::WDT,
15    mcusr: crate::pac::cpu::MCUSR,
16    wdtcsr_name: wdtcsr,
17    timeout: |to, w| match to {
18        Timeout::Ms16 => w.wdpl().cycles_2k_512k(),
19        Timeout::Ms32 => w.wdpl().cycles_4k_1024k(),
20        Timeout::Ms64 => w.wdpl().cycles_8k(),
21        Timeout::Ms125 => w.wdpl().cycles_16k(),
22        Timeout::Ms250 => w.wdpl().cycles_32k(),
23        Timeout::Ms500 => w.wdpl().cycles_64k(),
24        Timeout::Ms1000 => w.wdpl().cycles_128k(),
25        Timeout::Ms2000 => w.wdpl().cycles_256k(),
26        Timeout::Ms4000 => w.wdph().set_bit().wdpl().cycles_2k_512k(),
27        Timeout::Ms8000 => w.wdph().set_bit().wdpl().cycles_4k_1024k(),
28    },
29}
30
31#[cfg(any(feature = "atmega8", feature = "atmega32a", feature = "atmega128a"))]
32avr_hal_generic::impl_wdt! {
33    hal: crate::Atmega,
34    peripheral: crate::pac::WDT,
35    mcusr: crate::pac::cpu::MCUCSR,
36    wdtcsr_name: wdtcr,
37    timeout: |to, w| match to {
38        Timeout::Ms16 => w.wdpl().cycles_16k(),
39        Timeout::Ms32 => w.wdpl().cycles_32k(),
40        Timeout::Ms64 => w.wdpl().cycles_64k(),
41        Timeout::Ms125 => w.wdpl().cycles_128k(),
42        Timeout::Ms250 => w.wdpl().cycles_256k(),
43        Timeout::Ms500 => w.wdpl().cycles_512k(),
44        Timeout::Ms1000 => w.wdpl().cycles_1024k(),
45        Timeout::Ms2000 => w.wdpl().cycles_2048k(),
46        Timeout::Ms4000 => panic!(), // Does not exist for ATmega8 ...
47        Timeout::Ms8000 => panic!() // Does not exist for ATmega8 ...
48    },
49}