Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b28e26b
Fix typo
hannobraun Oct 24, 2020
a61ef34
Add some whitespace
hannobraun Oct 24, 2020
c310b0d
Group structs and their implementation
hannobraun Oct 24, 2020
a15e2a0
Rename `CTimer` to `CTIMER`
hannobraun Oct 24, 2020
b7151d3
Rename struct field
hannobraun Oct 24, 2020
7573aa0
Define PWM output function via channel trait
hannobraun Oct 24, 2020
e879d9b
Add constructor for `DetachedPwmPin`
hannobraun Oct 24, 2020
791294e
Replace `DetachedPwmPin` with new `Channel` struct
hannobraun Oct 24, 2020
27f5c42
Rename type parameter
hannobraun Oct 24, 2020
a12092b
Replace `CTimerPwmPin` with `Channel`
hannobraun Oct 24, 2020
9c901f8
Rename struct field
hannobraun Oct 24, 2020
cfbfd2e
Remove `number` field of `Channel`
hannobraun Oct 24, 2020
e33cf54
Seal `channels::Trait`
hannobraun Oct 24, 2020
6071839
Generate `Channels` struct
hannobraun Oct 24, 2020
d9f8cff
Add type state to `CTIMER`
hannobraun Oct 24, 2020
3912f61
Rename method
hannobraun Oct 24, 2020
7e53668
Move `reg!` invocations to where they are used
hannobraun Oct 24, 2020
15a2833
Make freeing `CTIMER` possible in any state
hannobraun Oct 24, 2020
b553963
Make uses of channel state more compact
hannobraun Oct 24, 2020
9080fd3
Add peripheral state to `Channel`
hannobraun Oct 24, 2020
3b6e455
Add `Channels` field to `CTIMER`
hannobraun Oct 24, 2020
de6c9c4
Add `CTIMER::disable`
hannobraun Oct 24, 2020
b6f61fc
Move `attach` method from `Channel` to `CTIMER`
hannobraun Oct 24, 2020
923fa1f
Rename struct field
hannobraun Oct 24, 2020
973b691
Move `CTIMER` to `ctimer::peripheral`
hannobraun Oct 24, 2020
0b376fc
Move generated CTIMER types to dedicated module
hannobraun Oct 24, 2020
1ef1f29
Rename module
hannobraun Oct 24, 2020
3419597
Re-export `Channel` from `ctimer`, for convenience
hannobraun Oct 24, 2020
8c01187
Refactor
hannobraun Oct 24, 2020
e4763ab
Set CTIMER period in private method
hannobraun Oct 24, 2020
f5b9c80
Implement `embedded_hal::Pwm` for `CTIMER`
hannobraun Oct 24, 2020
4c1f602
Implement embedded-hal alpha traits for CTIMER
hannobraun Oct 24, 2020
a6d9d58
Fix `set_period` sometimes breaking PWM for a bit
hannobraun Oct 26, 2020
5aa1caf
Add example to demonstrate `set_period`
hannobraun Oct 26, 2020
0c6553b
Improve documentation
hannobraun Oct 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/ctimer/mod.rs
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;
49 changes: 2 additions & 47 deletions src/ctimer.rs → src/ctimer/peripheral.rs
Original file line number Diff line number Diff line change
@@ -1,56 +1,11 @@
//! 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;

use crate::{
init_state::{Disabled, Enabled},
pac::CTIMER0,
swm, syscon,
};

use self::channels::{
use super::channels::{
self,
state::{Attached, Detached},
Channel1, Channel2, Channel3, Channels,
};
Expand Down