1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Inline asm for msp430 is gated behind this nightly feature (used by
// `delay` for its cycle-accurate busy-loop).
/// Boot front door: optionally stop the watchdog, then take the PAC
/// peripherals — **in that order, guaranteed by construction**.
///
/// The two steps are order-sensitive: the watchdog powers up running as a
/// ~32 ms fuse, and `Peripherals::take()` enters a critical section, so the
/// stop must come first (see [`watchdog`]). Written as two statements in every
/// binary, nothing stops a future `main` from swapping them; fused here, the
/// ordering cannot be gotten wrong at a call site. Make this the first
/// statement in `main`:
///
/// ```ignore
/// #[entry]
/// fn main() -> ! {
/// let p = hal::init(hal::watchdog::WdtMode::Hold).unwrap();
/// // ...
/// }
/// ```
///
/// The three policies (see [`watchdog::WdtMode`]): `Hold` stops the watchdog,
/// `Arm { source, interval }` installs a fresh timeout so boot itself runs
/// guarded, and `LeaveRunning` performs no `WDTCTL` write at all.
///
/// Returns what `Peripherals::take()` returns: `Some` on the first call,
/// `None` after (the watchdog policy is still applied either way).
///
/// Gated on the `critical-section` feature for the same reason the PAC gates
/// `Peripherals::take()` on it: `take()` only exists when a critical-section
/// implementation is available (see the `msp430` crate's
/// `critical-section-single-core`). Without the feature there is no safe
/// `take` to fuse with, so there is no `init` either — use
/// [`watchdog::disable`] and `Peripherals::steal()` manually in that world.
pub use embedded_hal;
pub use embedded_hal_nb;
pub use embedded_io;
pub use embedded_storage;
pub use pac;
/// Interrupt vector names for use with msp430-rt's `#[interrupt]` attribute.
///
/// msp430-rt's `#[interrupt]` macro validates the handler's name against a
/// `interrupt::<NAME>` path (e.g. `interrupt::TIMER0_A1`). The PAC exposes these
/// as variants of `pac::Interrupt` rather than as a module, so this shim
/// re-exports them under the `interrupt` path the macro expects. Bring it into
/// scope (`use hal::interrupt;`) alongside the `#[msp430_rt::interrupt]`
/// attribute when defining an ISR.