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

34
drv/tim.cpp Normal file
View File

@ -0,0 +1,34 @@
#include "stm32g4xx.h"
#include "tim.h"
static void (*TIM7_Proc)() = 0;
extern "C" void TIM7_IRQHandler()
{
TIM7->SR = 0;
TIM7_Proc();
}
//------------------------------------------------------------------------------
void TIM7_Init(long Priority)
{
RCC->APB1ENR1 |= RCC_APB1ENR1_TIM7EN;
TIM7->CR1 = 0;
TIM7->ARR = 1000 - 1;
TIM7->DIER = TIM_DIER_UIE;
NVIC_SetPriority(TIM7_IRQn, Priority);
NVIC_EnableIRQ(TIM7_IRQn);
}
//------------------------------------------------------------------------------
void TIM7_Update(unsigned long Freq, void (*Proc)())
{
TIM7->CR1 = 0;
TIM7->PSC = (SystemCoreClock / 1000 / Freq) - 1;
TIM7_Proc = Proc;
TIM7->CR1 = TIM_CR1_CEN;
}
//------------------------------------------------------------------------------