13 lines
429 B
Rust
13 lines
429 B
Rust
use arduino_hal::pac::TC0;
|
|
|
|
pub fn segment_timer_init(tc0: TC0, counts: u8) {
|
|
// Use CTC mode: reset counter when matches compare value
|
|
tc0.tccr0a.write(|w| w.wgm0().ctc());
|
|
// Set the compare value
|
|
tc0.ocr0a.write(|w| w.bits(counts));
|
|
// Slow down the timer (CLK / prescale)
|
|
tc0.tccr0b.write(|w| w.cs0().prescale_1024());
|
|
// Raise interrupt on reset
|
|
tc0.timsk0.write(|w| w.ocie0a().set_bit());
|
|
}
|