diff --git a/MyDrivers/MySysTick.c b/MyDrivers/MySysTick.c new file mode 100644 index 0000000..0db6e80 --- /dev/null +++ b/MyDrivers/MySysTick.c @@ -0,0 +1,43 @@ +#include "MySysTick.h" + +#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges +#include "stm32f1xx_ll_cortex.h" + + +void (*Ptr_ItFct_SysTick)(void); + +void MySysTick_Conf(uint32_t ticks) { + + SysTick_Config(ticks); + + MySysTick_IT_Disable(); + +} + +void MySysTick_IT_Conf (void (*IT_function)(void), int Prio) { + + //Affectation de la fonction du handler + Ptr_ItFct_SysTick = IT_function; + + //Désactivation des IT + LL_SYSTICK_DisableIT(); + + //Configuration du NVIC + NVIC_SetPriority(SysTick_IRQn, Prio); + NVIC_EnableIRQ(SysTick_IRQn); + +} + +void MySysTick_IT_Enable (void) { + LL_SYSTICK_EnableIT(); +} + +void MySysTick_IT_Disable (void) { + LL_SYSTICK_DisableIT(); +} + +/*========Handler d'IT==========*/ + +void SysTick_Handler (void) { + (*Ptr_ItFct_SysTick)(); +} diff --git a/MyDrivers/MySysTick.h b/MyDrivers/MySysTick.h new file mode 100644 index 0000000..b87a943 --- /dev/null +++ b/MyDrivers/MySysTick.h @@ -0,0 +1,15 @@ +#ifndef MY_SYSTICK_H +#define MY_SYSTICK_H + +#include "stm32f103xb.h" + + + void MySysTick_Conf(uint32_t ticks); + + void MySysTick_IT_Conf (void (*IT_function)(void), int Prio); + + void MySysTick_IT_Enable (void); + + void MySysTick_IT_Disable (void); + +#endif diff --git a/Src/main.c b/Src/main.c index 6861ae4..ad2191e 100644 --- a/Src/main.c +++ b/Src/main.c @@ -23,6 +23,9 @@ #include "MyTimer.h" #include "MyPWM.h" #include "MyRF.h" +#include "Moteur.h" +#include "MySysTick.h" +#include void SystemClock_Config(void); @@ -35,11 +38,19 @@ void SystemClock_Config(void); */ + +void test (void) { + printf("ok"); +} + int main(void) { /* Configure the system clock to 72 MHz */ SystemClock_Config(); + MySysTick_Conf(0xAFC80); + MySysTick_IT_Conf(test,3); + MySysTick_IT_Enable(); MyRF_Conf(); for(int i=0; i<0xCFFF; i++) { @@ -57,8 +68,6 @@ int main(void) - - /** * @brief System Clock Configuration * The system Clock is configured as follow : @@ -81,7 +90,7 @@ void SystemClock_Config(void) /* Enable HSE oscillator */ // ********* Commenter la ligne ci-dessous pour MCBSTM32 ***************** - // ********* Conserver la ligne si Nucléo********************************* + // ********* Conserver la ligne si Nucl�o********************************* LL_RCC_HSE_EnableBypass(); LL_RCC_HSE_Enable(); while(LL_RCC_HSE_IsReady() != 1)