#include "stm32f3xx_hal.h"
#include "stm32f3xx_ll_tim.h"
#include "stm32f3xx_ll_adc.h"

__weak void foc_brake_handler(void) {}
__weak void foc_pwm_up_handler(void) {}
__weak void system_tick_handler(void){}
__weak void current_sample_handler(void){}

void TIM1_BRK_TIM15_IRQHandler(void){
	if (LL_TIM_IsActiveFlag_BRK2(TIM1))
	{
	  	LL_TIM_ClearFlag_BRK2(TIM1);
	  	TIM1->BDTR |= LL_TIM_OSSI_ENABLE;
		foc_brake_handler();
	}
}

void TIM1_UP_TIM16_IRQHandler(void){
	LL_TIM_ClearFlag_UPDATE(TIM1);
	foc_pwm_up_handler();
}


void ADC1_IRQHandler(void) {
	LL_ADC_ClearFlag_JEOS( ADC1 );
	current_sample_handler();
}

void SysTick_Handler(void)
{
	system_tick_handler();
}

