Index: branch/guochao/Emb_App.tws
===================================================================
--- branch/guochao/Emb_App.tws	(revision 403)
+++ branch/guochao/Emb_App.tws	(revision 404)
@@ -9,8 +9,10 @@
 [OPEN_WORKSPACE_FILES]
 "E:\tp_info6_2018_guochao\tp_info6\bsp\carte_io.h" 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\lcd.c" 
+"E:\tp_info6_2018_guochao\tp_info6\bsp\mli.c" 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\periph.c" 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.c" 
+"E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.h" 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\uart0.c" 
 "E:\tp_info6_2018_guochao\tp_info6\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_guochao\tp_info6\Emb_App\crt0mr.a30" 
@@ -31,8 +33,10 @@
 "E:\tp_info6_2018_guochao\tp_info6\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 0 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\carte_io.h" 125 125 1430 351 0 11 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\lcd.c" 100 100 1430 351 0 10 
+"E:\tp_info6_2018_guochao\tp_info6\bsp\mli.c" 0 0 1430 351 0 14 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\periph.c" 100 100 1430 351 0 6 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.c" 125 125 1430 351 0 7 
+"E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.h" 150 150 1430 351 0 13 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\uart0.c" 25 25 1430 351 0 3 
 [LOADED_PROJECTS]
 "EmbM32C87App" 
Index: branch/guochao/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/guochao/Emb_App/SessionM32C_E8a_system.ini	(revision 403)
+++ branch/guochao/Emb_App/SessionM32C_E8a_system.ini	(revision 404)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff013a
+RESET=ff0146
Index: branch/guochao/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/guochao/Emb_App/SessionM32C_E8a_system.hsf	(revision 403)
+++ branch/guochao/Emb_App/SessionM32C_E8a_system.hsf	(revision 404)
@@ -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" "0000000000FF06A4" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF06A0" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000E94" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000BCC" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000001" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000004044" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "00000000000014FA" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000C20" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000004004" 
 "{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" "0000000000000008" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000EC8" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "000000000000151C" 
 "{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" 
@@ -205,22 +205,23 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth2" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth3" "200" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH" "c,buff,n,rx,flag," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "sauter, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "secouerFini, 1, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "coleur, 2, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "boueTerreFini, 1, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "num, 2, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "secouer, 1, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "capteur, 1, 0, P, Col, Hex, MA" 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Global," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "position, 1, 0, P, Col, Hex, MA" 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "statue, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "dansAir, 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" "montrePont, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Global," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "position, 1, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005_SCOPE" "Global," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "erreur, 1, 0, P, Col, Hex, MA" 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006_SCOPE" "Global," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007" "msg, 1, 0, C0002, Col, Hex, MN" 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008" "sauter, 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "obstacle, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007" "event, 1, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008" "pisteInfo, 10, 0, P, Col, Hex, N" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "7" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
@@ -326,15 +327,17 @@
 [WINDOW_Z_ORDER]
 "E:\tp_info6_2018_guochao\tp_info6\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_guochao\tp_info6\Emb_App\crt0mr.a30" 
+"E:\tp_info6_2018_guochao\tp_info6\Emb_App\pid.h" 
 "E:\tp_info6_2018_guochao\tp_info6\Emb_App\conf_noyau.cfg" 
+"E:\tp_info6_2018_guochao\tp_info6\Emb_App\pid.c" 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\uart0.c" 
+"E:\tp_info6_2018_guochao\tp_info6\Emb_App\Debug\mr308.inc" 
+"E:\tp_info6_2018_guochao\tp_info6\bsp\mli.c" 
+"E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.h" 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\periph.c" 
-"E:\tp_info6_2018_guochao\tp_info6\Emb_App\pid.h" 
-"E:\tp_info6_2018_guochao\tp_info6\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_guochao\tp_info6\Emb_App\Debug\mrtable.a30" 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\lcd.c" 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\carte_io.h" 
-"E:\tp_info6_2018_guochao\tp_info6\Emb_App\pid.c" 
 "E:\tp_info6_2018_guochao\tp_info6\Emb_App\Debug\kernel_id.h" 
 "E:\tp_info6_2018_guochao\tp_info6\bsp\radiocommande.c" 
 [TARGET_NAME]
@@ -383,5 +386,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 100066200 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 102419808 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/guochao/Emb_App/programme_principal_etud.c
===================================================================
--- branch/guochao/Emb_App/programme_principal_etud.c	(revision 403)
+++ branch/guochao/Emb_App/programme_principal_etud.c	(revision 404)
@@ -121,26 +121,44 @@
 //				correspondant au nom du véhicule si le nom se termine par '*'
 #include "pid.h"
 
-CanFrame comm;
-CanFrame requete;
-CanFrame reponse;
+CanFrame comm;//*
+CanFrame requete;//*
+CanFrame reponse;//**
 
 int g_angle450=450;
 int position = 0;
 int erreur = 0;
 
+char coleur;
+char num;
+short capteur;
+int valider=1;
+int sauter;
+float count;
+int secouerFini;
+int boueTerreFini=0;
+
+int lastErreur;
+
+int pistNoire;
+int vitesseSauter;
+int vitesseBase=0;
+
 void corrigerAngle()
 {
+	CanFrame requete;
+	CanFrame comm;
 	int angle;
 	int erreur;
 	
+	requete.data.id  = 'R';//*
+	comm.data.id = 'T';
 	requete.data.rtr = 1;
 	comm.data.rtr = 0;
 	while(1)
 	{
 		// lecture
-		requete.data.id  = 'R';
-		requete.data.rtr = 1;
+		
 		snd_dtq(CanTx, requete.msg);
 		dly_tsk(5);
 		angle = periph[ADDR('R')].val;//reponse.data.val;
@@ -147,7 +165,6 @@
 	
 			// corriger
 		erreur = g_angle450 - angle;//** (ok)
-		comm.data.id = 'T';
 		comm.data.val = erreur;
 		snd_dtq(CanTx, comm.msg);
 		dly_tsk(20);	
@@ -193,7 +210,7 @@
 	lcd_str(str);	
 }
 
-int getStatue(int erreur)
+int getStatue(int erreur)//*
 {
 	if( abs(erreur) > 30 ) //abs
 		return 1;
@@ -201,36 +218,149 @@
 		return 0;
 }
 
-char coleur;
-char num;
-short capteur;
-int valider;
-int siSauter(void)
+
+void siSauter()//*
 {//** Tache ...
-CanFrame requete;
+	CanFrame requete;
 
+	requete.data.rtr = 1;
 	requete.data.id  = 'C';
-	requete.data.rtr = 1;
-	snd_dtq(CanTx, requete.msg);
-	dly_tsk(5);	
-	capteur = periph[ADDR('C')].val;
-	coleur = capteur >> 8;
-	num    = capteur & 0xff;
 
-	if( 15 == num && coleur == 'r' && valider)
-		return 1;
-	else
-		return 0;	
+	while(1)
+	{
+		snd_dtq(CanTx, requete.msg);
+		dly_tsk(5);	
+		capteur = periph[ADDR('C')].val;
+		coleur = capteur >> 8;
+		num    = capteur & 0xff;
+
+		if( 3 == num && coleur == 'V')
+			sauter = 1;
+		else if( 3 == num && coleur == 'B' )
+			sauter = 0;	
+			
+		if( 4 == num && 'V' == coleur )
+			secouerFini = 1;
+		else
+			secouerFini = 0;
+			
+		if( 1 == num && 'J' == coleur )
+			vitesseBase = 1;
+		else if( 2 == num && 'V' == coleur )
+			vitesseBase = 2;
+		else if( 2 == num && 'R' == coleur )
+			vitesseBase = 0;
+			
+		dly_tsk(5);
+	}
 }
 
-int sauter = 0;
-int statue;
-void main()
+void siSecouerFini()
 {
-	float count = 0;
-	int lastErreur = 0;
-	valider = 1;
-	
+	CanFrame requete;
+
+	
+	while(1)
+	{	
+		dly_tsk(20);
+	}
+}
+
+int secouer=0;
+int dansAir=0;
+int montrePont=0;
+int obstacle=0;
+int lastErreurVrai;
+void control()
+{
+	int finiSauter=0;
+	int montrePont=0;
+	int positionABS=0;
+	int erreurStatic=0;
+	
+	dly_tsk(2000);
+	
+	while(1)
+    {
+		positionABS = abs(position);
+		erreur = IncPIDCalc(positionABS);		
+		
+		if( abs(erreur - lastErreur) > 300 && abs(erreur) > 500 )			// pour eviter le trou
+		{
+			if( !pistNoire )
+				erreur = 0;
+			else
+				erreur = lastErreur; 	
+		}
+	
+		if( 2 == vitesseBase )
+		{
+			if( (abs(erreur) > 2) && (positionABS < 695) )			// montrer le pont.
+				erreur = 0;
+		}
+	
+		if( sauter )
+		{
+			if( !secouer )
+				setVitesse(vitesseSauter);
+
+			if( (abs(erreur) > 3) && (positionABS < 680) )			// montrer le pont.
+			{
+				erreur = 0;
+				montrePont = 1;
+			}
+
+			if( montrePont && (positionABS > 1000) )			// flying...
+			{
+				dansAir = 1;
+				montrePont = 0;
+			}
+
+			if( dansAir && (positionABS < 700) )
+			{
+				setVitesse(0);				 // toucher le sol
+				dansAir = 0;
+				secouer = 1;					// commencer secouer
+			}
+		}
+		else
+		{
+			if( secouer && !secouerFini && !boueTerreFini )       				// viens de toucher le sol, bcp de secouer!!
+			{
+				setVitesse(20);
+			}
+			else
+			{
+				if( pistNoire && !boueTerreFini && secouer )				// entre la boueTerre
+				{
+					setVitesse(11);
+				}
+				else
+				{
+					if( 1 == vitesseBase )
+					{
+						IncPIDInit(POSITION_STANDAR_45, 0, 0, 0);
+						setVitesse(13);
+					}
+					else
+						setVitesse(41);
+						secouer = 0;
+						dansAir = 0;
+						sauter = 0;
+						erreurStatic = 0;
+				}
+			}
+		}
+		
+		controleRoue(erreur);
+		lastErreur = erreur;
+		
+		dly_tsk(20);
+    }
+}
+
+void main()
+{	
 	ports_mcu();
     lcd_init();
 	periph_init();
@@ -238,49 +368,35 @@
 
     can_init();
     clavier_init(1);
-	capture_init();
-	IncPIDInit(POSITION_STANDAR_45, 0);
+	capture_init();
+	
+	IncPIDInit(POSITION_STANDAR_45+200, -0.7, 0);
 
 	sta_cyc(ID_acqui);
 //	sta_cyc(ID_itouche);
 	sta_tsk(ID_clavier);
 	sta_tsk(ID_periph_rx);
+	
 	sta_tsk(ID_corrigerAngle);
 	sta_tsk(ID_mesurerDistance);
+	sta_tsk(ID_siSauter);
+	sta_tsk(ID_control);
+	sta_tsk(ID_secouerFini);
 	
-
-    while(1)
-    {//*** Tache 
-		erreur = IncPIDCalc(position);
-		if( erreur > 200 || erreur < -200 )			// evider le tronc
-			erreur = lastErreur;
-		
-	//	statue = getStatue(erreur);
-		
-		sauter = siSauter();
-	
-		if( (1 == sauter) && (count < 150) )
-		{
-			setVitesse(45);
-			erreur = lastErreur;
-			count++;
-		}
-		else if( count*1.5 > 0 )
-		{
-			count -= 0.5;
-			valider = 0;
-			setVitesse(0);
-			erreur = lastErreur;
-		}
-		else
-		{
-			setVitesse(30);
-			count = 0;
-			valider = 1;
-		}
-		controleRoue(erreur);
-		lastErreur = erreur;
-    }
+	pistNoire = 1;
+	if( pistNoire )
+	{
+		vitesseSauter = 42;
+	}
+	else
+	{
+		vitesseSauter = 45;
+	}
+	
+    while(1)
+	{
+		dly_tsk(50);
+	}
 }
 /*
 void itouche()
Index: branch/guochao/Emb_App/conf_noyau.cfg
===================================================================
--- branch/guochao/Emb_App/conf_noyau.cfg	(revision 403)
+++ branch/guochao/Emb_App/conf_noyau.cfg	(revision 404)
@@ -20,7 +20,7 @@
 
 // max definition
 maxdefine{
-	max_task	= 6;
+	max_task	= 8;
 	max_flag	= 3;
 	max_dtq	= 2;
 	max_cyh	= 2;
@@ -39,7 +39,7 @@
 	name	= ID_main;
 	stack_size	= 512;
 	stack_section	= stack;
-	priority	= 1;
+	priority	= 4;
 	initial_start	= ON;
 	exinf	= 0x0;
 };
@@ -73,6 +73,16 @@
 };
 
 task[]{
+	entry_address	= siSecouerFini();
+	name	= ID_secouerFini;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 5;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
 	entry_address	= corrigerAngle();
 	name	= ID_corrigerAngle;
 	stack_size	= 256;
@@ -87,11 +97,31 @@
 	name	= ID_mesurerDistance;
 	stack_size	= 256;
 	stack_section	= stack;
-	priority	= 2;
+	priority	= 3;
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
 
+task[]{
+	entry_address	= siSauter();
+	name	= ID_siSauter;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 1;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
+	entry_address	= control();
+	name	= ID_control;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 3;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
 flag[]{
 	name	= ev_bus_fin_tr;
 	initial_pattern	= 0x0000;
