dap_rs/
swj.rs

1use bitflags::bitflags;
2
3bitflags! {
4    /// Pin definitions in the SWJ_Pins command
5    pub struct Pins: u8 {
6        /// SWCLK
7        const SWCLK = 1 << 0;
8        /// SWDIO
9        const SWDIO = 1 << 1;
10        /// TDI
11        const TDI = 1 << 2;
12        /// TDO
13        const TDO = 1 << 3;
14        /// NTRST
15        const NTRST = 1 << 5;
16        /// NRESET
17        const NRESET = 1 << 7;
18    }
19}
20
21// TODO: Change the name? Move it to a different module?
22/// Trait describing the dependencies necessary to yield an instance of
23/// [`crate::Dap`]
24///
25/// User has to provide implementations of SWJ_{Pins, Sequence, Clock} commands
26pub trait Dependencies<SWD, JTAG>: From<SWD> + From<JTAG> {
27    /// Runner for SWJ_Pins commands.
28    fn process_swj_pins(&mut self, output: Pins, mask: Pins, wait_us: u32) -> Pins;
29
30    /// Runner for SWJ_Pins commands.
31    fn process_swj_sequence(&mut self, data: &[u8], nbits: usize);
32
33    /// Set the maximum clock frequency, return `true` if it is valid.
34    fn process_swj_clock(&mut self, max_frequency: u32) -> bool;
35
36    /// Set pins in high impedance mode
37    fn high_impedance_mode(&mut self);
38}