Revision 301

View differences:

branch/font/Emb_App.tws
17 17
[WORKSPACE_FILE_STATES]
18 18
"E:\tp_info6_2018_font\Emb_App\Debug\mr308.inc" 150 150 1430 351 0 6 
19 19
"E:\tp_info6_2018_font\Emb_App\conf_noyau.cfg" 75 75 1430 351 0 2 
20
"E:\tp_info6_2018_font\Emb_App\crt0mr.a30" -8 -30 1596 539 1 0 
21
"E:\tp_info6_2018_font\Emb_App\programme_principal_etud.c" 0 0 1596 539 0 1 
20
"E:\tp_info6_2018_font\Emb_App\crt0mr.a30" 0 0 1596 539 0 0 
21
"E:\tp_info6_2018_font\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 1 
22 22
"E:\tp_info6_2018_font\bsp\periph.c" 100 100 1430 351 0 4 
23 23
"E:\tp_info6_2018_font\bsp\sfr32c83.h" 100 100 1430 351 0 3 
24 24
"E:\tp_info6_2018_font\bsp\uart0.c" 150 150 1430 351 0 5 
branch/font/Emb_App/SessionM32C_E8a_system.ini
25 25
[Target]
26 26
M32C E8a SYSTEM=Renesas Communications
27 27
[USER_DATA]
28
RESET=ff002a
28
RESET=ff0036
branch/font/Emb_App/SessionM32C_E8a_system.hsf
141 141
"{55384715-F881-421C-A548-D7D1ABE158E1}PDMRWndInstanceKey0" "{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" 
142 142
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_DENORMAL_MODE" "0" 
143 143
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_ROUND_MODE" "0" 
144
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000000" 
144
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000001" 
145 145
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000000" 
146 146
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_10" "0000000000000000" 
147 147
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_11" "0000000000000000" 
148 148
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_12" "0000000000000000" 
149 149
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_13" "0000000000000000" 
150 150
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_14" "0000000000000000" 
151
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000000" 
152
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF002A" 
153
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000000000" 
154
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000000" 
155
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000700" 
151
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000512" 
152
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF3590" 
153
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
154
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000AEC" 
155
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "00000000000008F0" 
156 156
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
157
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000000" 
157
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "00000000000000C0" 
158 158
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_21" "0000000000000000" 
159 159
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_22" "0000000000000000" 
160 160
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_23" "0000000000000000" 
......
169 169
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_31" "0000000000000000" 
170 170
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_32" "0000000000000000" 
171 171
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_33" "0000000000000000" 
172
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_34" "0000000000000000" 
172
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_34" "000000000000036A" 
173 173
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
174
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000000" 
175
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
176
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000000" 
177
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000000" 
174
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000009" 
175
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000120012" 
176
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000AEC" 
177
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000512" 
178 178
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_8" "0000000000000000" 
179 179
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_9" "0000000000000000" 
180 180
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_COUNT" "36" 
......
209 209
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
210 210
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "feu, 1, 0, P, Col, Hex, MA" 
211 211
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
212
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "num_piste1, 1, 0, P, Col, Dec, MA" 
212
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "capteur, 1, 0, P, Col, Hex, MA" 
213 213
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
214
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "num_piste, 1, 0, P, Col, Hex, MA" 
214
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "montee_noire, 1, 0, P, Col, Hex, MA" 
215 215
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
216
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "capteur, 1, 0, P, Col, Hex, MA" 
216
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "go, 1, 0, P, Col, Hex, MA" 
217 217
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
218 218
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "montee, 1, 0, P, Col, Hex, MA" 
219 219
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005_SCOPE" "Current Scope," 
220 220
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "a, 1, 0, P, Col, Hex, MA" 
221 221
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006_SCOPE" "Current Scope," 
222
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "7" 
222
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "5" 
223 223
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
224 224
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
225 225
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
......
321 321
[WINDOW_POSITION_STATE_DATA_VD3]
322 322
[WINDOW_POSITION_STATE_DATA_VD4]
323 323
[WINDOW_Z_ORDER]
324
"E:\tp_info6_2018_font\Emb_App\programme_principal_etud.c" 
324 325
"E:\tp_info6_2018_font\Emb_App\crt0mr.a30" 
325
"E:\tp_info6_2018_font\Emb_App\programme_principal_etud.c" 
326
"E:\tp_info6_2018_font\Emb_App\Debug\mr308.inc" 
326 327
"E:\tp_info6_2018_font\Emb_App\conf_noyau.cfg" 
327 328
"E:\tp_info6_2018_font\bsp\uart0.c" 
328
"E:\tp_info6_2018_font\Emb_App\Debug\mr308.inc" 
329 329
"E:\tp_info6_2018_font\bsp\periph.c" 
330 330
"E:\tp_info6_2018_font\bsp\sfr32c83.h" 
331 331
[TARGET_NAME]
......
374 374
[FLASH_DETAILS]
375 375
"" 0 0 "" 0 "" 0 0 "" 0 0 0 0 0 0 0 "" "" "" "" "" 
376 376
[BREAKPOINTS]
377
"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 100391144 1 "{00000000-0000-0000-C000-000000000046}" "" 
377
"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 100654760 1 "{00000000-0000-0000-C000-000000000046}" "" 
378 378
[END]
branch/font/Emb_App/programme_principal_etud.c
125 125
#define blue	0x0043
126 126
#define cyan	0x0042
127 127

  
128
const int distance_bord = 700;		//distance du bord souhait?e
129
const int angle_tourelle = 450;		//angle tourelle souhait?
128
int distance_bord = 700;		//distance du bord souhait?e
129
int angle_tourelle = 450;		//angle tourelle souhait?
130 130
int alpha;							//angle tourelle
131 131
int distance;						//distance du bord mesur?e
132 132
int distance1;
......
135 135
int vitesse_montee = 45;			//vitesse pendant la mont?e piste bleu
136 136
int vitesse_saut = 45;				//vitesse pendant le saut piste rouge
137 137
int vitesse_recep = 10;
138
int vitesse_retour_piste = 20;
138 139
int angle_roue = 0;						
139 140
int kroue = 1;						//coefficient asservissement tourelle
140 141
int ktour = 1;						//coefficient asservissement roues
141 142
int num_piste;						//valeur du p?riph?rique 'M'
142 143
int num_piste1;						//num?ro de la piste
143 144
int capteur;						//valeur du dernier capteur franchi
144
int a = 0;
145
char saut = 0;
145
char saut = 0;						//Indique quand est le saut piste rouge
146 146
int feu;
147 147
int feuv;
148
int montee = 0;
148
int montee_bleu = 0;						//indique quand est la mont?e piste bleu
149
int montee_noire = 0;						//indique quand est la mont?e piste bleu
150
int a = 0;
151
int go = 0;							//variable pour d?part de la voiture
149 152

  
150 153
void lecture_telemetre(){
151 154
	CanFrame requete;
......
159 162
		snd_dtq(CanTx, requete.msg); 
160 163
		wai_flg(ev_periph, 0x02, TWF_ANDW, &flag);	//Attente de lecture
161 164
		distance1 = periph[ADDR('U')].val;
162
		if(distance1 > 1500 || distance1 < -1500){}
165
		if(distance1 > 1500 || distance1 < -1500){}		//gestions des trous dans les barri?res de la piste
163 166
		else {
164 167
			distance = distance1;
165 168
		}
166
		dly_tsk(6);
169
		dly_tsk(8);
167 170
	}
168 171
}
169 172

  
......
179 182
		snd_dtq(CanTx, requete.msg); 
180 183
		wai_flg(ev_periph, 0x03, TWF_ANDW, &flag);	//Attente de lecture de l'angle des roues
181 184
		comm.data.rtr = 0;
182
		//if(saut == 0){
185
		if(saut == 0){
183 186
			angle_roue = kroue * (distance - distance_bord);	//Asservissement de l'angle
184
		//}
185
		if(saut == 1) {
187
		}
188
		if(saut == 1) {					//d?sactive l'asservissement des roues pour passer le saut
186 189
			angle_roue = 0;
187 190
		}
191
		if(angle_roue < -250 && capteur == 0x5601){		//emp?che l'asservissement de fonctionner pr?s des barils
192
			angle_roue = 0;
193
		}
194
		if(montee_noire == 1 && capteur == 0x5602){
195
			angle_roue = 0;
196
		}
188 197
		comm.data.val = angle_roue;
189 198
		snd_dtq(CanTx, comm.msg);
190
		dly_tsk(6);		
199
		dly_tsk(8);		
191 200
	}
192 201
}
193 202

  
......
210 219
		comm.data.rtr = 0;
211 220
		comm.data.val = ktour * (angle_tourelle - alpha);
212 221
		snd_dtq(CanTx, comm.msg);
213
		dly_tsk(5);		
222
		dly_tsk(8);		
214 223
	}
215 224
}
216 225

  
217
//lis la piste sur laquelle on roule
226
//lit la piste sur laquelle on roule
218 227
void lecture_piste(){
219 228
	CanFrame requete;
220 229
	UINT flag;
......
224 233
	periph[ADDR('M')].ev = 0x04;
225 234
	snd_dtq(CanTx, requete.msg);
226 235
	wai_flg(ev_periph, 0x04, TWF_ANDW, &flag); //Attente de la r?ponse
227
	num_piste = periph[ADDR('M')].val;	//acquisition num?ro piste
228
	num_piste1 = num_piste & 0x00ff;
236
	num_piste = periph[ADDR('M')].val;	//acquisition de la valeur de 'M'
237
	num_piste1 = num_piste & 0x00ff;	//num?ro de la piste
229 238
}
230 239

  
231 240
//lis le dernier capteur franchi
......
241 250
		snd_dtq(CanTx, requete.msg);
242 251
		wai_flg(ev_periph, 0x05, TWF_ANDW, &flag); //Attente de la r?ponse
243 252
		capteur = periph[ADDR('C')].val;	//acquisition du dernier capteur franchi
244
		dly_tsk(6);
253
		dly_tsk(8);
245 254
	}
246 255
}
247 256

  
248 257
//g?re la mont?e piste bleu
249
void gestion_montee (){
258
void gestion_montee_bleu (){
250 259
	
251 260
	while(1){
252
		if(num_piste1 == 2){ //d?tection piste rouge
253
			if( capteur == 0x5604 ){	//d?tection capteur avant montee
254
				montee = 1;
261
		if(num_piste1 == 2){ //d?tection piste bleu
262
			if( capteur == 0x5604 ){	//d?tection capteur avant montee piste bleu
263
				montee_bleu = 1;
255 264
			}	
256 265
			else {
257
				montee = 0;
266
				montee_bleu = 0;
258 267
			}
259 268
		}
260
		dly_tsk(6);
269
		dly_tsk(7);
261 270
	}
262 271
}
263 272

  
273
//g?re la mont?e piste noire
274
void gestion_montee_noire (){/*
275
	
276
	while(1){
277
		if(num_piste1 == 4){ //d?tection piste noire
278
			if( capteur == 0x5602 ){	//d?tection capteur avant montee
279
				dly_tsk(1000);
280
				montee_noire = 1;
281
			}	
282
			else {
283
				montee_noire = 0;
284
			}
285
		}
286
		dly_tsk(7);
287
	}*/
288
}
289

  
264 290
//g?re le saut piste rouge
265 291
void gestion_saut (){
266 292
	
......
278 304
	}
279 305
}
280 306

  
307
//g?re le passage des barils piste noire
308
void gestion_baril(){
309
	while(1){
310
		if(num_piste1 == 4){
311
			if(capteur == 0x5601){		//d?tection piste noire
312
				distance_bord = 900;	//d?calage de la voiture sur la voie de gauche
313
			}
314
		}
315
	dly_tsk(6);
316
	}
317
}
318

  
281 319
//detecte si le feu est vert
282 320
void detect_feuv(){
283 321
	CanFrame requete;
......
291 329
		snd_dtq(CanTx, requete.msg);
292 330
		wai_flg(ev_periph, 0x06, TWF_ANDW, &flag); //Attente de la r?ponse
293 331
		feu = periph[ADDR('M')].val;	//acquisition du dernier capteur franchi
294
		feuv = feu & 0x8000;
332
		feuv = (feu & 0x8000);
295 333
		dly_tsk(6);
296 334
	}
297 335
}
298 336

  
299

  
300 337
//Fonction de demarrage de la voiture
301 338
void demarrage(){
302 339
	CanFrame comm, requete;
......
304 341

  
305 342
	dly_tsk(4000);			//Attente avant d?part
306 343
	
307
	//if(feuv == 0x8000){		//D?part feu vert
308
		comm.data.id = 'V';
309
		comm.data.rtr = 0;
310
		comm.data.val = vitesse;	//D?marrage
311
		snd_dtq(CanTx, comm.msg);
312
	
344
	if(feuv == 0x8000 ) go = 1;		//Autorisation de d?part de la voiture
345
	if( go == 1){
346
	comm.data.id = 'V';
347
	comm.data.rtr = 0;
348
	comm.data.val = vitesse;	//D?marrage
349
	snd_dtq(CanTx, comm.msg);
313 350
			while(1){
314
				comm.data.id = 'V';
315
				comm.data.rtr = 0;
316
				if(angle_roue > 40 || angle_roue < -40){	//ralentissement de la voiture si angle demand? trop grand
317
					comm.data.val = vitesse_virage;
318
					snd_dtq(CanTx, comm.msg);
319
				}	
320
				else{
321
					comm.data.val = vitesse;
322
					snd_dtq(CanTx, comm.msg);
323
				}
324
				if(montee == 1){
325
					comm.data.val = vitesse_montee;
326
					snd_dtq(CanTx, comm.msg);
327
				}
328
				if(saut == 1){
329
					comm.data.val = vitesse_saut;
330
					snd_dtq(CanTx, comm.msg);
331
				}
332
				if(capteur == 0x4203 && num_piste1 == 3){
333
					comm.data.val = vitesse_recep;
334
					snd_dtq(CanTx, comm.msg);
335
				}
336
				dly_tsk(6);	
351
			comm.data.id = 'V';
352
			comm.data.rtr = 0;
353
			if(angle_roue > 40 || angle_roue < -40){	//ralentissement de la voiture si angle demand? trop grand
354
				comm.data.val = vitesse_virage;
355
				snd_dtq(CanTx, comm.msg);
356
			}	
357
			else{										//vitesse de base de la voiture
358
				comm.data.val = vitesse;
359
				snd_dtq(CanTx, comm.msg);
360
			}
361
			if(montee_bleu == 1){							//vitesse adapt?e pour la mont?e piste bleu
362
				comm.data.val = vitesse_montee;
363
				snd_dtq(CanTx, comm.msg);
364
			}
365
			if(saut == 1){								//vitesse adapt?e pour le saut piste rouge
366
				comm.data.val = vitesse_saut;
367
				snd_dtq(CanTx, comm.msg);
368
			}
369
			if(capteur == 0x4203 && num_piste1 == 3){	//vitesse adapt?e pour la reception du saut piste rouge
370
				comm.data.val = vitesse_recep;
371
				snd_dtq(CanTx, comm.msg);
372
			}
373
			if(capteur == 0x5602 && num_piste1 == 4){	//vitesse adapt?e pour la reception du saut piste rouge
374
				comm.data.val = vitesse_retour_piste;
375
				snd_dtq(CanTx, comm.msg);
376
			}
377
		dly_tsk(6);	
337 378
		}
338
	//}	acolade if d?part feu vert
379
	}
339 380
}
340 381

  
341 382

  
......
355 396
	sta_tsk(ID_lecture_capteur);
356 397
	sta_tsk(ID_demarrage);
357 398
	sta_cyc(ID_acqui);
358
	sta_tsk(ID_gestion_montee);
399
	sta_tsk(ID_gestion_montee_bleu);
359 400
	sta_tsk(ID_tsk_asserv1);
360 401
	sta_tsk(ID_lecture_telemetre);
361 402
	sta_tsk(ID_detect_feuv);
362 403
	sta_tsk(ID_asservissement_roue);
363
	sta_tsk(ID_gestion_saut);
404
	sta_tsk(ID_gestion_saut);
405
	sta_tsk(ID_gestion_baril);
406
	sta_tsk(ID_gestion_montee_noire);
364 407
    
365 408
	while(1)
366 409
    {
branch/font/Emb_App/conf_noyau.cfg
83 83
};
84 84

  
85 85
task[]{
86
	entry_address	= gestion_baril();
87
	name	= ID_gestion_baril;
88
	stack_size	= 512;
89
	stack_section	= stack;
90
	priority	= 4;
91
	initial_start	= OFF;
92
	exinf	= 0x0;
93
};
94

  
95
task[]{
86 96
	entry_address	= detect_feuv();
87 97
	name	= ID_detect_feuv;
88 98
	stack_size	= 512;
......
93 103
};
94 104

  
95 105
task[]{
96
	entry_address	= gestion_montee();
97
	name	= ID_gestion_montee;
106
	entry_address	= gestion_montee_bleu();
107
	name	= ID_gestion_montee_bleu;
98 108
	stack_size	= 512;
99 109
	stack_section	= stack;
100 110
	priority	= 4;
......
103 113
};
104 114

  
105 115
task[]{
116
	entry_address	= gestion_montee_noire();
117
	name	= ID_gestion_montee_noire;
118
	stack_size	= 512;
119
	stack_section	= stack;
120
	priority	= 4;
121
	initial_start	= OFF;
122
	exinf	= 0x0;
123
};
124

  
125
task[]{
106 126
	entry_address	= asservissement_roue();
107 127
	name	= ID_asservissement_roue;
108 128
	stack_size	= 512;

Also available in: Unified diff