Browse Source

1ere partie step final sur platine de test OK

Adrien Barbanson 2 years ago
parent
commit
c27baa174f

+ 78
- 0
PjtKEIL_StepFinal/Driver/Affichage_Valise.h View File

@@ -0,0 +1,78 @@
1
+
2
+/* Fichier devant contenir l'ensemble de fichiers utiles pour le projet LaserQuest
3
+et qui concenent l'affichage sur la valise */
4
+/* mais non disponible en version source pour les étudiants.						*/
5
+
6
+#ifndef _AFFICHAGE_VALISE_H__
7
+#define _AFFICHAGE_VALISE_H__
8
+#include "stm32f10x.h"
9
+
10
+
11
+/**
12
+	* @brief  Initialise les périphériques nécessaires à l'affichage sur la Mallette
13
+	*					et gère la cible active. S'utilise aussi avec les ùmodules affichages simple (pas de mallette)
14
+  * @note   Utilise TIM1, PA5, PA6 pour les cibles, PC7 à PC9 pour SPI émulé
15
+	*					 utilise aussi une interruption sut TIM1, prio 8.
16
+	* @param  none
17
+  * @retval None
18
+  */
19
+void Init_Affichage(void);
20
+
21
+
22
+/**
23
+	* @brief  Prépare l'affichage 2 digit sur l'afficheur demandé
24
+  * @note   Exemple : Prepare_Afficheur(2, 99); 
25
+	*         prépare l'affichage de la valeur 99 sur l'afficheur n°2
26
+	* 			  L'action est différée à l'exécution de Mise_A_Jour_Afficheurs_LED()
27
+	* @param  char Aff : de 1 à 4 ; char Valeur de 0 à 99
28
+  * @retval None
29
+  */
30
+void Prepare_Afficheur(char Aff, char Valeur);
31
+
32
+
33
+
34
+void Prepare_Set_Point_Unite(char Aff);
35
+void Prepare_Clear_Point_Unite(char Aff);
36
+
37
+
38
+/**
39
+	* @brief  Prépare l'allumage de la LED demandée
40
+  * @note   Exemple : Prepare_Set_LED(LED_Cible_2); 
41
+	*         prépare l'allumage de la LED correspondant à la cible n°2
42
+	*					L'action est différée à l'exécution de Mise_A_Jour_Afficheurs_LED()
43
+	* @param  voir #define ci-dessous
44
+  * @retval None
45
+  */
46
+void Prepare_Set_LED(char LED);
47
+void Prepare_Clear_LED(char LED);
48
+
49
+
50
+/**
51
+	* @brief  Effectue l'action d'écriture dans le module d'affichage
52
+	*					à partir de tout ce qui a été préparé auparavant.
53
+  * @note   
54
+	* @param  None
55
+  * @retval None
56
+  */
57
+void Mise_A_Jour_Afficheurs_LED(void);
58
+
59
+/**
60
+	* @brief  Spécifie le capteut actif, à savoir celui effectivement relié
61
+	*					aux sorties disponibles sur la malette
62
+  * @note   Exemple : Choix_Capteur(1)        
63
+	* @param  1 à 4
64
+  * @retval None
65
+  */
66
+void Choix_Capteur(char Capteur);
67
+// define utile pour la fonction Prepare_Set_LED et Prepare_Clear_LED
68
+#define LED_LCD_R 5
69
+#define LED_LCD_V  4
70
+#define LED_Cible_4 3
71
+#define LED_Cible_3 2
72
+#define LED_Cible_2 1
73
+#define LED_Cible_1 0
74
+
75
+
76
+
77
+#endif
78
+

+ 345
- 0
PjtKEIL_StepFinal/Driver/DriverJeuLaser.h View File

@@ -0,0 +1,345 @@
1
+/**
2
+ * Bibliotheque DriverJeuLaser (ancienne gassp72 adaptée 2021 - TR)
3
+ *
4
+ * GPIO - ADC - Sequenceur - System Timer - PWM - 72 MHz
5
+ * Modifs :
6
+ * enlèvement de tout ce qui est inutile dans le .h 
7
+ * ajout de fonctions GPIO dans le .c pour utilisation en ASM ou en C :
8
+ *  - GPIOA_Set(char Broche), GPIOB_Set(char Broche), GPIOC_Set(char Broche)
9
+ *  - GPIOA_Clear(char Broche), GPIOB_Clear(char Broche), GPIOC_Clear(char Broche)
10
+ * 
11
+ * ajout d'une fonction qui impose une valeur de PWM (TIM3_CCR3)
12
+ * PWM_Set_Value_On_TIM3_C3( int Val) 
13
+ * permet en ASM ou en C de fixer la valeur de PWM 
14
+ 
15
+ * Ajout de commentaires
16
+ 
17
+ */
18
+#ifndef DRIVERJEULASER_H__
19
+#define DRIVERJEULASER_H__
20
+
21
+#include "stm32f10x.h"
22
+
23
+//**********************************************************************************************************
24
+//---------------------          CONFIGURATION CLOCK DU STM32         --------------------------------------
25
+//**********************************************************************************************************
26
+
27
+/**
28
+	* @brief  Configure l'ensemble des horloges du uC
29
+  * @note   horloge systeme (config statique a 72 MHz pour le STM32F103)
30
+	* @param  None
31
+  * @retval None
32
+  */
33
+void CLOCK_Configure(void);
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+//**********************************************************************************************************
45
+//---------------------          LES TIMERS GENERAL PURPOSE TIM1 à TIM 4      ------------------------------
46
+//**********************************************************************************************************
47
+
48
+/**
49
+	* @brief  Configure un Timer TIM1 à TIM4 avec une périodicité donnée
50
+  * @note   L' horloge des 4 timers a une fréquence de 72MHz
51
+	* @param  *Timer = TIM1 ou TIM2 ou TIM3 ou TIM4
52
+	* @param  Durée_ticks : nombre de pas (tick) comptés à 72 MHz pour faire déborder le timer 
53
+	*         La période de débordement du Timer est donc T = Durée_ticks * Tck, avec Tck = 1/72 000 000
54
+  * @retval None
55
+  */
56
+void Timer_1234_Init_ff( TIM_TypeDef *Timer, u32 Duree_ticks );
57
+
58
+/**
59
+ * Macros de base pour utiliser les timers
60
+ */
61
+ // bloque le timer
62
+#define Bloque_Timer(Timer) Timer->CR1=(Timer->CR1)&~(1<<0)
63
+// Lance timer
64
+#define Run_Timer(Timer) Timer->CR1=(Timer->CR1)|(1<<0)
65
+
66
+
67
+
68
+/**
69
+	* @brief  Associe une fonction d'interruption (callback) lors du débordement d'un timer
70
+  * @note   
71
+	* @param  *Timer = TIM1 ou TIM2 ou TIM3 ou TIM4
72
+	* @param  Prio : niveau de priorité de l'interruption (0 -> priorité max, 15 ->  priorité min)
73
+	* @param  IT_function : le nom de la fonction Callback à appeler lors de l'interruption
74
+  * @retval None
75
+  */
76
+void Active_IT_Debordement_Timer( TIM_TypeDef *Timer, char Prio, void (*IT_function)(void) );
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+//*********************************************************************************************************
89
+//---------------------               PWM   TIM1 to TIM 4                   ------------------------------
90
+//*********************************************************************************************************
91
+
92
+/**
93
+	* @brief  Configure un timer en PWM 
94
+  * @note   
95
+	* @param  *Timer = TIM1 ou TIM2 ou TIM3 ou TIM4
96
+	* @param  voie : un des 4 canaux possibles 1 à 4.
97
+	* @param  Periode_ticks : nombre de pas (tick) comptés à 72 MHz pour faire déborder le timer 
98
+	*         La période de débordement du Timer est donc T = Durée_ticks * Tck, avec Tck = 1/72 000 000
99
+  * @retval Retourne la période  en tick (normalement la même que le param d'entrée sauf si PSC utilisé
100
+  */
101
+unsigned short int PWM_Init_ff( TIM_TypeDef *Timer, char Voie, u32 Periode_ticks );
102
+
103
+
104
+
105
+/**
106
+	* @brief  Fixe une valeur de PWM, Val, en tick horloge. La rapport cyclique effectif
107
+	* est donc : rcy = Thaut_ticks / Periode_ticks
108
+  * @note   spécifique Jeu Laser, PWM liée exclusivement au TIM3, chan3
109
+	* @param  Thaut_ticks : durée de l'état haut d'une impulsion en Ticks
110
+  * @retval None
111
+  */
112
+void PWM_Set_Value_TIM3_Ch3( unsigned short int Thaut_ticks);
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+//**********************************************************************************************************
123
+//---------------------          LE SYSTICK TIMER, Part of Cortex M3          ------------------------------
124
+//**********************************************************************************************************
125
+
126
+/**
127
+	* @brief  Configure le timer Systick avec une périodicité donnée
128
+  * @note   Ce timer ne peut servir qu'à créer des temporisations ou générer des interruption
129
+	*         ce n'est pas à proprement parler un périphérique, il fait partie du Cortex M3
130
+	*         Ce timer est un 24 bits 
131
+	* @param  Periode_ticks : nombre de pas (tick) comptés à 72 MHz pour établir la périodicité
132
+	*          La période de débordement du Timer est donc T = Durée_ticks * Tck, avec Tck = 1/72 000 000
133
+  * @retval None
134
+  */
135
+void Systick_Period_ff( unsigned int Periode_ticks );
136
+
137
+
138
+
139
+/**
140
+	* @brief  Associe une fonction d'interruption (callback) lors du débordement du Systick
141
+  * @note   
142
+	* @param  Prio : niveau de priorité de l'interruption (0 -> priorité max, 15 ->  priorité min)
143
+	* @param  IT_function : le nom de la fonction Callback à appeler lors de l'interruption
144
+  * @retval None
145
+  */
146
+void Systick_Prio_IT( char Prio, void (*Systick_function)(void) );
147
+
148
+
149
+/**
150
+ * Macros de base pour utiliser le Systick 
151
+ */
152
+#define  SysTick_On ((SysTick->CTRL)=(SysTick->CTRL)|1<<0)
153
+#define  SysTick_Off ((SysTick->CTRL)=(SysTick->CTRL)& ~(1<<0))
154
+#define  SysTick_Enable_IT ((SysTick->CTRL)=(SysTick->CTRL)|1<<1)
155
+#define  SysTick_Disable_IT ((SysTick->CTRL)=(SysTick->CTRL)& ~(1<<1))
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+//**********************************************************************************************************
171
+//---------------------          LE SYSTICK TIMER, Part of Cortex M3          ------------------------------
172
+//**********************************************************************************************************
173
+
174
+/**
175
+	* @brief  Active l'ADC du STM32, configure la durée de prélèvement de l'échantillon (temps
176
+	* de fermeture du switch d'acquisition
177
+  * @note   
178
+	* @param  ADC : précise de quel ADC il s'agit, ADC1 ou ADC2
179
+	* @param  Duree_Ech_ticks : dirée de fermeture du switch d'échantillonnage en Tick d'horloge CPU
180
+	*         exemple pour 1µs on choisira 72.
181
+  * @retval Nombre de Tick réellement pris en compte
182
+  */
183
+unsigned int Init_TimingADC_ActiveADC_ff( ADC_TypeDef * ADC, u32 Duree_Ech_ticks );
184
+
185
+
186
+/**
187
+	* @brief  Sélectionne la voie à convertir
188
+  * @note   Attention, la voie va de 0 à 15 et n'est pas directement lié au n°de GPIO
189
+	* @param  ADC : précise de quel ADC il s'agit, ADC1 ou ADC2
190
+	* @param  Voie_ADC : 1 à 15
191
+  * @retval None
192
+  */
193
+void Single_Channel_ADC( ADC_TypeDef * ADC, char Voie_ADC );
194
+
195
+
196
+
197
+
198
+
199
+/**
200
+	* @brief  Permet lier le déclenchement au débordement d'un timer, spécifie également
201
+	*         la période de débordement du timer 
202
+  * @note   pas besoin de régler le timer avec une autre fonction dédiée timer
203
+	* @param  ADC : précise de quel ADC il s'agit, ADC1 ou ADC2
204
+	* @param  Source : indique le timer qui déclenche l'ADC choix dans les define ci-dessous
205
+	* @param	Periode_ticks : nombre de pas (tick) comptés à 72 MHz pour faire déborder le timer 
206
+	*         La période de débordement du Timer est donc T = Durée_ticks * Tck, avec Tck = 1/72 000 000
207
+  * @retval None
208
+  */
209
+
210
+// param pour Source :
211
+#define TIM1_CC1 0
212
+#define TIM1_CC2 1
213
+#define TIM1_CC3 2
214
+#define TIM2_CC2 3
215
+#define TIM4_CC4 5
216
+void Init_Conversion_On_Trig_Timer_ff( ADC_TypeDef * ADC, char Source, u32 Periode_ticks );
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+//**********************************************************************************************************
233
+//---------------------           ANALOG INPUT  ADC & DMA                     ------------------------------
234
+//**********************************************************************************************************
235
+
236
+/**
237
+	* @brief  Permer de lier l'ADC à un tableau en RAM pour une DMA 
238
+  * @note   
239
+	* @param  Circ : circular. Si '0', en fin de DMA le ptr d'@ reste inchangé
240
+	*         si '1' le ptr d'@ se recale à celle du début.
241
+	* @param  Ptr_Table_DMA : contient l'@ de début de zone RAM à écrire
242
+	* @retval None
243
+  */
244
+void Init_ADC1_DMA1(char Circ, short int *Ptr_Table_DMA);
245
+
246
+
247
+
248
+
249
+
250
+/**
251
+	* @brief  Lance une DMA sur le nombre de points spécifie. Les resultats seront stockes
252
+	*         dans la zone de RAM écrite est indiquée lors de l'appel de la fonction  Init_ADC1_DMA1 
253
+  * @note   
254
+	* @param  NbEchDMA est le nombre d'échantillons à stocker.
255
+	* @retval None
256
+  */
257
+void Start_DMA1( u16 NbEchDMA );
258
+
259
+// arret DMA
260
+#define  Stop_DMA1 DMA1_Channel1->CCR =(DMA1_Channel1->CCR) &~0x1;
261
+
262
+
263
+/**
264
+	* @brief  Attend la fin d'un cycle de DMA. la duree depend de la periode d'acquisition 
265
+	* et du nombre d'echantillons
266
+  * @note   fonction d'attente (bloquante) 
267
+	* @param  None
268
+	* @retval None
269
+  */
270
+void Wait_On_End_Of_DMA1(void);
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+//**********************************************************************************************************
280
+//---------------------                   GPIO                                ------------------------------
281
+//**********************************************************************************************************
282
+
283
+/**
284
+	* @brief  Initialisation d'un GPIO (A à C), pin x. 
285
+  *  			peut être configuré :
286
+	*  			-> Input ou output
287
+	*       -> architecture technologique (push-pull, open drain...)
288
+	
289
+  * @note   
290
+	* @param  Port : GPIOA, GPIOB, GPIOC
291
+	* @param  Broche : 0 à 15
292
+	* @param  Sens : INPUT ou OUTPUT
293
+	* @param  Techno : voir define ci dessous
294
+	* @retval 1 erreur, 0 si OK
295
+  */
296
+
297
+// Sens
298
+#define INPUT   'i'
299
+#define OUTPUT  'o'
300
+
301
+// Techno pour pin en entrée (INPUT)
302
+#define ANALOG              0
303
+#define INPUT_FLOATING      1
304
+#define INPUT_PULL_DOWN_UP  2
305
+
306
+// Techno pour pin en sortie (OUTPUT)
307
+#define OUTPUT_PPULL    0
308
+#define OUTPUT_OPDRAIN  1
309
+#define ALT_PPULL       2
310
+#define ALT_OPDRAIN     3
311
+
312
+// Exemple :
313
+// Port_IO_Init(GPIOB, 8, OUTPUT, OUTPUT_PPULL);
314
+// Place le bit 8 du port B en sortie Push-pull
315
+char GPIO_Configure(GPIO_TypeDef * Port, int Broche, int Sens, int Techno);
316
+
317
+
318
+/**
319
+	* @brief  Mise à 1 d'une broche GPIO	
320
+  * @note   Une fonction par GPIO
321
+	* @param  Broche : 0 à 15
322
+	* @retval None
323
+  */
324
+
325
+void GPIOA_Set(char Broche);
326
+void GPIOB_Set(char Broche);
327
+void GPIOC_Set(char Broche);
328
+
329
+
330
+
331
+/**
332
+	* @brief  Mise à 0 d'une broche GPIO	
333
+  * @note   Une fonction par GPIO
334
+	* @param  Broche : 0 à 15
335
+	* @retval None
336
+  */
337
+
338
+void GPIOA_Clear(char Broche);
339
+void GPIOB_Clear(char Broche);
340
+void GPIOC_Clear(char Broche);
341
+
342
+
343
+#endif
344
+
345
+

+ 56
- 0
PjtKEIL_StepFinal/Driver/DriverJeuLaser.inc View File

@@ -0,0 +1,56 @@
1
+
2
+; Bibliotheque DriverJeuLaser (ancienne gassp72 adaptée 2021 - TR)
3
+; Accès en aux fonctions suivantes :
4
+; GPIO :
5
+; GPIOA_Set(char Broche), GPIOB_Set(char Broche), GPIOC_Set(char Broche)
6
+; GPIOA_Clear(char Broche), GPIOB_Clear(char Broche), GPIOC_Clear(char Broche)
7
+  
8
+; PWM :
9
+;/**
10
+;	* @brief  Fixe une valeur de PWM, Val, en tick horloge. La rapport cyclique effectif
11
+;	* est donc : rcy = Thaut_ticks / Periode_ticks
12
+; * @note   spécifique Jeu Laser, PWM liée exclusivement au TIM3, chan3
13
+;	* @param  Thaut_ticks : durée de l'état haut d'une impulsion en Ticks
14
+;  * @retval None
15
+; */
16
+
17
+;void PWM_Set_Value_TIM3_Ch3( unsigned short int Thaut_ticks);
18
+	import PWM_Set_Value_TIM3_Ch3
19
+
20
+
21
+
22
+;/**
23
+;	* @brief  Mise à 1 d'une broche GPIO	
24
+;  * @note   Une fonction par GPIO
25
+;	* @param  Broche : 0 à 15
26
+;	* @retval None
27
+; */
28
+
29
+;void GPIOA_Set(char Broche);
30
+	import GPIOA_Set
31
+
32
+;void GPIOB_Set(char Broche);
33
+	import GPIOB_Set
34
+
35
+;void GPIOC_Set(char Broche);
36
+	import GPIOC_Set
37
+
38
+
39
+
40
+;/**
41
+;	* @brief  Mise à 0 d'une broche GPIO	
42
+;  * @note   Une fonction par GPIO
43
+;	* @param  Broche : 0 à 15
44
+;	* @retval None
45
+;  */
46
+
47
+;void GPIOA_Clear(char Broche);
48
+	import GPIOA_Clear
49
+
50
+;void GPIOB_Clear(char Broche);
51
+	import GPIOB_Clear
52
+
53
+;void GPIOC_Clear(char Broche);
54
+	import GPIOC_Clear
55
+
56
+	end

+ 21
- 0
PjtKEIL_StepFinal/RTE/_CibleSondeKEIL/RTE_Components.h View File

@@ -0,0 +1,21 @@
1
+
2
+/*
3
+ * Auto generated Run-Time-Environment Configuration File
4
+ *      *** Do not modify ! ***
5
+ *
6
+ * Project: 'StepDFT' 
7
+ * Target:  'CibleSondeKEIL' 
8
+ */
9
+
10
+#ifndef RTE_COMPONENTS_H
11
+#define RTE_COMPONENTS_H
12
+
13
+
14
+/*
15
+ * Define the Device Header File: 
16
+ */
17
+#define CMSIS_device_header "stm32f10x.h"
18
+
19
+
20
+
21
+#endif /* RTE_COMPONENTS_H */

+ 21
- 0
PjtKEIL_StepFinal/RTE/_Simu/RTE_Components.h View File

@@ -0,0 +1,21 @@
1
+
2
+/*
3
+ * Auto generated Run-Time-Environment Configuration File
4
+ *      *** Do not modify ! ***
5
+ *
6
+ * Project: 'StepDFT' 
7
+ * Target:  'Simu' 
8
+ */
9
+
10
+#ifndef RTE_COMPONENTS_H
11
+#define RTE_COMPONENTS_H
12
+
13
+
14
+/*
15
+ * Define the Device Header File: 
16
+ */
17
+#define CMSIS_device_header "stm32f10x.h"
18
+
19
+
20
+
21
+#endif /* RTE_COMPONENTS_H */

+ 266
- 0
PjtKEIL_StepFinal/Src/DFT.s View File

@@ -0,0 +1,266 @@
1
+	PRESERVE8
2
+	THUMB   
3
+		
4
+
5
+; ====================== zone de réservation de données,  ======================================
6
+;Section RAM (read only) :
7
+	area    mesdata,data,readonly
8
+
9
+
10
+;Section RAM (read write):
11
+	area    maram,data,readwrite
12
+		
13
+	export DFT_ModuleAuCarre
14
+	
15
+	
16
+; ===============================================================================================
17
+	
18
+
19
+
20
+
21
+
22
+
23
+		
24
+;Section ROM code (read only) :		
25
+	area    moncode,code,readonly
26
+; écrire le code ici		
27
+
28
+
29
+DFT_ModuleAuCarre proc
30
+	
31
+	; dans r0 On a l'adresse du départ du tableau du signal
32
+	; dans r1 on a le nombre k
33
+	
34
+	push {r4-r10}
35
+	
36
+	; on utilise R2 pour stocker la somme des cosinus
37
+	mov r2, #0;
38
+	; on utilise R7 pour stocker la somme des sinus
39
+	mov r7, #0;
40
+	
41
+	; on utilise r3 pour stocker n
42
+	mov r3, #0;
43
+	
44
+boucle
45
+	; on load la valeur du son signal[i]
46
+	; on utilise LDR mais que sur 16 bits car le chiffre est au format 1.15
47
+	; on charge depuis l'adresse r0 avec un décalage r3, on décale de 2^4 = 16 bits
48
+	ldrh r4, [r0,r3,LSL #1]
49
+	
50
+	; on fait k*n pour avoir p
51
+	; donc dans  r6 on a p
52
+	mul r6, r3, r1
53
+	
54
+	; ensuite on fait le modulo 64
55
+	; ce qui revient à faire un masque sur les 2^6 premiers bits
56
+	
57
+	
58
+	; XXXXXXXXXXXXXXXX
59
+	;  AND
60
+	; 0000000000111111 = 63 en binaire
61
+	
62
+	and r6, r6,#63
63
+	
64
+	;on va chercher la valeur du cosinus
65
+	ldr r5, =TabCos
66
+	ldrsh r5, [r5, r6, LSL #1]
67
+	
68
+	; on va chercher la valeur du sinus
69
+	ldr r8, =TabSin
70
+	ldrsh r8, [r8, r6, LSL #1]
71
+	
72
+	
73
+	
74
+    ; ATTENTION : on multiplie un format 1.12 avec un format 1.15 donc le résultat est au format 2.27
75
+	; DONC : on fait 16bits * 16 bits = 32 bits
76
+	mul r5,r4 ; f(x) * cos(p)
77
+	mul r8,r4 ; f(x) * sin(p)
78
+	
79
+	; on est sûr que l'on a la partie entière qui ne peut pas être supérieure à 1
80
+	; donc on a pas de risque de débordement si on remasse en 1.15
81
+	
82
+	; on repase en 1.12 en décalant de 15 bits à droite, mais on préserve le signe
83
+	
84
+	asr r5, #15
85
+	asr r8, #15
86
+	
87
+	; Attention, à force d'ajouter du 1.12 on peut facilement déborder en 6.12 car on peut potentiellement ajouter 1 à chaque itération ! (donc 64 = 2^6)
88
+	add r2, r5
89
+	add r7, r8
90
+	
91
+	;on incrémente notre i
92
+	add r3, #1
93
+	
94
+	cmp r3, #63
95
+	bne boucle
96
+	
97
+	; MISE AU CARRE : attention on a 6.12 * 6.12 = 12.24 donc 36 bits or le registre est sur 32 bits.
98
+	; Donc on réduit de 6.12 à 6.10 avec de pouvoir avoir : 6.10 * 6.10 = 12.20 = 32 bits.
99
+	
100
+	asr r2, #2
101
+	asr r7, #2
102
+
103
+	; format 12.20
104
+	mul r2,r2
105
+	mul r7,r7
106
+	
107
+	; la somme totale doit etre retournée dans r1
108
+	; sauf que 12.20 + 12.20 il y a risque de débordement
109
+	; donc on passe en 12.19 + 12.19 et le résultat sera en 13.19
110
+	asr r2, #1
111
+	asr r7, #1
112
+	
113
+	; on les somme : on passe en 13.19
114
+	add r2, r7
115
+	
116
+	; on place le résultat dans r0
117
+	mov r0, r2
118
+	
119
+	pop {r4-r10}
120
+	
121
+	bx lr
122
+	
123
+ endp
124
+
125
+
126
+
127
+
128
+;Section ROM code (read only) :		
129
+	AREA Trigo, DATA, READONLY
130
+; codage fractionnaire 1.15
131
+
132
+TabCos
133
+	DCW	32767	;  0 0x7fff  0.99997
134
+	DCW	32610	;  1 0x7f62  0.99518
135
+	DCW	32138	;  2 0x7d8a  0.98077
136
+	DCW	31357	;  3 0x7a7d  0.95694
137
+	DCW	30274	;  4 0x7642  0.92389
138
+	DCW	28899	;  5 0x70e3  0.88193
139
+	DCW	27246	;  6 0x6a6e  0.83148
140
+	DCW	25330	;  7 0x62f2  0.77301
141
+	DCW	23170	;  8 0x5a82  0.70709
142
+	DCW	20788	;  9 0x5134  0.63440
143
+	DCW	18205	; 10 0x471d  0.55557
144
+	DCW	15447	; 11 0x3c57  0.47141
145
+	DCW	12540	; 12 0x30fc  0.38269
146
+	DCW	 9512	; 13 0x2528  0.29028
147
+	DCW	 6393	; 14 0x18f9  0.19510
148
+	DCW	 3212	; 15 0x0c8c  0.09802
149
+	DCW	    0	; 16 0x0000  0.00000
150
+	DCW	-3212	; 17 0xf374 -0.09802
151
+	DCW	-6393	; 18 0xe707 -0.19510
152
+	DCW	-9512	; 19 0xdad8 -0.29028
153
+	DCW	-12540	; 20 0xcf04 -0.38269
154
+	DCW	-15447	; 21 0xc3a9 -0.47141
155
+	DCW	-18205	; 22 0xb8e3 -0.55557
156
+	DCW	-20788	; 23 0xaecc -0.63440
157
+	DCW	-23170	; 24 0xa57e -0.70709
158
+	DCW	-25330	; 25 0x9d0e -0.77301
159
+	DCW	-27246	; 26 0x9592 -0.83148
160
+	DCW	-28899	; 27 0x8f1d -0.88193
161
+	DCW	-30274	; 28 0x89be -0.92389
162
+	DCW	-31357	; 29 0x8583 -0.95694
163
+	DCW	-32138	; 30 0x8276 -0.98077
164
+	DCW	-32610	; 31 0x809e -0.99518
165
+	DCW	-32768	; 32 0x8000 -1.00000
166
+	DCW	-32610	; 33 0x809e -0.99518
167
+	DCW	-32138	; 34 0x8276 -0.98077
168
+	DCW	-31357	; 35 0x8583 -0.95694
169
+	DCW	-30274	; 36 0x89be -0.92389
170
+	DCW	-28899	; 37 0x8f1d -0.88193
171
+	DCW	-27246	; 38 0x9592 -0.83148
172
+	DCW	-25330	; 39 0x9d0e -0.77301
173
+	DCW	-23170	; 40 0xa57e -0.70709
174
+	DCW	-20788	; 41 0xaecc -0.63440
175
+	DCW	-18205	; 42 0xb8e3 -0.55557
176
+	DCW	-15447	; 43 0xc3a9 -0.47141
177
+	DCW	-12540	; 44 0xcf04 -0.38269
178
+	DCW	-9512	; 45 0xdad8 -0.29028
179
+	DCW	-6393	; 46 0xe707 -0.19510
180
+	DCW	-3212	; 47 0xf374 -0.09802
181
+	DCW	    0	; 48 0x0000  0.00000
182
+	DCW	 3212	; 49 0x0c8c  0.09802
183
+	DCW	 6393	; 50 0x18f9  0.19510
184
+	DCW	 9512	; 51 0x2528  0.29028
185
+	DCW	12540	; 52 0x30fc  0.38269
186
+	DCW	15447	; 53 0x3c57  0.47141
187
+	DCW	18205	; 54 0x471d  0.55557
188
+	DCW	20788	; 55 0x5134  0.63440
189
+	DCW	23170	; 56 0x5a82  0.70709
190
+	DCW	25330	; 57 0x62f2  0.77301
191
+	DCW	27246	; 58 0x6a6e  0.83148
192
+	DCW	28899	; 59 0x70e3  0.88193
193
+	DCW	30274	; 60 0x7642  0.92389
194
+	DCW	31357	; 61 0x7a7d  0.95694
195
+	DCW	32138	; 62 0x7d8a  0.98077
196
+	DCW	32610	; 63 0x7f62  0.99518
197
+TabSin 
198
+	DCW	    0	;  0 0x0000  0.00000
199
+	DCW	 3212	;  1 0x0c8c  0.09802
200
+	DCW	 6393	;  2 0x18f9  0.19510
201
+	DCW	 9512	;  3 0x2528  0.29028
202
+	DCW	12540	;  4 0x30fc  0.38269
203
+	DCW	15447	;  5 0x3c57  0.47141
204
+	DCW	18205	;  6 0x471d  0.55557
205
+	DCW	20788	;  7 0x5134  0.63440
206
+	DCW	23170	;  8 0x5a82  0.70709
207
+	DCW	25330	;  9 0x62f2  0.77301
208
+	DCW	27246	; 10 0x6a6e  0.83148
209
+	DCW	28899	; 11 0x70e3  0.88193
210
+	DCW	30274	; 12 0x7642  0.92389
211
+	DCW	31357	; 13 0x7a7d  0.95694
212
+	DCW	32138	; 14 0x7d8a  0.98077
213
+	DCW	32610	; 15 0x7f62  0.99518
214
+	DCW	32767	; 16 0x7fff  0.99997
215
+	DCW	32610	; 17 0x7f62  0.99518
216
+	DCW	32138	; 18 0x7d8a  0.98077
217
+	DCW	31357	; 19 0x7a7d  0.95694
218
+	DCW	30274	; 20 0x7642  0.92389
219
+	DCW	28899	; 21 0x70e3  0.88193
220
+	DCW	27246	; 22 0x6a6e  0.83148
221
+	DCW	25330	; 23 0x62f2  0.77301
222
+	DCW	23170	; 24 0x5a82  0.70709
223
+	DCW	20788	; 25 0x5134  0.63440
224
+	DCW	18205	; 26 0x471d  0.55557
225
+	DCW	15447	; 27 0x3c57  0.47141
226
+	DCW	12540	; 28 0x30fc  0.38269
227
+	DCW	 9512	; 29 0x2528  0.29028
228
+	DCW	 6393	; 30 0x18f9  0.19510
229
+	DCW	 3212	; 31 0x0c8c  0.09802
230
+	DCW	    0	; 32 0x0000  0.00000
231
+	DCW	-3212	; 33 0xf374 -0.09802
232
+	DCW	-6393	; 34 0xe707 -0.19510
233
+	DCW	-9512	; 35 0xdad8 -0.29028
234
+	DCW	-12540	; 36 0xcf04 -0.38269
235
+	DCW	-15447	; 37 0xc3a9 -0.47141
236
+	DCW	-18205	; 38 0xb8e3 -0.55557
237
+	DCW	-20788	; 39 0xaecc -0.63440
238
+	DCW	-23170	; 40 0xa57e -0.70709
239
+	DCW	-25330	; 41 0x9d0e -0.77301
240
+	DCW	-27246	; 42 0x9592 -0.83148
241
+	DCW	-28899	; 43 0x8f1d -0.88193
242
+	DCW	-30274	; 44 0x89be -0.92389
243
+	DCW	-31357	; 45 0x8583 -0.95694
244
+	DCW	-32138	; 46 0x8276 -0.98077
245
+	DCW	-32610	; 47 0x809e -0.99518
246
+	DCW	-32768	; 48 0x8000 -1.00000
247
+	DCW	-32610	; 49 0x809e -0.99518
248
+	DCW	-32138	; 50 0x8276 -0.98077
249
+	DCW	-31357	; 51 0x8583 -0.95694
250
+	DCW	-30274	; 52 0x89be -0.92389
251
+	DCW	-28899	; 53 0x8f1d -0.88193
252
+	DCW	-27246	; 54 0x9592 -0.83148
253
+	DCW	-25330	; 55 0x9d0e -0.77301
254
+	DCW	-23170	; 56 0xa57e -0.70709
255
+	DCW	-20788	; 57 0xaecc -0.63440
256
+	DCW	-18205	; 58 0xb8e3 -0.55557
257
+	DCW	-15447	; 59 0xc3a9 -0.47141
258
+	DCW	-12540	; 60 0xcf04 -0.38269
259
+	DCW	-9512	; 61 0xdad8 -0.29028
260
+	DCW	-6393	; 62 0xe707 -0.19510
261
+	DCW	-3212	; 63 0xf374 -0.09802
262
+
263
+
264
+		
265
+		
266
+	END	

+ 92
- 0
PjtKEIL_StepFinal/Src/GestionSon.s View File

@@ -0,0 +1,92 @@
1
+	PRESERVE8
2
+	THUMB   
3
+		
4
+
5
+; ====================== zone de réservation de données,  ======================================
6
+;Section RAM (read only) :
7
+	area    mesdata,data,readonly
8
+
9
+
10
+;Section RAM (read write):
11
+	area    maram,data,readwrite
12
+		
13
+TableauIndex   	dcd 0
14
+SortieSon    	dcd 0
15
+
16
+   import LongueurSon
17
+   import Son
18
+   import PWM_Set_Value_TIM3_Ch3
19
+; ===============================================================================================
20
+	
21
+    export CallBackSon
22
+	export SortieSon
23
+	export TableauIndex
24
+
25
+		
26
+;Section ROM code (read only) :		
27
+	area    moncode,code,readonly
28
+; écrire le code ici		
29
+
30
+
31
+CallBackSon proc 
32
+	ldr r0, =TableauIndex
33
+	ldr r1, [r0]  ; r1 = valeur tableauIndex
34
+	
35
+	ldr r2, =LongueurSon
36
+	ldr r2, [r2]
37
+		
38
+	cmp r1, r2
39
+	bne jouer
40
+	
41
+	; dans le cas où on joue pas, on laisse la valeur à zéro
42
+	mov r0, #0
43
+	ldr r2, =SortieSon
44
+	str r0, [r2]
45
+	bx lr
46
+
47
+jouer
48
+
49
+	; on incrémente l'index pour la prochaine fois
50
+	add r1, #1
51
+	; on l'écrit dans l'espace mémoire à l'avance
52
+	str r1, [r0]
53
+	
54
+	
55
+	
56
+	; puis on décrémente pour récupérer l'index de départ
57
+	sub r1, #1
58
+	
59
+	; donc r0 est maintenant libre vu que j'ai plus besoin d'aller écrire dans la mémoire l'index
60
+    
61
+    ldr r3, =Son
62
+	; on multiplie par deux l'index pour avoir le bon décalage qui est sur 8 bits dans ce cas
63
+	
64
+	; dans r4 on a la valeur de l'index du tableau, je peux donc incrémenter mon index et le store pour libérer r1 dans la suite du code
65
+	
66
+	mov r0, #2
67
+	mul r1, r0
68
+	ldrsh r3, [r3,r1]	
69
+	
70
+	;on met le signal en full positif
71
+	add r3, #32768
72
+	
73
+	; on fait une règle de trois
74
+	mov r0, #719
75
+	mul r3,r0
76
+	mov r0, #65535
77
+	udiv r3, r0
78
+	
79
+	;r0 est libre ici car on a  fini les calculs
80
+	ldr r0, =SortieSon
81
+	str r3, [r0] ; il faut modifier sortie son pour pouvoir être dans la plage 0;719  au lieu de -32767
82
+	mov r0, r3 ; on met cette fois-ci la valeur du point dans R0 pour respecter l'appel AAPCS
83
+	
84
+	b PWM_Set_Value_TIM3_Ch3
85
+
86
+	;bx lr
87
+   endp
88
+
89
+
90
+		
91
+		
92
+	END	

+ 78
- 0
PjtKEIL_StepFinal/Src/ModuleAffichage/Affichage_Valise.h View File

@@ -0,0 +1,78 @@
1
+
2
+/* Fichier devant contenir l'ensemble de fichiers utiles pour le projet LaserQuest
3
+et qui concenent l'affichage sur la valise */
4
+/* mais non disponible en version source pour les étudiants.						*/
5
+
6
+#ifndef _AFFICHAGE_VALISE_H__
7
+#define _AFFICHAGE_VALISE_H__
8
+#include "stm32f10x.h"
9
+
10
+
11
+/**
12
+	* @brief  Initialise les périphériques nécessaires à l'affichage sur la Mallette
13
+	*					et gère la cible active. S'utilise aussi avec les ùmodules affichages simple (pas de mallette)
14
+  * @note   Utilise TIM1, PA5, PA6 pour les cibles, PC7 à PC9 pour SPI émulé
15
+	*					 utilise aussi une interruption sut TIM1, prio 8.
16
+	* @param  none
17
+  * @retval None
18
+  */
19
+void Init_Affichage(void);
20
+
21
+
22
+/**
23
+	* @brief  Prépare l'affichage 2 digit sur l'afficheur demandé
24
+  * @note   Exemple : Prepare_Afficheur(2, 99); 
25
+	*         prépare l'affichage de la valeur 99 sur l'afficheur n°2
26
+	* 			  L'action est différée à l'exécution de Mise_A_Jour_Afficheurs_LED()
27
+	* @param  char Aff : de 1 à 4 ; char Valeur de 0 à 99
28
+  * @retval None
29
+  */
30
+void Prepare_Afficheur(char Aff, char Valeur);
31
+
32
+
33
+
34
+void Prepare_Set_Point_Unite(char Aff);
35
+void Prepare_Clear_Point_Unite(char Aff);
36
+
37
+
38
+/**
39
+	* @brief  Prépare l'allumage de la LED demandée
40
+  * @note   Exemple : Prepare_Set_LED(LED_Cible_2); 
41
+	*         prépare l'allumage de la LED correspondant à la cible n°2
42
+	*					L'action est différée à l'exécution de Mise_A_Jour_Afficheurs_LED()
43
+	* @param  voir #define ci-dessous
44
+  * @retval None
45
+  */
46
+void Prepare_Set_LED(char LED);
47
+void Prepare_Clear_LED(char LED);
48
+
49
+
50
+/**
51
+	* @brief  Effectue l'action d'écriture dans le module d'affichage
52
+	*					à partir de tout ce qui a été préparé auparavant.
53
+  * @note   
54
+	* @param  None
55
+  * @retval None
56
+  */
57
+void Mise_A_Jour_Afficheurs_LED(void);
58
+
59
+/**
60
+	* @brief  Spécifie le capteut actif, à savoir celui effectivement relié
61
+	*					aux sorties disponibles sur la malette
62
+  * @note   Exemple : Choix_Capteur(1)        
63
+	* @param  1 à 4
64
+  * @retval None
65
+  */
66
+void Choix_Capteur(char Capteur);
67
+// define utile pour la fonction Prepare_Set_LED et Prepare_Clear_LED
68
+#define LED_LCD_R 5
69
+#define LED_LCD_V  4
70
+#define LED_Cible_4 3
71
+#define LED_Cible_3 2
72
+#define LED_Cible_2 1
73
+#define LED_Cible_1 0
74
+
75
+
76
+
77
+#endif
78
+

+ 177
- 0
PjtKEIL_StepFinal/Src/principal.c View File

@@ -0,0 +1,177 @@
1
+#include <stdlib.h>
2
+#include "Affichage_Valise.h"
3
+#include "DriverJeuLaser.h"
4
+
5
+
6
+#define SEUIL_MIN 0x00093510
7
+#define SEUIL_MAX 0x01933510
8
+
9
+
10
+	//short int = 16 bit signé
11
+	//char = 8 bit non signé (0 à 255)
12
+extern int PeriodeSonMicroSec;
13
+
14
+extern void CallBackSon(void);
15
+
16
+extern int TableauIndex;
17
+
18
+extern int LongueurSon;
19
+
20
+extern int DFT_ModuleAuCarre(short int*, char);
21
+
22
+extern short int LeSignal;
23
+
24
+short int dma_buff[64] ;
25
+
26
+int res[4];
27
+
28
+char cible_active;
29
+
30
+typedef struct {
31
+		short int valeur_k, score, confirmations;
32
+} Joueur;
33
+
34
+Joueur tous_joueurs[4];
35
+
36
+
37
+void jouerSon() {
38
+	//on remet l'index du tableau à zéro, du coup ça va jouer une fois le son
39
+	TableauIndex = 0;
40
+}
41
+
42
+
43
+void changer_cible(){
44
+	
45
+	int i;
46
+	
47
+	for(i = 0; i < 4; i++){
48
+		tous_joueurs[i].confirmations = 0;
49
+		Prepare_Afficheur(i+1,tous_joueurs[i].score);
50
+	}
51
+	
52
+	int prochaine_cible = (rand() % 4 + 1);
53
+	
54
+	Choix_Capteur(prochaine_cible);
55
+	
56
+	Prepare_Set_LED(prochaine_cible);
57
+	Prepare_Clear_LED(cible_active);
58
+	//Mise_A_Jour_Afficheurs_LED();
59
+	cible_active = prochaine_cible;
60
+}
61
+
62
+
63
+
64
+
65
+
66
+
67
+void faire_dft() {
68
+	
69
+	
70
+	//on fait la mesure
71
+	
72
+	Start_DMA1(64);
73
+	Wait_On_End_Of_DMA1();
74
+	Stop_DMA1;
75
+	
76
+	
77
+	//on l'exploite en regardant que les raies qui nous intéresse
78
+	char k[4] = {17,18,19,20};
79
+
80
+	int i;
81
+	
82
+	/*
83
+	for(i=0;i<64;i++){
84
+		res[i] = DFT_ModuleAuCarre(dma_buff, i);
85
+	}*/
86
+	
87
+	for(i=0;i<4;i++){
88
+		res[i] = DFT_ModuleAuCarre(dma_buff, k[i]);
89
+		if (res[i] > SEUIL_MIN && res[i] < SEUIL_MAX){
90
+			if(tous_joueurs[i].confirmations < 5){
91
+				tous_joueurs[i].confirmations++;
92
+				if(tous_joueurs[i].confirmations == 5){
93
+					jouerSon();
94
+					tous_joueurs[i].score++;
95
+					//changer_cible();
96
+				}
97
+			}				
98
+		}
99
+	}
100
+	
101
+	
102
+}
103
+
104
+
105
+int main(void)
106
+{
107
+
108
+// ===========================================================================
109
+// ============= INIT PERIPH (faites qu'une seule fois)  =====================
110
+// ===========================================================================
111
+
112
+// Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers
113
+CLOCK_Configure();
114
+	
115
+	// 72Mhz  pour 1s
116
+	// ? ticks pour 5*10^-3 s
117
+	// règle de trois.
118
+	
119
+	//on décide de faire une DFT toutes les 5 ms
120
+	Systick_Period_ff(360000);
121
+	Systick_Prio_IT(1,faire_dft);
122
+	SysTick_On;
123
+	SysTick_Enable_IT; // activer l'interruption configurée
124
+	Init_Conversion_On_Trig_Timer_ff( ADC1, TIM2_CC2, 225 );
125
+	
126
+	//il faut configurer la fréquence d'échantillonage de l'ADC
127
+	Init_TimingADC_ActiveADC_ff(ADC1,72);
128
+	Single_Channel_ADC(ADC1,2);
129
+	Init_Conversion_On_Trig_Timer_ff( ADC1, TIM2_CC2, 225 );
130
+	Init_ADC1_DMA1( 0, dma_buff );
131
+		
132
+
133
+//============================================================================	
134
+	
135
+	//initialiser les pistolets
136
+	Init_Affichage();
137
+	
138
+	srand(20);
139
+	
140
+	
141
+	
142
+	int nbCycles = PeriodeSonMicroSec * 72;    //PeriodeSonMicroSec * 0.000001 * 72 000 000
143
+	
144
+  Timer_1234_Init_ff( TIM4, nbCycles);
145
+	Timer_1234_Init_ff( TIM1, 72000000 * 3); // Permet de lancer le timer de changement de cible toutes les 3 secondes
146
+	
147
+	//avant de config le timer on va mettre la taille de l'index supérieur à la taille du fichier audio
148
+	//comme ça, le logiciel ne va pas jouer le son de suite
149
+	
150
+	TableauIndex = LongueurSon;
151
+	
152
+	
153
+  Active_IT_Debordement_Timer( TIM4, 2, CallBackSon );
154
+	Active_IT_Debordement_Timer( TIM1, 2, changer_cible);
155
+	
156
+	PWM_Init_ff( TIM3, 3, 720); //initialisation de la PWM sur canal 3 timer 3
157
+	
158
+	//on met période tick à 720 sur une clock à 72 Mhz
159
+	
160
+	//période de 720/72.10^6 =   72 / 72.10^5 = 1 / 10^5 = 10^-5 = 10 µs 
161
+
162
+  // donc fréquence de 10^5 Hz = 100 kHz
163
+	
164
+	GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
165
+		
166
+	
167
+	
168
+	
169
+	
170
+	
171
+while	(1)
172
+	{
173
+	}
174
+}
175
+
176
+
177
+

+ 335
- 0
PjtKEIL_StepFinal/Src/startup-rvds.s View File

@@ -0,0 +1,335 @@
1
+;******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
2
+;* File Name          : startup_stm32f10x_md.s
3
+;* Author             : MCD Application Team
4
+;* Version            : V3.5.0
5
+;* Date               : 11-March-2011
6
+;* Description        : STM32F10x Medium Density Devices vector table for MDK-ARM 
7
+;*                      toolchain.  
8
+;*                      This module performs:
9
+;*                      - Set the initial SP
10
+;*                      - Set the initial PC == Reset_Handler
11
+;*                      - Set the vector table entries with the exceptions ISR address
12
+;*                      - Configure the clock system
13
+;*                      - Branches to __main in the C library (which eventually
14
+;*                        calls main()).
15
+;*                      After Reset the CortexM3 processor is in Thread mode,
16
+;*                      priority is Privileged, and the Stack is set to Main.
17
+;* <<< Use Configuration Wizard in Context Menu >>>   
18
+;*******************************************************************************
19
+; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
20
+; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
21
+; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
22
+; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
23
+; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
24
+; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
25
+;*******************************************************************************
26
+
27
+; Amount of memory (in bytes) allocated for Stack
28
+; Tailor this value to your application needs
29
+; <h> Stack Configuration
30
+;   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
31
+; </h>
32
+
33
+Stack_Size      EQU     0x00000400
34
+
35
+                AREA    STACK, NOINIT, READWRITE, ALIGN=3
36
+Stack_Mem       SPACE   Stack_Size
37
+__initial_sp
38
+
39
+
40
+; <h> Heap Configuration
41
+;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
42
+; </h>
43
+
44
+Heap_Size       EQU     0x00000200
45
+
46
+                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
47
+__heap_base
48
+Heap_Mem        SPACE   Heap_Size
49
+__heap_limit
50
+
51
+                PRESERVE8
52
+                THUMB
53
+
54
+
55
+; Vector Table Mapped to Address 0 at Reset
56
+                AREA    RESET, DATA, READONLY
57
+                EXPORT  __Vectors
58
+                EXPORT  __Vectors_End
59
+                EXPORT  __Vectors_Size
60
+
61
+__Vectors       DCD     __initial_sp               ; Top of Stack
62
+                DCD     Reset_Handler              ; Reset Handler
63
+                DCD     NMI_Handler                ; NMI Handler
64
+                DCD     HardFault_Handler          ; Hard Fault Handler
65
+                DCD     MemManage_Handler          ; MPU Fault Handler
66
+                DCD     BusFault_Handler           ; Bus Fault Handler
67
+                DCD     UsageFault_Handler         ; Usage Fault Handler
68
+                DCD     0                          ; Reserved
69
+                DCD     0                          ; Reserved
70
+                DCD     0                          ; Reserved
71
+                DCD     0                          ; Reserved
72
+                DCD     SVC_Handler                ; SVCall Handler
73
+                DCD     DebugMon_Handler           ; Debug Monitor Handler
74
+                DCD     0                          ; Reserved
75
+                DCD     PendSV_Handler             ; PendSV Handler
76
+                DCD     SysTick_Handler            ; SysTick Handler
77
+
78
+                ; External Interrupts
79
+                DCD     WWDG_IRQHandler            ; Window Watchdog
80
+                DCD     PVD_IRQHandler             ; PVD through EXTI Line detect
81
+                DCD     TAMPER_IRQHandler          ; Tamper
82
+                DCD     RTC_IRQHandler             ; RTC
83
+                DCD     FLASH_IRQHandler           ; Flash
84
+                DCD     RCC_IRQHandler             ; RCC
85
+                DCD     EXTI0_IRQHandler           ; EXTI Line 0
86
+                DCD     EXTI1_IRQHandler           ; EXTI Line 1
87
+                DCD     EXTI2_IRQHandler           ; EXTI Line 2
88
+                DCD     EXTI3_IRQHandler           ; EXTI Line 3
89
+                DCD     EXTI4_IRQHandler           ; EXTI Line 4
90
+                DCD     DMA1_Channel1_IRQHandler   ; DMA1 Channel 1
91
+                DCD     DMA1_Channel2_IRQHandler   ; DMA1 Channel 2
92
+                DCD     DMA1_Channel3_IRQHandler   ; DMA1 Channel 3
93
+                DCD     DMA1_Channel4_IRQHandler   ; DMA1 Channel 4
94
+                DCD     DMA1_Channel5_IRQHandler   ; DMA1 Channel 5
95
+                DCD     DMA1_Channel6_IRQHandler   ; DMA1 Channel 6
96
+                DCD     DMA1_Channel7_IRQHandler   ; DMA1 Channel 7
97
+                DCD     ADC1_2_IRQHandler          ; ADC1_2
98
+                DCD     USB_HP_CAN1_TX_IRQHandler  ; USB High Priority or CAN1 TX
99
+                DCD     USB_LP_CAN1_RX0_IRQHandler ; USB Low  Priority or CAN1 RX0
100
+                DCD     CAN1_RX1_IRQHandler        ; CAN1 RX1
101
+                DCD     CAN1_SCE_IRQHandler        ; CAN1 SCE
102
+                DCD     EXTI9_5_IRQHandler         ; EXTI Line 9..5
103
+                DCD     TIM1_BRK_IRQHandler        ; TIM1 Break
104
+                DCD     TIM1_UP_IRQHandler         ; TIM1 Update
105
+                DCD     TIM1_TRG_COM_IRQHandler    ; TIM1 Trigger and Commutation
106
+                DCD     TIM1_CC_IRQHandler         ; TIM1 Capture Compare
107
+                DCD     TIM2_IRQHandler            ; TIM2
108
+                DCD     TIM3_IRQHandler            ; TIM3
109
+                DCD     TIM4_IRQHandler            ; TIM4
110
+                DCD     I2C1_EV_IRQHandler         ; I2C1 Event
111
+                DCD     I2C1_ER_IRQHandler         ; I2C1 Error
112
+                DCD     I2C2_EV_IRQHandler         ; I2C2 Event
113
+                DCD     I2C2_ER_IRQHandler         ; I2C2 Error
114
+                DCD     SPI1_IRQHandler            ; SPI1
115
+                DCD     SPI2_IRQHandler            ; SPI2
116
+                DCD     USART1_IRQHandler          ; USART1
117
+                DCD     USART2_IRQHandler          ; USART2
118
+                DCD     USART3_IRQHandler          ; USART3
119
+                DCD     EXTI15_10_IRQHandler       ; EXTI Line 15..10
120
+                DCD     RTCAlarm_IRQHandler        ; RTC Alarm through EXTI Line
121
+                DCD     USBWakeUp_IRQHandler       ; USB Wakeup from suspend
122
+__Vectors_End
123
+
124
+__Vectors_Size  EQU  __Vectors_End - __Vectors
125
+
126
+                AREA    |.text|, CODE, READONLY
127
+
128
+; Reset handler
129
+Reset_Handler    PROC
130
+                 EXPORT  Reset_Handler             [WEAK]
131
+     IMPORT  __main
132
+     
133
+                 LDR     R0, =SystemInit
134
+                 BLX     R0
135
+
136
+;
137
+; Enable UsageFault, MemFault and Busfault interrupts
138
+;
139
+_SHCSR			EQU     0xE000ED24		; SHCSR is located at address 0xE000ED24
140
+				LDR.W	R0, =_SHCSR				
141
+				LDR 	R1, [R0]				; Read CPACR
142
+				ORR 	R1, R1, #(0x7 << 16)	; Set bits 16,17,18 to enable usagefault, busfault, memfault interrupts
143
+				STR 	R1, [R0]				; Write back the modified value to the CPACR
144
+				DSB								; Wait for store to complete
145
+
146
+;
147
+; Set priority grouping (PRIGROUP) in AIRCR to 3 (16 levels for group priority and 0 for subpriority)
148
+;
149
+_AIRCR			EQU		0xE000ED0C
150
+_AIRCR_VAL		EQU		0x05FA0300
151
+				LDR.W	R0, =_AIRCR
152
+				LDR.W	R1, =_AIRCR_VAL
153
+				STR		R1,[R0]
154
+		
155
+;
156
+; Finaly, jump to main function (void main (void))
157
+;
158
+                LDR     R0, =__main
159
+                BX      R0
160
+                ENDP
161
+
162
+SystemInit		PROC				 
163
+				EXPORT  SystemInit                    [WEAK]    
164
+				BX		LR
165
+				ENDP
166
+
167
+; Dummy Exception Handlers (infinite loops which can be modified)
168
+
169
+NMI_Handler     PROC
170
+                EXPORT  NMI_Handler                [WEAK]
171
+                B       .
172
+                ENDP
173
+HardFault_Handler\
174
+                PROC
175
+                EXPORT  HardFault_Handler          [WEAK]
176
+                B       .
177
+                ENDP
178
+MemManage_Handler\
179
+                PROC
180
+                EXPORT  MemManage_Handler          [WEAK]
181
+                B       .
182
+                ENDP
183
+BusFault_Handler\
184
+                PROC
185
+                EXPORT  BusFault_Handler           [WEAK]
186
+                B       .
187
+                ENDP
188
+UsageFault_Handler\
189
+                PROC
190
+                EXPORT  UsageFault_Handler         [WEAK]
191
+                B       .
192
+                ENDP
193
+SVC_Handler     PROC
194
+                EXPORT  SVC_Handler                [WEAK]
195
+                B       .
196
+                ENDP
197
+DebugMon_Handler\
198
+                PROC
199
+                EXPORT  DebugMon_Handler           [WEAK]
200
+                B       .
201
+                ENDP
202
+PendSV_Handler  PROC
203
+                EXPORT  PendSV_Handler             [WEAK]
204
+                B       .
205
+                ENDP
206
+SysTick_Handler PROC
207
+                EXPORT  SysTick_Handler            [WEAK]
208
+                B       .
209
+                ENDP
210
+
211
+Default_Handler PROC
212
+
213
+                EXPORT  WWDG_IRQHandler            [WEAK]
214
+                EXPORT  PVD_IRQHandler             [WEAK]
215
+                EXPORT  TAMPER_IRQHandler          [WEAK]
216
+                EXPORT  RTC_IRQHandler             [WEAK]
217
+                EXPORT  FLASH_IRQHandler           [WEAK]
218
+                EXPORT  RCC_IRQHandler             [WEAK]
219
+                EXPORT  EXTI0_IRQHandler           [WEAK]
220
+                EXPORT  EXTI1_IRQHandler           [WEAK]
221
+                EXPORT  EXTI2_IRQHandler           [WEAK]
222
+                EXPORT  EXTI3_IRQHandler           [WEAK]
223
+                EXPORT  EXTI4_IRQHandler           [WEAK]
224
+                EXPORT  DMA1_Channel1_IRQHandler   [WEAK]
225
+                EXPORT  DMA1_Channel2_IRQHandler   [WEAK]
226
+                EXPORT  DMA1_Channel3_IRQHandler   [WEAK]
227
+                EXPORT  DMA1_Channel4_IRQHandler   [WEAK]
228
+                EXPORT  DMA1_Channel5_IRQHandler   [WEAK]
229
+                EXPORT  DMA1_Channel6_IRQHandler   [WEAK]
230
+                EXPORT  DMA1_Channel7_IRQHandler   [WEAK]
231
+                EXPORT  ADC1_2_IRQHandler          [WEAK]
232
+                EXPORT  USB_HP_CAN1_TX_IRQHandler  [WEAK]
233
+                EXPORT  USB_LP_CAN1_RX0_IRQHandler [WEAK]
234
+                EXPORT  CAN1_RX1_IRQHandler        [WEAK]
235
+                EXPORT  CAN1_SCE_IRQHandler        [WEAK]
236
+                EXPORT  EXTI9_5_IRQHandler         [WEAK]
237
+                EXPORT  TIM1_BRK_IRQHandler        [WEAK]
238
+                EXPORT  TIM1_UP_IRQHandler         [WEAK]
239
+                EXPORT  TIM1_TRG_COM_IRQHandler    [WEAK]
240
+                EXPORT  TIM1_CC_IRQHandler         [WEAK]
241
+                EXPORT  TIM2_IRQHandler            [WEAK]
242
+                EXPORT  TIM3_IRQHandler            [WEAK]
243
+                EXPORT  TIM4_IRQHandler            [WEAK]
244
+                EXPORT  I2C1_EV_IRQHandler         [WEAK]
245
+                EXPORT  I2C1_ER_IRQHandler         [WEAK]
246
+                EXPORT  I2C2_EV_IRQHandler         [WEAK]
247
+                EXPORT  I2C2_ER_IRQHandler         [WEAK]
248
+                EXPORT  SPI1_IRQHandler            [WEAK]
249
+                EXPORT  SPI2_IRQHandler            [WEAK]
250
+                EXPORT  USART1_IRQHandler          [WEAK]
251
+                EXPORT  USART2_IRQHandler          [WEAK]
252
+                EXPORT  USART3_IRQHandler          [WEAK]
253
+                EXPORT  EXTI15_10_IRQHandler       [WEAK]
254
+                EXPORT  RTCAlarm_IRQHandler        [WEAK]
255
+                EXPORT  USBWakeUp_IRQHandler       [WEAK]
256
+
257
+WWDG_IRQHandler
258
+PVD_IRQHandler
259
+TAMPER_IRQHandler
260
+RTC_IRQHandler
261
+FLASH_IRQHandler
262
+RCC_IRQHandler
263
+EXTI0_IRQHandler
264
+EXTI1_IRQHandler
265
+EXTI2_IRQHandler
266
+EXTI3_IRQHandler
267
+EXTI4_IRQHandler
268
+DMA1_Channel1_IRQHandler
269
+DMA1_Channel2_IRQHandler
270
+DMA1_Channel3_IRQHandler
271
+DMA1_Channel4_IRQHandler
272
+DMA1_Channel5_IRQHandler
273
+DMA1_Channel6_IRQHandler
274
+DMA1_Channel7_IRQHandler
275
+ADC1_2_IRQHandler
276
+USB_HP_CAN1_TX_IRQHandler
277
+USB_LP_CAN1_RX0_IRQHandler
278
+CAN1_RX1_IRQHandler
279
+CAN1_SCE_IRQHandler
280
+EXTI9_5_IRQHandler
281
+TIM1_BRK_IRQHandler
282
+TIM1_UP_IRQHandler
283
+TIM1_TRG_COM_IRQHandler
284
+TIM1_CC_IRQHandler
285
+TIM2_IRQHandler
286
+TIM3_IRQHandler
287
+TIM4_IRQHandler
288
+I2C1_EV_IRQHandler
289
+I2C1_ER_IRQHandler
290
+I2C2_EV_IRQHandler
291
+I2C2_ER_IRQHandler
292
+SPI1_IRQHandler
293
+SPI2_IRQHandler
294
+USART1_IRQHandler
295
+USART2_IRQHandler
296
+USART3_IRQHandler
297
+EXTI15_10_IRQHandler
298
+RTCAlarm_IRQHandler
299
+USBWakeUp_IRQHandler
300
+
301
+                B       .
302
+
303
+                ENDP
304
+
305
+                ALIGN
306
+
307
+;*******************************************************************************
308
+; User Stack and Heap initialization
309
+;*******************************************************************************
310
+                 IF      :DEF:__MICROLIB           
311
+                
312
+                 EXPORT  __initial_sp
313
+                 EXPORT  __heap_base
314
+                 EXPORT  __heap_limit
315
+                
316
+                 ELSE
317
+                
318
+                 IMPORT  __use_two_region_memory
319
+                 EXPORT  __user_initial_stackheap
320
+                 
321
+__user_initial_stackheap
322
+
323
+                 LDR     R0, =  Heap_Mem
324
+                 LDR     R1, =(Stack_Mem + Stack_Size)
325
+                 LDR     R2, = (Heap_Mem +  Heap_Size)
326
+                 LDR     R3, = Stack_Mem
327
+                 BX      LR
328
+
329
+                 ALIGN
330
+
331
+                 ENDIF
332
+
333
+                 END
334
+
335
+;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE*****

+ 1547
- 0
PjtKEIL_StepFinal/StepDFT.uvprojx
File diff suppressed because it is too large
View File


Loading…
Cancel
Save