-
Notifications
You must be signed in to change notification settings - Fork 8
Clean up CTIMER; implement embedded_hal::Pwm
#291
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 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
b28e26b
Fix typo
hannobraun a61ef34
Add some whitespace
hannobraun c310b0d
Group structs and their implementation
hannobraun a15e2a0
Rename `CTimer` to `CTIMER`
hannobraun b7151d3
Rename struct field
hannobraun 7573aa0
Define PWM output function via channel trait
hannobraun e879d9b
Add constructor for `DetachedPwmPin`
hannobraun 791294e
Replace `DetachedPwmPin` with new `Channel` struct
hannobraun 27f5c42
Rename type parameter
hannobraun a12092b
Replace `CTimerPwmPin` with `Channel`
hannobraun 9c901f8
Rename struct field
hannobraun cfbfd2e
Remove `number` field of `Channel`
hannobraun e33cf54
Seal `channels::Trait`
hannobraun 6071839
Generate `Channels` struct
hannobraun d9f8cff
Add type state to `CTIMER`
hannobraun 3912f61
Rename method
hannobraun 7e53668
Move `reg!` invocations to where they are used
hannobraun 15a2833
Make freeing `CTIMER` possible in any state
hannobraun b553963
Make uses of channel state more compact
hannobraun 9080fd3
Add peripheral state to `Channel`
hannobraun 3b6e455
Add `Channels` field to `CTIMER`
hannobraun de6c9c4
Add `CTIMER::disable`
hannobraun b6f61fc
Move `attach` method from `Channel` to `CTIMER`
hannobraun 923fa1f
Rename struct field
hannobraun 973b691
Move `CTIMER` to `ctimer::peripheral`
hannobraun 0b376fc
Move generated CTIMER types to dedicated module
hannobraun 1ef1f29
Rename module
hannobraun 3419597
Re-export `Channel` from `ctimer`, for convenience
hannobraun 8c01187
Refactor
hannobraun e4763ab
Set CTIMER period in private method
hannobraun f5b9c80
Implement `embedded_hal::Pwm` for `CTIMER`
hannobraun 4c1f602
Implement embedded-hal alpha traits for CTIMER
hannobraun a6d9d58
Fix `set_period` sometimes breaking PWM for a bit
hannobraun 5aa1caf
Add example to demonstrate `set_period`
hannobraun 0c6553b
Improve documentation
hannobraun 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| //! API for the CTimer peripheral | ||
| //! | ||
| //! Currently, only PWM output functionality is implemented. | ||
| //! | ||
| //! # Example | ||
| //! | ||
| //! ```no_run | ||
| //! use lpc8xx_hal::{ | ||
| //! delay::Delay, | ||
| //! prelude::*, | ||
| //! Peripherals, | ||
| //! pac::CorePeripherals, | ||
| //! }; | ||
| //! | ||
| //! let cp = CorePeripherals::take().unwrap(); | ||
| //! let p = Peripherals::take().unwrap(); | ||
| //! | ||
| //! let swm = p.SWM.split(); | ||
| //! let mut delay = Delay::new(cp.SYST); | ||
| //! let mut syscon = p.SYSCON.split(); | ||
| //! | ||
| //! let mut swm_handle = swm.handle.enable(&mut syscon.handle); | ||
| //! | ||
| //! let pwm_output = p.pins.pio1_2.into_swm_pin(); | ||
| //! | ||
| //! let (pwm_output, _) = swm.movable_functions.t0_mat0.assign( | ||
| //! pwm_output, | ||
| //! &mut swm_handle, | ||
| //! ); | ||
| //! | ||
| //! // Use 8 bit pwm | ||
| //! let ctimer = p.CTIMER0 | ||
| //! .enable(256, 0, &mut syscon.handle) | ||
| //! .attach(pwm_output); | ||
| //! | ||
| //! let mut pwm_pin = ctimer.channels.channel1; | ||
| //! loop { | ||
| //! for i in 0..pwm_pin.get_max_duty() { | ||
| //! delay.delay_ms(4_u8); | ||
| //! pwm_pin.set_duty(i); | ||
| //! } | ||
| //! } | ||
| //! ``` | ||
|
|
||
| pub mod channels; | ||
|
|
||
| mod peripheral; | ||
|
|
||
| pub use self::peripheral::CTIMER; | ||
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
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.