fix unwanted timer restart

This commit is contained in:
marqs 2024-07-14 22:30:38 +03:00
parent e4cec87bec
commit 7f75717ecb
2 changed files with 3 additions and 3 deletions

View File

@ -1235,8 +1235,9 @@ int main()
while (alt_timestamp() < start_ts + MAINLOOP_INTERVAL_US*(TIMER_0_FREQ/1000000)) {}
// restart timer if past half-range
if (start_ts > 0x7fffffff) {
if ((start_ts > 0x7fffffff) && !SPI_Timer_Status()) {
alt_timestamp_start();
SPI_Timer_Off();
if (auto_input_timestamp > start_ts)
auto_input_timestamp -= start_ts;
else

View File

@ -58,8 +58,7 @@ inline void SPI_Freq_Low (void) {
int SPI_Timer_On (WORD ms) {
if (!sd_timer_ts) {
sd_timer_ts = ms*(ALT_CPU_FREQ/1000);
alt_timestamp_start();
sd_timer_ts = alt_timestamp() + ms*(TIMER_0_FREQ/1000);
return 0;
}
return 1;