Merge branch 'SysTick' into develop
# Conflicts: # MDK-ARM/Project.uvoptx # MDK-ARM/Project.uvprojx # Src/main.c
This commit is contained in:
commit
45bc1d4b7d
3 changed files with 70 additions and 3 deletions
43
MyDrivers/MySysTick.c
Normal file
43
MyDrivers/MySysTick.c
Normal file
|
@ -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)();
|
||||
}
|
15
MyDrivers/MySysTick.h
Normal file
15
MyDrivers/MySysTick.h
Normal file
|
@ -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
|
15
Src/main.c
15
Src/main.c
|
@ -23,6 +23,9 @@
|
|||
#include "MyTimer.h"
|
||||
#include "MyPWM.h"
|
||||
#include "MyRF.h"
|
||||
#include "Moteur.h"
|
||||
#include "MySysTick.h"
|
||||
#include <stdio.h>
|
||||
|
||||
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<EFBFBD>o*********************************
|
||||
LL_RCC_HSE_EnableBypass();
|
||||
LL_RCC_HSE_Enable();
|
||||
while(LL_RCC_HSE_IsReady() != 1)
|
||||
|
|
Loading…
Reference in a new issue