-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Grapple-Systems/add-swd-sequence
Add support for SWD sequence
- Loading branch information
Showing
7 changed files
with
336 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "dap-rs" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
edition = "2021" | ||
authors = [ | ||
"Emil Fresk <[email protected]>", | ||
|
@@ -20,6 +20,9 @@ embedded-hal = "1.0.0" | |
replace_with = { version = "0.1.7", default-features = false, features = ["panic_abort"] } | ||
bitflags = "1.3.2" | ||
|
||
[dev-dependencies] | ||
mockall = "0.13.0" | ||
|
||
[dependencies.defmt] | ||
optional = true | ||
version = "0.3" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use crate::{jtag, swd, swj}; | ||
|
||
#[mockall::automock] | ||
pub trait SwdJtagDevice { | ||
// swj | ||
fn high_impedance_mode(&mut self); | ||
fn process_swj_clock(&mut self, max_frequency: u32) -> bool; | ||
fn process_swj_pins(&mut self, output: swj::Pins, mask: swj::Pins, wait_us: u32) -> swj::Pins; | ||
fn process_swj_sequence(&mut self, data: &[u8], nbits: usize); | ||
|
||
// swd | ||
fn read_inner(&mut self, apndp: swd::APnDP, a: swd::DPRegister) -> swd::Result<u32>; | ||
fn write_inner(&mut self, apndp: swd::APnDP, a: swd::DPRegister, data: u32) -> swd::Result<()>; | ||
fn read_sequence(&mut self, num_bits: usize, data: &mut [u8]) -> swd::Result<()>; | ||
fn write_sequence(&mut self, num_bits: usize, data: &[u8]) -> swd::Result<()>; | ||
|
||
// jtag | ||
fn sequences(&mut self, data: &[u8], rxbuf: &mut [u8]) -> u32; | ||
|
||
// swd/jtag | ||
fn set_clock(&mut self, max_frequency: u32) -> bool; | ||
} | ||
|
||
impl swj::Dependencies<Self, Self> for MockSwdJtagDevice { | ||
fn high_impedance_mode(&mut self) { | ||
SwdJtagDevice::high_impedance_mode(self) | ||
} | ||
|
||
fn process_swj_clock(&mut self, max_frequency: u32) -> bool { | ||
SwdJtagDevice::process_swj_clock(self, max_frequency) | ||
} | ||
|
||
fn process_swj_pins(&mut self, output: swj::Pins, mask: swj::Pins, wait_us: u32) -> swj::Pins { | ||
SwdJtagDevice::process_swj_pins(self, output, mask, wait_us) | ||
} | ||
|
||
fn process_swj_sequence(&mut self, data: &[u8], nbits: usize) { | ||
SwdJtagDevice::process_swj_sequence(self, data, nbits) | ||
} | ||
} | ||
|
||
impl swd::Swd<Self> for MockSwdJtagDevice { | ||
const AVAILABLE: bool = true; | ||
|
||
fn set_clock(&mut self, max_frequency: u32) -> bool { | ||
SwdJtagDevice::set_clock(self, max_frequency) | ||
} | ||
|
||
fn read_inner(&mut self, apndp: swd::APnDP, a: swd::DPRegister) -> swd::Result<u32> { | ||
SwdJtagDevice::read_inner(self, apndp, a) | ||
} | ||
|
||
fn write_inner(&mut self, apndp: swd::APnDP, a: swd::DPRegister, data: u32) -> swd::Result<()> { | ||
SwdJtagDevice::write_inner(self, apndp, a, data) | ||
} | ||
|
||
fn read_sequence(&mut self, num_bits: usize, data: &mut [u8]) -> swd::Result<()> { | ||
SwdJtagDevice::read_sequence(self, num_bits, data) | ||
} | ||
|
||
fn write_sequence(&mut self, num_bits: usize, data: &[u8]) -> swd::Result<()> { | ||
SwdJtagDevice::write_sequence(self, num_bits, data) | ||
} | ||
} | ||
|
||
impl jtag::Jtag<MockSwdJtagDevice> for MockSwdJtagDevice { | ||
const AVAILABLE: bool = true; | ||
|
||
fn set_clock(&mut self, max_frequency: u32) -> bool { | ||
SwdJtagDevice::set_clock(self, max_frequency) | ||
} | ||
|
||
fn sequences(&mut self, data: &[u8], rxbuf: &mut [u8]) -> u32 { | ||
SwdJtagDevice::sequences(self, data, rxbuf) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters