add firmware

This commit is contained in:
Dana Markova
2025-07-28 12:43:33 +03:00
parent 6cf2747ec9
commit 748830dfb7
84 changed files with 40709 additions and 0 deletions

36
drv/tick.cpp Normal file
View File

@ -0,0 +1,36 @@
#include "stm32g4xx.h"
#include "tick.h"
static unsigned long Tick = 0;
extern "C" void SysTick_Handler()
{
Tick++;
}
//------------------------------------------------------------------------------
void TICK_Init()
{
SysTick->LOAD = SystemCoreClock / 1000;
SysTick->VAL = 0UL;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk;
NVIC_SetPriority(SysTick_IRQn, 0);
}
//------------------------------------------------------------------------------
unsigned long TICK_GetCount() // ms
{
return Tick;
}
//------------------------------------------------------------------------------
void Tick_Delay(unsigned long ms)
{
const unsigned long start = Tick;
while ((Tick - start) < ms) {
__NOP();
}
}