Index: branch/vilain_sebastien/Emb_App.tws
===================================================================
--- branch/vilain_sebastien/Emb_App.tws	(revision 311)
+++ branch/vilain_sebastien/Emb_App.tws	(revision 312)
@@ -16,8 +16,8 @@
 [WORKSPACE_FILE_STATES]
 "E:\tp_info6_2018_vilain_sebastien\Emb_App\Debug\mr308.inc" 0 0 1596 539 0 4 
 "E:\tp_info6_2018_vilain_sebastien\Emb_App\conf_noyau.cfg" 50 50 1430 351 0 2 
-"E:\tp_info6_2018_vilain_sebastien\Emb_App\crt0mr.a30" -8 -30 1596 539 1 1 
-"E:\tp_info6_2018_vilain_sebastien\Emb_App\programme_principal_etud.c" 0 0 1596 539 0 0 
+"E:\tp_info6_2018_vilain_sebastien\Emb_App\crt0mr.a30" 0 0 1596 539 0 1 
+"E:\tp_info6_2018_vilain_sebastien\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 0 
 "E:\tp_info6_2018_vilain_sebastien\bsp\periph.c" 75 75 1430 351 0 3 
 "E:\tp_info6_2018_vilain_sebastien\bsp\uart0.c" 125 125 1430 351 0 5 
 [LOADED_PROJECTS]
Index: branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.ini	(revision 311)
+++ branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.ini	(revision 312)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0018
+RESET=ff0026
Index: branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.hsf	(revision 311)
+++ branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.hsf	(revision 312)
@@ -141,7 +141,7 @@
 "{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" "0000000000000044" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000004044" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000020" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_10" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_11" "0000000000000000" 
@@ -149,12 +149,12 @@
 "{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" "0000000000000512" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0577" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF058D" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000E08" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000830" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000A46" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000868" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000044" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000004044" 
 "{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" 
@@ -173,7 +173,7 @@
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "000000000000000A" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000E2C" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000A64" 
 "{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" 
@@ -211,9 +211,9 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "angle_roues, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "rampe, 1, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "lecture, 1, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "lecture, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "num_piste, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "5" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
@@ -317,12 +317,12 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"E:\tp_info6_2018_vilain_sebastien\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_vilain_sebastien\Emb_App\crt0mr.a30" 
-"E:\tp_info6_2018_vilain_sebastien\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_2018_vilain_sebastien\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_vilain_sebastien\bsp\uart0.c" 
+"E:\tp_info6_2018_vilain_sebastien\bsp\periph.c" 
 "E:\tp_info6_2018_vilain_sebastien\Emb_App\conf_noyau.cfg" 
-"E:\tp_info6_2018_vilain_sebastien\Emb_App\Debug\mr308.inc" 
-"E:\tp_info6_2018_vilain_sebastien\bsp\periph.c" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -369,5 +369,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 99232872 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 98315368 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/vilain_sebastien/Emb_App/programme_principal_etud.c
===================================================================
--- branch/vilain_sebastien/Emb_App/programme_principal_etud.c	(revision 311)
+++ branch/vilain_sebastien/Emb_App/programme_principal_etud.c	(revision 312)
@@ -126,14 +126,21 @@
 short lecture_telemetre();
 short lecture_capteur();
 void commande_vitesse(short vitesse);
-void init_vitesse(short vitesse);
+void init_vitesse();
 short consigne_angle = 450;
 short consigne_telemetre = 705;
 FLGPTN flag;
 short dist;
 short angle_roues;
-int rampe = 0;
+int asserv_off = 0;
 short lecture;
+short num_piste;
+int vit_spe = 0;
+int vit_spe2 = 0;
+int vit_spe3 = 0;
+int vit_spe4 = 0;
+float K1 = 1;
+int telemetre_a_droite = 1;
 
 void main()
 {
@@ -150,6 +157,7 @@
 	periph[ADDR('R')].ev=0x01;
 	periph[ADDR('U')].ev=0x02;
 	periph[ADDR('C')].ev=0x03;
+	periph[ADDR('M')].ev=0x04;
 	
 	sta_cyc(ID_acqui);
 	sta_tsk(ID_periph_rx);
@@ -156,8 +164,9 @@
 	sta_tsk(ID_asserv0);
 	sta_tsk(ID_asserv1);
 	sta_tsk(ID_commande_capteur);
+	sta_tsk(ID_course);
 
-	init_vitesse(45);
+	init_vitesse();
 	
     while(1)
     {
@@ -197,7 +206,7 @@
 
 void asserv0()
 {
-	int K = 2;
+	int K = 5;
 	short erreur;
 	while(1)
 	{
@@ -231,22 +240,25 @@
 
 void asserv1()
 {
-	int K = 2;
 	short erreur;
 	short ancien_dist;
 	while(1)
 	{
-		if (rampe == 0)
+		if (asserv_off == 0)
 		{
 			ancien_dist = dist;
 			dist = lecture_telemetre();
-			if((dist >= 2000)||(dist <= -2000))
+			if((abs(dist) >= 2000))
 			{
 				dist = ancien_dist;
 			}
-			erreur = K*(consigne_telemetre-dist);
-			angle_roues = -erreur;
-			commande_angle_roues(-erreur);
+			erreur = K1*(consigne_telemetre-dist);
+			if (telemetre_a_droite == 1)
+			{
+				erreur = -erreur;
+			}
+			angle_roues = erreur;
+			commande_angle_roues(erreur);
 		}
 		dly_tsk(5);
 	}
@@ -262,12 +274,44 @@
 	snd_dtq(CanTx, comm.msg);
 }
 
-void init_vitesse(short vitesse)
+void init_vitesse()
 {
 	dly_tsk(3000);
-	commande_vitesse(vitesse);
+	sta_tsk(ID_vitesse_virage);
 }
 
+void vitesse_virage()
+{
+	while(1)
+	{
+		if (vit_spe)
+		{
+			commande_vitesse(45);
+		}
+		else if (vit_spe2)
+		{
+			commande_vitesse(10);
+		}
+		else if (vit_spe3)
+		{
+			commande_vitesse(43);
+		}
+		else if (vit_spe4)
+		{
+			commande_vitesse(30);
+		}
+		else if ((angle_roues > 50) || (angle_roues < -50))
+		{
+			commande_vitesse(20);
+		}
+		else
+		{
+			commande_vitesse(60);
+		}
+	}
+	dly_tsk(100);
+}
+
 short lecture_capteur()
 {
 	CanFrame requete;
@@ -285,31 +329,112 @@
 	while(1)
 	{
 		lecture = lecture_capteur();
-		if((lecture & 0xFF00) == 0x6200) //bleu
+		if(lecture == 0x6201) //bleu id 01
 		{
-			rampe = 1;
+			asserv_off = 1;
+			vit_spe = 1;
 		}
-		if ((lecture & 0xFF00) == 0x7600) //vert
+		if(lecture == 0x6202) //bleu id 02
 		{
-			rampe = 0;
+			asserv_off = 1;
+		}
+		if (lecture == 0x7601) //vert id 01
+		{
+			asserv_off = 0;
+			vit_spe = 0;
+		}
+		if (lecture == 0x6a01) //jaune id 01
+		{
+			asserv_off = 0;
+		}
+		if (lecture == 0x7603) //vert id 03
+		{
 			commande_vitesse(20);
 		}
-		if ((lecture & 0xFF00) == 0x6a00) //jaune
+		if (lecture == 0x7602) //vert id 02
 		{
-			rampe = 0;
+			vit_spe = 1;
 		}
-		if ((lecture & 0xFF00) == 0x5604)
+		if (lecture == 0x7604) //vert id 04
 		{
-			commande_vitesse(45);
+			vit_spe = 0;
 		}
-		if ((lecture & 0xFF00) == 0x7200) //rouge
+		if (lecture == 0x7605) //vert id 05
 		{
-			consigne_telemetre = 600;
+			vit_spe2 = 0;
 		}
-		if ((lecture & 0xFF00) == 0x6300) //cyan
+		if (lecture == 0x7606) //vert id 06
 		{
+			vit_spe2 = 1;
+		}
+		if (lecture == 0x7607) //vert id 07
+		{
+			asserv_off = 0;
+			vit_spe3 = 0;
+		}
+		if (lecture == 0x7608) //vert id 08
+		{
+			asserv_off = 1;
+			vit_spe3 = 1;
+		}
+		if (lecture == 0x7609) //vert id 09
+		{
+			vit_spe4 = 0;
+		}
+		if (lecture == 0x760a) //vert id 10
+		{
+			vit_spe4 = 1;
+		}
+		if (lecture == 0x7201) //rouge id 1
+		{
+			consigne_telemetre = 500;
+		}
+		if (lecture == 0x7202) //rouge id 2
+		{
 			consigne_telemetre = 705;
 		}
+		if (lecture == 0x6301) //cyan id 1
+		{
+			consigne_angle = 700;
+			consigne_telemetre = 525;
+			telemetre_a_droite = 1;
+			K1 = 3;
+		}
+		if (lecture == 0x6302) //cyan id 2
+		{
+			consigne_angle = 450;
+			consigne_telemetre = 705;
+			telemetre_a_droite = 1;
+			K1 = 1;
+		}
+		if (lecture == 0x6303) //cyan id 3
+		{
+			consigne_angle = -700;
+			consigne_telemetre = 525;
+			telemetre_a_droite = 0;
+			K1 = 3;
+		}
 		dly_tsk(100);
 	}
+}
+
+short lecture_course()
+{
+	CanFrame requete;
+	
+	requete.data.id = 'M';
+	requete.data.rtr = 1;
+	snd_dtq(CanTx, requete.msg);
+	wai_flg (ev_periph,0x04,TWF_ORW,&flag);
+	clr_flg(ev_periph,~0x04);
+	return (periph[ADDR('M')].val);
+}
+
+void course()
+{
+	while(1)
+	{
+		num_piste = (lecture_course() & 0x00FF);
+		dly_tsk(100);
+	}
 }
\ No newline at end of file
Index: branch/vilain_sebastien/Emb_App/conf_noyau.cfg
===================================================================
--- branch/vilain_sebastien/Emb_App/conf_noyau.cfg	(revision 311)
+++ branch/vilain_sebastien/Emb_App/conf_noyau.cfg	(revision 312)
@@ -2,7 +2,7 @@
 //
 //    kernel.cfg : building file for MR308 Ver.4.00
 //
-//    Generated by M3T-MR308 GUI Configurator at 2018/12/12 15:16:07
+//    Generated by M3T-MR308 GUI Configurator at 2018/12/18 14:42:59
 //
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -20,7 +20,7 @@
 
 // max definition
 maxdefine{
-	max_task	= 6;
+	max_task	= 8;
 	max_flag	= 3;
 	max_dtq	= 2;
 	max_cyh	= 1;
@@ -88,6 +88,24 @@
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
+task[]{
+	entry_address	= course();
+	name	= ID_course;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 1;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+task[]{
+	entry_address	= vitesse_virage();
+	name	= ID_vitesse_virage;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 1;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
 
 flag[]{
 	name	= ev_bus_fin_tr;
Index: branch/vilain_sebastien/Emb_App/conf_noyau.hcf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: branch/vilain_sebastien/bsp/uart0.c
===================================================================
--- branch/vilain_sebastien/bsp/uart0.c	(revision 311)
+++ branch/vilain_sebastien/bsp/uart0.c	(revision 312)
@@ -67,7 +67,7 @@
 	c=u0rb;
 
 	if (c==0x0D || c==0x0A){
-		if (n>=2 && n<7)
+;		if (n>=2 && n<7)
 			ipsnd_dtq (CanRx,(VP_INT) rx.msg);
 		n=0;
 		rx.data.id=rx.data.rtr=rx.data.val=0;
