refactoring
This commit is contained in:
@@ -5,10 +5,6 @@ const TIMER_PRESCALE: u32 = 64;
|
||||
// Timer clock tick rate per second
|
||||
const TIMER_FREQ: u32 = DefaultClock::FREQ / TIMER_PRESCALE;
|
||||
|
||||
// How much time in μs to reserve for post LED off operation (keyboard read)
|
||||
const BUFFER_US: u32 = 250;
|
||||
const BUFFER_TICKS: u32 = us_to_ticks(BUFFER_US);
|
||||
|
||||
const fn us_to_ticks(us: u32) -> u32 {
|
||||
TIMER_FREQ * us / 1_000_000
|
||||
}
|
||||
@@ -46,12 +42,7 @@ impl SegmentTimer {
|
||||
// Set for how long the segment LEDs should be on in μs
|
||||
// Controls TIMER0_COMPB interrupt time after TIMER0_COMPA
|
||||
pub fn segment_on_time(&mut self, segment_on_us: u32) {
|
||||
let ocra = self.0.ocr0a.read().bits();
|
||||
let ocrb = us_to_ticks(segment_on_us);
|
||||
assert!(
|
||||
ocra as u32 > ocrb + BUFFER_TICKS,
|
||||
"segment_on_us cannot be longer than segment_switch_us - buffer"
|
||||
);
|
||||
// Set the compare value for B match
|
||||
self.0.ocr0b.write(|w| {
|
||||
w.bits(
|
||||
|
||||
Reference in New Issue
Block a user