Index: branch/bacher/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/bacher/Emb_App/SessionM32C_E8a_system.ini	(revision 232)
+++ branch/bacher/Emb_App/SessionM32C_E8a_system.ini	(revision 233)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff002a
+RESET=ff003a
Index: branch/bacher/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/bacher/Emb_App/SessionM32C_E8a_system.hsf	(revision 232)
+++ branch/bacher/Emb_App/SessionM32C_E8a_system.hsf	(revision 233)
@@ -141,20 +141,20 @@
 "{55384715-F881-421C-A548-D7D1ABE158E1}PDMRWndInstanceKey0" "{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_DENORMAL_MODE" "0" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_ROUND_MODE" "0" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000001" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "00000000000000C0" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_10" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_11" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_12" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_13" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_14" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF002A" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000700" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000512" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF32EF" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000A48" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "000000000000084C" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "000000000000FFFF" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "00000000000000C0" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_21" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_22" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_23" "0000000000000000" 
@@ -169,12 +169,12 @@
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_31" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_32" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_33" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_34" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_34" "000000000000036A" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000007" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000FE0000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000A48" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000512" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_8" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_9" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_COUNT" "36" 
@@ -318,9 +318,9 @@
 "E:\tp_info6_2018_bacher\tp_info6\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_bacher\tp_info6\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2018_bacher\tp_info6\Emb_App\conf_noyau.cfg" 
+"E:\tp_info6_2018_bacher\tp_info6\Emb_App\Debug\mr308.inc" 
+"E:\tp_info6_2018_bacher\tp_info6\bsp\uart0.c" 
 "E:\tp_info6_2018_bacher\tp_info6\bsp\periph.c" 
-"E:\tp_info6_2018_bacher\tp_info6\bsp\uart0.c" 
-"E:\tp_info6_2018_bacher\tp_info6\Emb_App\Debug\mr308.inc" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -367,5 +367,5 @@
 [FLASH_DETAILS]
 "" 0 0 "" 0 "" 0 0 "" 0 0 0 0 0 0 0 "" "" "" "" "" 
 [BREAKPOINTS]
-"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 91139432 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 93576520 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/bacher/Emb_App/programme_principal_etud.c
===================================================================
--- branch/bacher/Emb_App/programme_principal_etud.c	(revision 232)
+++ branch/bacher/Emb_App/programme_principal_etud.c	(revision 233)
@@ -125,23 +125,70 @@
 int retour=0; //contient la valeur retourner par le périph
 int k=3; //contient le gain du correcteur de la boucle de régulation de la tourelle
 int k2=1; //contient le gain du correcteur de l'angle des roues
-int vitesse=80; //vitesse en ligne droite
-int vitesse_virage=30; //vitesse dans les virages
+int vitesse=0; //vitesse en ligne droite
+int vitesse_virage=0; //vitesse dans les virages
 int valeur=0; //contient la valeur à envoyer
 int distance=0; //mesure de la distance grâce au télémère
 int cons_roue=700; //consigne du placement au milieu de la route
 int ang_roue=0; //correction de l'angle à effectuer
+int numcapt=0; //numéro du dernier capteur
+int colcapt=0; //couleur du dernier capteur
+int retour_C; //couleur & numéro
+int i_tremplin=0; //booléen : 1=ligne du tremplin 0=autres lignes
+int i_ralenti=0;
+int i=0; //booléen : 1=accélération avant le tremplin et désactivation de la rotation des roues 0= fonctionnement normal
+int retour_M;
+int num_piste=0;
+int col_feu=0;
+int mode=0;
+FLGPTN flag_capt;
+FLGPTN flag_pist;
 
 CanFrame vit_roue; //canal de commande de la vitesse
+CanFrame capteur;
+CanFrame piste;
 
 void demarre()
 {
-		dly_tsk(2000);
-		vit_roue.data.id='V'; 
-    	vit_roue.data.rtr=0; 
-    	vit_roue.data.val=vitesse;
-	    snd_dtq (CanTx,vit_roue.msg);
+	dly_tsk(2000);
 
+
+	piste.data.id='M';
+  	piste.data.rtr=1; 
+	periph[ADDR('M')].ev=0x04;
+	snd_dtq(CanTx, piste.msg);
+	wai_flg (ev_periph, 0x04, TWF_ANDW, &flag_pist);
+
+	retour_M=periph[ADDR('M')].val;
+	num_piste=retour_M & 0x007F;
+	switch(num_piste){
+		case 0: //piste noire
+			vitesse=40;
+			vitesse_virage=30;
+			sta_tsk(ID_capteur);
+			break;
+		case 1: //piste verte
+			vitesse=70;
+			vitesse_virage=30;
+			mode=1;
+			break;
+		case 2: //piste bleue
+			vitesse=50;
+			vitesse_virage=30;
+			mode=1;	
+			sta_tsk(ID_capteur);	
+			break;
+		case 3: //piste rouge
+			vitesse=40;
+			vitesse_virage=30;
+			mode=0;
+			sta_tsk(ID_capteur);
+			break;
+		}
+	vit_roue.data.id='V'; 
+    vit_roue.data.rtr=0; 
+    vit_roue.data.val=vitesse;
+	snd_dtq (CanTx,vit_roue.msg);
 }
 
 void asserv0()
@@ -162,32 +209,51 @@
     comm.data.val=valeur;
     snd_dtq (CanTx,comm.msg); //on envoie la modification à effectuer
 	if(retour!=cons) valeur=k*(cons-retour);
-	dly_tsk(3);
+	dly_tsk(10);
 	}
 }
 
 int calcul_virage(int a){
-	if (a>-10 && a<10){
-		return vitesse;}
-	else if(a>0&&a<50) 
-		return -a/2+80;
-		//return (a*a)/100-a+vitesse;
-	else if(a<0&&a>-50) 
-		return a/2+80;
-		//return (a*a)/100+a+vitesse;
-	else if (a<-100||a>100){
-		return vitesse_virage;
+	if (mode==0){
+		if (a>-30 && a<30)	return vitesse;
+		else return vitesse_virage;
 	}
-	else return ((-(a*a)/100)+vitesse);
-	
-	/*if (a<0){
-		return ((a*a)/200+a+vitesse);
+	if (mode==1){
+		if (a>-10 && a<10){
+			return vitesse;}
+		else if(a>0&&a<50) 
+			return -a/2+vitesse;
+			//return (a*a)/100-a+vitesse;
+		else if(a<0&&a>-50) 
+			return a/2+vitesse;
+			//return (a*a)/100+a+vitesse;
+		else if (a<-100||a>100){
+			return vitesse_virage;
+		}
+		else return ((-(a*a)/100)+vitesse);
 	}
-	else{ 
-		return ((a*a)/200-a+vitesse);
-	
-	if (a>-50 && a<50)	return vitesse;
-	else return vitesse_virage;	*/
+	if (mode==2){
+		if (a>-10 && a<10){
+			return vitesse;}
+		else if(a>0&&a<50) 
+			
+			return (a*a)/100-a+vitesse;
+		else if(a<0&&a>-50) 
+			
+			return (a*a)/100+a+vitesse;
+		else if (a<-100||a>100){
+			return vitesse_virage;
+		}
+		else return ((-(a*a)/100)+vitesse);
+	}
+	if (mode==3){
+		if (a<0){
+			return ((a*a)/200+a+vitesse);
+		}
+		else{ 
+			return ((a*a)/200-a+vitesse);
+		}
+	}	
 }
  	
 void mes_dist(){
@@ -206,7 +272,7 @@
 		else {
 			distance=periph[ADDR('U')].val;
 			}
-		dly_tsk(3);
+		dly_tsk(20);
 	}
 }
 
@@ -215,24 +281,78 @@
     CanFrame req,comm;
     UINT flag;
    	while (1) {
-        req.data.id='D';
-        req.data.rtr=1;
-        periph[ADDR('D')].ev=0x01;
-        snd_dtq(CanTx, req.msg);
+			req.data.id='D';
+        	req.data.rtr=1;
+        	periph[ADDR('D')].ev=0x01;
+        	snd_dtq(CanTx, req.msg);
 
-       	wai_flg (ev_periph, 0x01, TWF_ANDW, &flag);
-        ang_roue=periph[ADDR('D')].val;
+       		wai_flg (ev_periph, 0x01, TWF_ANDW, &flag);
+        	ang_roue=periph[ADDR('D')].val;
 
-        comm.data.id='D';
-        comm.data.rtr=0; 
-        comm.data.val=k2*(distance-cons_roue);		
-		vit_roue.data.val=calcul_virage(k2*(distance-cons_roue)); 
-	  	snd_dtq (CanTx,vit_roue.msg);
-        snd_dtq(CanTx, comm.msg);
-		dly_tsk(3);
+        	comm.data.id='D';
+        	comm.data.rtr=0; 
+        	if(i_tremplin==1) comm.data.val=0;
+			if(i_tremplin==0) comm.data.val=k2*(distance-cons_roue);		
+		    if(i_tremplin==0 && i_ralenti==0) {
+				vit_roue.data.val=calcul_virage(k2*(distance-cons_roue)); 
+	  			snd_dtq (CanTx,vit_roue.msg);
+        		
+			}
+			snd_dtq(CanTx, comm.msg); 
+			dly_tsk(20);
+		
 	}
 }
 
+void detect_capteur()
+{
+	while(1){
+		
+	capteur.data.id='C';
+    capteur.data.rtr=1; 
+	periph[ADDR('C')].ev=0x03;
+	snd_dtq(CanTx, capteur.msg);
+	wai_flg (ev_periph, 0x03, TWF_ANDW, &flag_capt);
+	
+	retour_C=periph[ADDR('C')].val;
+	numcapt=retour_C & 0x00ff;
+	colcapt=retour_C & 0xff00;
+	
+	if (retour_C==0x5603 && i==0 && num_piste==3){ //si on passe le capteur avant le tremplin
+		i++;
+		dly_tsk(1500);
+		i_tremplin=1;
+		vit_roue.data.val=45; 
+		snd_dtq (CanTx,vit_roue.msg);
+		/*dly_tsk(500);
+		vit_roue.data.val=30; 
+	  	snd_dtq (CanTx,vit_roue.msg);*/
+	}
+	if (retour_C==0x4203 & num_piste==3){ //si on passe le capteur après le tremplin
+		i_tremplin=0;
+		i_ralenti=1;
+		vit_roue.data.val=20; 
+	  	snd_dtq (CanTx,vit_roue.msg);
+		i=0;
+	}
+	if (retour_C==0x5604 & num_piste==3){
+		vit_roue.data.val=vitesse; 
+	  	snd_dtq (CanTx,vit_roue.msg);
+		i_ralenti=0;
+	}
+	if (retour_C==0x5604 & num_piste==2){
+		vit_roue.data.val=15;
+		snd_dtq (CanTx,vit_roue.msg);
+		i_ralenti=1;
+	}	
+	if (retour_C==0x4204 & num_piste==2)
+		vit_roue.data.val=vitesse; 
+	  	snd_dtq (CanTx,vit_roue.msg);
+		i_ralenti=0;
+	}	
+	dly_tsk(20);
+	}
+
 
 void main()
 {	
@@ -251,10 +371,11 @@
 	sta_tsk(ID_mes_dist);
 	sta_tsk(ID_angle_roue);
 	sta_tsk(ID_demarre);
-
-    while(1){
-	}
-	 
+	//sta_tsk(ID_capteur);
+	
+    while(1){/*
+*/
+	}	 
 }
 
 void acqui()
Index: branch/bacher/Emb_App/conf_noyau.cfg
===================================================================
--- branch/bacher/Emb_App/conf_noyau.cfg	(revision 232)
+++ branch/bacher/Emb_App/conf_noyau.cfg	(revision 233)
@@ -2,7 +2,7 @@
 //
 //    kernel.cfg : building file for MR308 Ver.4.00
 //
-//    Generated by M3T-MR308 GUI Configurator at 2018/12/03 16:29:27
+//    Generated by M3T-MR308 GUI Configurator at 2018/12/12 16:22:45
 //
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -20,7 +20,7 @@
 
 // max definition
 maxdefine{
-	max_task	= 7;
+	max_task	= 8;
 	max_flag	= 3;
 	max_dtq	= 2;
 	max_cyh	= 1;
@@ -97,6 +97,15 @@
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
+task[]{
+	entry_address	= detect_capteur();
+	name	= ID_capteur;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 1;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
 
 flag[]{
 	name	= ev_bus_fin_tr;
Index: branch/bacher/Emb_App/conf_noyau.hcf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
