Zero span improvements

This commit is contained in:
Jan Käberich 2022-06-22 23:00:09 +02:00
parent 6393ae7fc3
commit 7151fffcdb
3 changed files with 6 additions and 7 deletions

View file

@ -9,7 +9,7 @@ void Delay::Init() {
// enable update interrupt
TIM1->DIER |= TIM_DIER_UIE;
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 0, 0);
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 6, 0);
HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn);
TIM1->CR1 |= TIM_CR1_CEN;
@ -36,8 +36,8 @@ void Delay::ms(uint32_t t) {
}
}
void Delay::us(uint32_t t) {
uint64_t start = get_us();
while(start + t > get_us());
uint64_t start = TIM1->CNT;
while(TIM1->CNT - start < t);
}
extern "C" {