Browse Source

Merge branch 'SysTick' into develop

# Conflicts:
#	MDK-ARM/Project.uvoptx
#	MDK-ARM/Project.uvprojx
#	Src/main.c
Neluji 3 years ago
parent
commit
45bc1d4b7d
3 changed files with 70 additions and 3 deletions
  1. 43
    0
      MyDrivers/MySysTick.c
  2. 15
    0
      MyDrivers/MySysTick.h
  3. 12
    3
      Src/main.c

+ 43
- 0
MyDrivers/MySysTick.c View File

@@ -0,0 +1,43 @@
1
+#include "MySysTick.h"
2
+
3
+#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
4
+#include "stm32f1xx_ll_cortex.h"
5
+
6
+
7
+void (*Ptr_ItFct_SysTick)(void); 
8
+
9
+void MySysTick_Conf(uint32_t ticks) {
10
+	
11
+	SysTick_Config(ticks);
12
+	
13
+	MySysTick_IT_Disable();
14
+	
15
+}
16
+
17
+void MySysTick_IT_Conf (void (*IT_function)(void), int Prio) {
18
+	
19
+	//Affectation de la fonction du handler
20
+	Ptr_ItFct_SysTick = IT_function;
21
+	
22
+	//Désactivation des IT
23
+	LL_SYSTICK_DisableIT();
24
+	
25
+	//Configuration du NVIC
26
+	NVIC_SetPriority(SysTick_IRQn, Prio);
27
+	NVIC_EnableIRQ(SysTick_IRQn);
28
+	
29
+}
30
+
31
+void MySysTick_IT_Enable (void) {
32
+	LL_SYSTICK_EnableIT();
33
+}
34
+
35
+void MySysTick_IT_Disable (void) {
36
+	LL_SYSTICK_DisableIT();
37
+}
38
+
39
+/*========Handler d'IT==========*/
40
+
41
+void SysTick_Handler (void) {
42
+	(*Ptr_ItFct_SysTick)();
43
+}

+ 15
- 0
MyDrivers/MySysTick.h View File

@@ -0,0 +1,15 @@
1
+#ifndef MY_SYSTICK_H
2
+#define MY_SYSTICK_H
3
+
4
+#include "stm32f103xb.h"
5
+
6
+	
7
+	void MySysTick_Conf(uint32_t ticks);
8
+	
9
+	void MySysTick_IT_Conf (void (*IT_function)(void), int Prio);
10
+	
11
+	void MySysTick_IT_Enable (void);
12
+	
13
+	void MySysTick_IT_Disable (void);
14
+
15
+#endif

+ 12
- 3
Src/main.c View File

@@ -23,6 +23,9 @@
23 23
 #include "MyTimer.h"
24 24
 #include "MyPWM.h"
25 25
 #include "MyRF.h"
26
+#include "Moteur.h"
27
+#include "MySysTick.h"
28
+#include <stdio.h>
26 29
 
27 30
 void  SystemClock_Config(void);
28 31
 
@@ -35,11 +38,19 @@ void  SystemClock_Config(void);
35 38
   */
36 39
 	
37 40
 
41
+
42
+void test (void) {
43
+	printf("ok");
44
+}
45
+
38 46
 int main(void)
39 47
 {
40 48
   /* Configure the system clock to 72 MHz */
41 49
   SystemClock_Config();
42 50
 	
51
+	MySysTick_Conf(0xAFC80);
52
+	MySysTick_IT_Conf(test,3);
53
+	MySysTick_IT_Enable();
43 54
 	MyRF_Conf();
44 55
 	
45 56
 	for(int i=0; i<0xCFFF; i++) {
@@ -57,8 +68,6 @@ int main(void)
57 68
 
58 69
 
59 70
 
60
-
61
-
62 71
 /**
63 72
   * @brief  System Clock Configuration
64 73
   *         The system Clock is configured as follow :
@@ -81,7 +90,7 @@ void SystemClock_Config(void)
81 90
 
82 91
   /* Enable HSE oscillator */
83 92
 	// ********* Commenter la ligne ci-dessous pour MCBSTM32 *****************
84
-	// ********* Conserver la ligne si Nucléo*********************************
93
+	// ********* Conserver la ligne si Nucl�o*********************************
85 94
   LL_RCC_HSE_EnableBypass();
86 95
   LL_RCC_HSE_Enable();
87 96
   while(LL_RCC_HSE_IsReady() != 1)

Loading…
Cancel
Save