-
Notifications
You must be signed in to change notification settings - Fork 367
Do not reset UsbSerialJtag peripheral
#1961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a93e8c6
Fix typos
bugadani c5a8401
Add a function to detect debugger connection
bugadani 1cbe043
Do not reset USB peripheral
bugadani ff890cd
Changelog
bugadani 5499528
Fix different register names
bugadani 3b1f049
Reuse xtensa_lx::is_debugger_attached
bugadani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,36 @@ | ||
| //! Debugger utilities | ||
|
|
||
| /// Checks if a debugger is connected. | ||
| pub fn debugger_connected() -> bool { | ||
| #[cfg(xtensa)] | ||
| { | ||
| xtensa_lx::is_debugger_attached() | ||
| } | ||
|
|
||
| #[cfg(riscv)] | ||
| { | ||
| use crate::peripherals::ASSIST_DEBUG; | ||
| let assist_debug = unsafe { &*ASSIST_DEBUG::ptr() }; | ||
| #[cfg(feature = "esp32c2")] | ||
| { | ||
| assist_debug | ||
| .core_0_debug_mode() | ||
| .read() | ||
| .core_0_debug_module_active() | ||
| .bit_is_set() | ||
| } | ||
| #[cfg(not(feature = "esp32c2"))] | ||
| { | ||
| assist_debug | ||
| .c0re_0_debug_mode() | ||
bugadani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .read() | ||
| .core_0_debug_module_active() | ||
| .bit_is_set() | ||
| } | ||
| } | ||
|
|
||
| #[cfg(not(any(xtensa, riscv)))] | ||
| { | ||
| false | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,45 @@ | ||
| //! USB Serial JTAG tests | ||
|
|
||
| //% CHIPS: esp32c3 esp32c6 esp32h2 esp32s3 | ||
|
|
||
| #![no_std] | ||
| #![no_main] | ||
|
|
||
| #[cfg(test)] | ||
| #[embedded_test::tests] | ||
| mod tests { | ||
| use defmt_rtt as _; | ||
| use esp_backtrace as _; | ||
| use esp_hal::{ | ||
| clock::ClockControl, | ||
| peripherals::Peripherals, | ||
| system::SystemControl, | ||
| timer::{timg::TimerGroup, ErasedTimer, OneShotTimer}, | ||
| usb_serial_jtag::UsbSerialJtag, | ||
| }; | ||
|
|
||
| // When you are okay with using a nightly compiler it's better to use https://docs.rs/static_cell/2.1.0/static_cell/macro.make_static.html | ||
| macro_rules! mk_static { | ||
| ($t:ty,$val:expr) => {{ | ||
| static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new(); | ||
| #[deny(unused_attributes)] | ||
| let x = STATIC_CELL.uninit().write(($val)); | ||
| x | ||
| }}; | ||
| } | ||
|
|
||
| #[test] | ||
| fn creating_peripheral_does_not_break_debug_connection() { | ||
| let peripherals = Peripherals::take(); | ||
| let system = SystemControl::new(peripherals.SYSTEM); | ||
| let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); | ||
|
|
||
| let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks); | ||
| let timer0: ErasedTimer = timg0.timer0.into(); | ||
| let timers = [OneShotTimer::new(timer0)]; | ||
| let timers = mk_static!([OneShotTimer<ErasedTimer>; 1], timers); | ||
| esp_hal_embassy::init(&clocks, timers); | ||
|
|
||
| _ = UsbSerialJtag::new_async(peripherals.USB_DEVICE).split(); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.