Browse Source

add basic scheduler functions

Arnaud Vergnet 3 years ago
parent
commit
7e6eb879f1
3 changed files with 69 additions and 4 deletions
  1. 21
    0
      Services/Scheduler.c
  2. 22
    0
      Services/Scheduler.h
  3. 26
    4
      Src/main.c

+ 21
- 0
Services/Scheduler.c View File

@@ -0,0 +1,21 @@
1
+#include "Scheduler.h"
2
+#include "Timer.h"
3
+#include "stm32f1xx_ll_utils.h"
4
+
5
+void (*it_callback_SysTick)(void); 
6
+
7
+void SysTick_Handler(void)
8
+{
9
+	(*it_callback_SysTick)();
10
+}	
11
+
12
+void Scheduler_conf(void (*it_callback) (void))
13
+{
14
+	it_callback_SysTick = it_callback;
15
+	LL_Init1msTick(1000);
16
+}
17
+
18
+void Scheduler_start(void)
19
+{
20
+	
21
+}

+ 22
- 0
Services/Scheduler.h View File

@@ -0,0 +1,22 @@
1
+#ifndef SCHEDULER_H
2
+#define SCHEDULER_H
3
+
4
+#include "stm32f103xb.h" 
5
+
6
+/**
7
+	* @brief  Configure l'horloge interne comme ordonanceur
8
+  * @note   
9
+	* @param  (void)* it_callback : Tache de fond à executer
10
+  * @retval None
11
+  */
12
+void Scheduler_conf(void (*it_callback) (void));
13
+
14
+/**
15
+	* @brief  Démarre ordonanceur
16
+  * @note   
17
+	* @param  None
18
+  * @retval None
19
+  */
20
+void Scheduler_start(void);
21
+
22
+#endif

+ 26
- 4
Src/main.c View File

@@ -21,17 +21,36 @@
21 21
 #include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
22 22
 
23 23
 #include "Sail.h"
24
+#include "Scheduler.h"
24 25
 
25 26
 void  SystemClock_Config(void);
26 27
 
27 28
 /* Private functions ---------------------------------------------------------*/
28 29
 
30
+int counter = 1;
31
+
32
+void backgroundTask()
33
+{
34
+	counter++;
35
+	Sail_background();
36
+}
37
+
38
+
39
+void configurePeripherals()
40
+{
41
+	Sail_conf();
42
+}
43
+
44
+void startPeripherals()
45
+{
46
+	Sail_start();
47
+}
48
+
29 49
 /**
30 50
   * @brief  Main program
31 51
   * @param  None
32 52
   * @retval None
33 53
   */
34
-
35 54
 int main(void)
36 55
 {
37 56
   /* Configure the system clock to 72 MHz */
@@ -43,9 +62,12 @@ int main(void)
43 62
 	// Lancement chronomètre
44 63
 	// Chrono_Start(); 
45 64
 	// time = Chrono_Read();
46
-  
47
-	Sail_conf();
48
-	Sail_start();
65
+  configurePeripherals();
66
+	startPeripherals();
67
+	
68
+	Scheduler_conf(backgroundTask);
69
+	Scheduler_start();
70
+	
49 71
   while (1)
50 72
   {
51 73
   }

Loading…
Cancel
Save