Expand description
API for the CTIMER peripheral
Currently, only PWM output functionality is implemented.
§Example
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);
}
}Re-exports§
pub use self::channel::Channel;
Modules§
- channel
- Contains types related to CTIMER PWM channels
Structs§
- CTIMER
- Interface to a CTimer peripheral
- Channel1
- Identifies a CTIMER PWM channel
- Channel2
- Identifies a CTIMER PWM channel
- Channel3
- Identifies a CTIMER PWM channel
- Channels
- Contains all CTIMER PWM channels
Enums§
- Channels1
- The available channels, if only channel 1 is attached
- Channels12
- The available channels, if only channels 1 and 2 are attached
- Channels123
- The available channels, if channels 1, 2, and 2 are attached