-
Notifications
You must be signed in to change notification settings - Fork 368
Add SYSTIMER ETM #828
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
+150
−2
Merged
Add SYSTIMER ETM #828
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Next
Next commit
Add SYSTIMER ETM
- Loading branch information
commit fd46802be2c0eba00b577a57cdc1f355f33b7084
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,45 @@ | ||
| //! Control LED on GPIO 1 by the systimer via ETM | ||
|
|
||
| #![no_std] | ||
| #![no_main] | ||
|
|
||
| use esp32c6_hal::{ | ||
| clock::ClockControl, | ||
| etm::Etm, | ||
| gpio::{etm::GpioEtmChannels, IO}, | ||
| peripherals::Peripherals, | ||
| prelude::*, | ||
| systimer::{etm::SysTimerEtmEvent, SystemTimer}, | ||
| }; | ||
| use esp_backtrace as _; | ||
|
|
||
| #[entry] | ||
| fn main() -> ! { | ||
| esp_println::logger::init_logger_from_env(); | ||
| let peripherals = Peripherals::take(); | ||
| let system = peripherals.PCR.split(); | ||
| let _clocks = ClockControl::boot_defaults(system.clock_control).freeze(); | ||
|
|
||
| let syst = SystemTimer::new(peripherals.SYSTIMER); | ||
| let mut alarm0 = syst.alarm0.into_periodic(); | ||
| alarm0.set_period(1u32.secs()); | ||
|
|
||
| let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); | ||
| let mut led = io.pins.gpio1.into_push_pull_output(); | ||
|
|
||
| // setup ETM | ||
| let gpio_ext = GpioEtmChannels::new(peripherals.GPIO_SD); | ||
| let led_task = gpio_ext.channel0_task.toggle(&mut led); | ||
|
|
||
| let timer_event = SysTimerEtmEvent::new(&mut alarm0); | ||
|
|
||
| let etm = Etm::new(peripherals.SOC_ETM); | ||
| let channel0 = etm.channel0; | ||
|
|
||
| // make sure the configured channel doesn't get dropped - dropping it will | ||
| // disable the channel | ||
| let _configured_channel = channel0.setup(&timer_event, &led_task); | ||
|
|
||
| // the LED is controlled by the timer without involving the CPU | ||
| loop {} | ||
| } | ||
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 @@ | ||
| //! Control LED on GPIO 1 by the systimer via ETM | ||
|
|
||
| #![no_std] | ||
| #![no_main] | ||
|
|
||
| use esp32h2_hal::{ | ||
| clock::ClockControl, | ||
| etm::Etm, | ||
| gpio::{etm::GpioEtmChannels, IO}, | ||
| peripherals::Peripherals, | ||
| prelude::*, | ||
| systimer::{etm::SysTimerEtmEvent, SystemTimer}, | ||
| }; | ||
| use esp_backtrace as _; | ||
|
|
||
| #[entry] | ||
| fn main() -> ! { | ||
| esp_println::logger::init_logger_from_env(); | ||
| let peripherals = Peripherals::take(); | ||
| let system = peripherals.PCR.split(); | ||
| let _clocks = ClockControl::boot_defaults(system.clock_control).freeze(); | ||
|
|
||
| let syst = SystemTimer::new(peripherals.SYSTIMER); | ||
| let mut alarm0 = syst.alarm0.into_periodic(); | ||
| alarm0.set_period(1u32.secs()); | ||
|
|
||
| let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); | ||
| let mut led = io.pins.gpio1.into_push_pull_output(); | ||
|
|
||
| // setup ETM | ||
| let gpio_ext = GpioEtmChannels::new(peripherals.GPIO_SD); | ||
| let led_task = gpio_ext.channel0_task.toggle(&mut led); | ||
|
|
||
| let timer_event = SysTimerEtmEvent::new(&mut alarm0); | ||
|
|
||
| let etm = Etm::new(peripherals.SOC_ETM); | ||
| let channel0 = etm.channel0; | ||
|
|
||
| // make sure the configured channel doesn't get dropped - dropping it will | ||
| // disable the channel | ||
| let _configured_channel = channel0.setup(&timer_event, &led_task); | ||
|
|
||
| // the LED is controlled by the timer without involving the CPU | ||
| loop {} | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put these behind a
#[cfg(feature = "log")]. I just cleaned up like 26 of these in #810 and that isn't a fun activityThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please add the examples to CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I keep forgetting about the log vs defmt thing 👍 most probably will just remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally this should fail in CI but these examples aren't checked (yet) ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do
cargo build --examples? there are no features needed so it should build itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True enough. esp-println's
logis currently enabled by default right now which makes this pass...