Merge pull request #862 from keyboardio/driver/atmega-scanner-adjust-scan-cycle-time

keyscanner::ATmega: Allow setting the scan cycle time at run-time
pull/871/head
Jesse Vincent 4 years ago committed by GitHub
commit 128bbfc38a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -111,10 +111,14 @@ class ATmega: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> {
} }
/* Set up Timer1 for 1700usec */ /* Set up Timer1 for 1700usec */
setScanCycleTime(1700);
}
void setScanCycleTime(uint16_t c) {
TCCR1B = _BV(WGM13); TCCR1B = _BV(WGM13);
TCCR1A = 0; TCCR1A = 0;
const uint32_t cycles = (F_CPU / 2000000) * 1700; const uint32_t cycles = (F_CPU / 2000000) * c;
ICR1 = cycles; ICR1 = cycles;
TCCR1B = _BV(WGM13) | _BV(CS10); TCCR1B = _BV(WGM13) | _BV(CS10);

Loading…
Cancel
Save