mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-11 13:01:30 +11:00
Added so stopped PIO state machines can change their clock divider
This commit is contained in:
parent
212ffec6ca
commit
b7e56d0869
|
@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- None
|
- Stopped PIO state machines can change their clock divider
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -559,6 +559,22 @@ impl<SM: ValidStateMachine> StateMachine<SM, Stopped> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Change the clock divider of a stopped state machine.
|
||||||
|
pub fn set_clock_divisor(&mut self, divisor: f32) {
|
||||||
|
// sm frequency = clock freq / (CLKDIV_INT + CLKDIV_FRAC / 256)
|
||||||
|
let int = divisor as u16;
|
||||||
|
let frac = ((divisor - int as f32) * 256.0) as u8;
|
||||||
|
|
||||||
|
self.sm.sm().sm_clkdiv.write(|w| {
|
||||||
|
unsafe {
|
||||||
|
w.int().bits(int);
|
||||||
|
w.frac().bits(frac);
|
||||||
|
}
|
||||||
|
|
||||||
|
w
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the pin state for the specified pins.
|
/// Sets the pin state for the specified pins.
|
||||||
///
|
///
|
||||||
/// The user has to make sure that they do not select any pins that are in use by any
|
/// The user has to make sure that they do not select any pins that are in use by any
|
||||||
|
|
Loading…
Reference in a new issue