clarifications and minor changes in slow clock related operations:
* SpinDelay and SpinDelayUs: now rounding applies instead of truncating * Document maximum duration of SpinDelay/SpinDelayUs/BUTTON_CLICK/BUTTON_HELD * Add argument check against max duration in SpinDelay/BUTTON_CLICK/BUTTON_HELD * Document why these functions don't need to take wrapping into acount as in GetTickCountDelta * Use >= in the spinning loops * Clarify StartTickCount calibration operations and use masks AT91C_CKGR_MAINRDY and AT91C_RTTC_RTPRES
This commit is contained in:
@@ -446,9 +446,11 @@ AT91S_CDC_LINE_CODING line = { // purely informative, actual values don't matter
|
||||
8 // 8 Data bits
|
||||
};
|
||||
|
||||
// timer counts in 21.3uS increments (1024/48Mhz), rounding applies
|
||||
// WARNING: timer can't measure more than 1.39s (21.3uS * 0xffff)
|
||||
static void SpinDelay(int ms) {
|
||||
int us = ms * 1000;
|
||||
int ticks = (48 * us) >> 10;
|
||||
int ticks = (48 * us + 512) >> 10;
|
||||
|
||||
// Borrow a PWM unit for my real-time clock
|
||||
AT91C_BASE_PWMC->PWMC_ENA = PWM_CHANNEL(0);
|
||||
|
||||
Reference in New Issue
Block a user