Index: branch/vilain_sebastien/Emb_App.tws
===================================================================
--- branch/vilain_sebastien/Emb_App.tws	(revision 237)
+++ branch/vilain_sebastien/Emb_App.tws	(revision 238)
@@ -8,6 +8,7 @@
 [BREAKPOINTS]
 [OPEN_WORKSPACE_FILES]
 "E:\tp_info6_2018_vilain_sebastien\bsp\periph.c" 
+"E:\tp_info6_2018_vilain_sebastien\bsp\uart0.c" 
 "E:\tp_info6_2018_vilain_sebastien\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_vilain_sebastien\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2018_vilain_sebastien\Emb_App\Debug\mr308.inc" 
@@ -18,6 +19,7 @@
 "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\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]
 "EmbM32C87App" 
 [END]
Index: branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.hsf	(revision 237)
+++ branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.hsf	(revision 238)
@@ -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" "0000000000004044" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000044" 
 "{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,11 +149,11 @@
 "{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" "0000000000FF0574" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0577" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000AE0" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "000000000000081A" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000001" 
+"{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_2" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000044" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_21" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_22" "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" "0000000000000B16" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000E2C" 
 "{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,11 +205,17 @@
 "{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" "erreur, 1, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "erreur, 10, 0, P, Col, Hex, N" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "dist, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "2" 
+"{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_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_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "5" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
@@ -313,6 +319,7 @@
 [WINDOW_Z_ORDER]
 "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\bsp\uart0.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" 
@@ -362,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 89664616 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 99232872 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 237)
+++ branch/vilain_sebastien/Emb_App/programme_principal_etud.c	(revision 238)
@@ -124,14 +124,16 @@
 void commande_angle_roues(short angle_roues);
 short lecture_angle();
 short lecture_telemetre();
+short lecture_capteur();
 void commande_vitesse(short vitesse);
-void choix_circuit(int i);
+void init_vitesse(short vitesse);
 short consigne_angle = 450;
-short erreur;
-short vitesse = 120;
-short consigne_telemetre = 714;
+short consigne_telemetre = 705;
 FLGPTN flag;
 short dist;
+short angle_roues;
+int rampe = 0;
+short lecture;
 
 void main()
 {
@@ -139,7 +141,7 @@
 	ports_mcu();
     lcd_init();
 	periph_init();
-	periph_nom("#Test*");
+	periph_nom("#Seb*");
 
     can_init();
     clavier_init(1);
@@ -146,13 +148,16 @@
 	capture_init();
 	
 	periph[ADDR('R')].ev=0x01;
+	periph[ADDR('U')].ev=0x02;
+	periph[ADDR('C')].ev=0x03;
 	
 	sta_cyc(ID_acqui);
 	sta_tsk(ID_periph_rx);
 	sta_tsk(ID_asserv0);
 	sta_tsk(ID_asserv1);
+	sta_tsk(ID_commande_capteur);
 
-	commande_vitesse(35);
+	init_vitesse(45);
 	
     while(1)
     {
@@ -180,7 +185,7 @@
 
 short lecture_angle()
 {
-	CanFrame requete, reponse;
+	CanFrame requete;
 	
 	requete.data.id = 'R';
 	requete.data.rtr = 1;
@@ -198,7 +203,7 @@
 	{
 		erreur = K*(consigne_angle-lecture_angle());
 		commande_tourelle(erreur);
-		dly_tsk(98);
+		dly_tsk(25);
 	}
 }
 
@@ -214,42 +219,97 @@
 
 short lecture_telemetre()
 {
-	CanFrame requete, reponse;
+	CanFrame requete;
 	
 	requete.data.id = 'U';
 	requete.data.rtr = 1;
 	snd_dtq(CanTx, requete.msg);
-	wai_flg (ev_periph,0x01,TWF_ORW,&flag);
-	clr_flg(ev_periph,~0x01);
+	wai_flg (ev_periph,0x02,TWF_ORW,&flag);
+	clr_flg(ev_periph,~0x02);
 	return (periph[ADDR('U')].val);
 }
 
 void asserv1()
 {
-	int K = 1;
+	int K = 2;
 	short erreur;
 	short ancien_dist;
 	while(1)
 	{
-		ancien_dist = dist;
-		dist = lecture_telemetre();
-		if(dist >= 1000)
+		if (rampe == 0)
 		{
-			dist = ancien_dist;
+			ancien_dist = dist;
+			dist = lecture_telemetre();
+			if((dist >= 2000)||(dist <= -2000))
+			{
+				dist = ancien_dist;
+			}
+			erreur = K*(consigne_telemetre-dist);
+			angle_roues = -erreur;
+			commande_angle_roues(-erreur);
 		}
-		erreur = K*(consigne_telemetre-dist);
-		commande_angle_roues(-erreur);
-		dly_tsk(98);
+		dly_tsk(5);
 	}
 }
 
 void commande_vitesse(short vitesse)
+{	
+	CanFrame comm;
+	
+	comm.data.id = 'V';
+	comm.data.rtr = 0;
+	comm.data.val=vitesse;
+	snd_dtq(CanTx, comm.msg);
+}
+
+void init_vitesse(short vitesse)
 {
+	dly_tsk(3000);
+	commande_vitesse(vitesse);
+}
+
+short lecture_capteur()
+{
 	CanFrame requete;
 	
-	dly_tsk(3000);
-	requete.data.id = 'V';
-	requete.data.rtr = 0;
-	requete.data.val=vitesse;
+	requete.data.id = 'C';
+	requete.data.rtr = 1;
 	snd_dtq(CanTx, requete.msg);
+	wai_flg (ev_periph,0x03,TWF_ORW,&flag);
+	clr_flg(ev_periph,~0x03);
+	return (periph[ADDR('C')].val);
+}
+
+void commande_capteur()
+{
+	while(1)
+	{
+		lecture = lecture_capteur();
+		if((lecture & 0xFF00) == 0x6200) //bleu
+		{
+			rampe = 1;
+		}
+		if ((lecture & 0xFF00) == 0x7600) //vert
+		{
+			rampe = 0;
+			commande_vitesse(20);
+		}
+		if ((lecture & 0xFF00) == 0x6a00) //jaune
+		{
+			rampe = 0;
+		}
+		if ((lecture & 0xFF00) == 0x5604)
+		{
+			commande_vitesse(45);
+		}
+		if ((lecture & 0xFF00) == 0x7200) //rouge
+		{
+			consigne_telemetre = 600;
+		}
+		if ((lecture & 0xFF00) == 0x6300) //cyan
+		{
+			consigne_telemetre = 705;
+		}
+		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 237)
+++ branch/vilain_sebastien/Emb_App/conf_noyau.cfg	(revision 238)
@@ -2,7 +2,7 @@
 //
 //    kernel.cfg : building file for MR308 Ver.4.00
 //
-//    Generated by M3T-MR308 GUI Configurator at 2018/12/03 16:28:30
+//    Generated by M3T-MR308 GUI Configurator at 2018/12/12 15:16:07
 //
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -20,7 +20,7 @@
 
 // max definition
 maxdefine{
-	max_task	= 5;
+	max_task	= 6;
 	max_flag	= 3;
 	max_dtq	= 2;
 	max_cyh	= 1;
@@ -75,6 +75,15 @@
 	name	= ID_asserv1;
 	stack_size	= 256;
 	stack_section	= stack;
+	priority	= 8;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+task[]{
+	entry_address	= commande_capteur();
+	name	= ID_commande_capteur;
+	stack_size	= 256;
+	stack_section	= stack;
 	priority	= 1;
 	initial_start	= OFF;
 	exinf	= 0x0;
Index: branch/vilain_sebastien/Emb_App/conf_noyau.hcf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
