Reduce display startup time

This commit is contained in:
2023-03-17 17:50:00 +01:00
parent 98f4a1d0ad
commit 7e4bc54266
10 changed files with 172 additions and 12 deletions

29
Core/Src/shorttimer.c Normal file
View File

@ -0,0 +1,29 @@
#include "shorttimer.h"
#include "stm32h7xx_hal.h"
#include "stm32h7xx_hal_tim.h"
#include <stdint.h>
static TIM_HandleTypeDef *htim;
static uint32_t ticks;
void shorttimer_init(TIM_HandleTypeDef *handle) {
htim = handle;
ticks = 0;
HAL_TIM_Base_Start_IT(htim);
}
uint32_t shorttimer_gettick(void) { return ticks; }
void shorttimer_sleep(uint32_t microseconds) {
volatile uint32_t start = shorttimer_gettick();
// Add another tick to guarantee a minimum wait
if (microseconds < UINT32_MAX) {
microseconds++;
}
while (shorttimer_gettick() - start < microseconds) {
}
}
void shorttimer_callback() { ticks++; }