Projet

Général

Profil

« Précédent | Suivant » 

Révision 396

Ajouté par fltronel il y a plus de 6 ans

Commit fin de séance : saut piste rouge passé mais problème réception
nb tour ok et arrêt après 3 tours

Voir les différences:

branch/tronel_florian/Emb_App/programme_principal_etud.c
//'I'/73/Ox49 : D?finition du nom du v?hicule. Doit d?buter par le caract?re '#' et entraine le chargement de la configuration de piste
// correspondant au nom du v?hicule si le nom se termine par '*'
CanFrame vit;
unsigned short r=0, f=0;
unsigned char p;
unsigned short t, T;
unsigned char t1, t2;
unsigned char *s=&t1, *cs=&t2;
unsigned short cap=0;
unsigned char cap_H, cap_L;
int nb_tour=0;
int dist;
int ang_r;
int vit=30;
int V;
int copV;
int M_A=0;
int c=0;
......
//sta_tsk(ID_task_6);//temps lcd
V=1;
copV=1;
if(p>2){sta_tsk(ID_task_7);}//capteur
sta_tsk(ID_task_1);//vitesse
sta_tsk(ID_task_2);//tourelle
sta_tsk(ID_task_3);//dist
dly_tsk(1000);
dly_tsk(800);
sta_tsk(ID_task_4);//roue
sta_cyc(ID_HC_1);
sta_cyc(ID_HC_2);
//sta_cyc(ID_HC_2);
sta_cyc(ID_HC_3);
}
void task_1(){
int v;
while(1){
CanFrame vit_2={{'V',0,vit}};
snd_dtq(CanTx,vit_2.msg);
switch(V){
case 0: v=0; break;
case 1: v=35; break;
case 2: v=45; break;
case 3: v=15; break;
}
vit.data.id='V';
vit.data.rtr=0;
vit.data.val=v;
snd_dtq(CanTx,vit.msg);
dly_tsk(80);
}
......
snd_dtq(CanTx,req_d.msg);
r = periph[ADDR('M')].val;
p = (r & 0x00FF);
f = (r & 0x8000)>>15;
dly_tsk(5);
}
......
}
}
void task_7(){
CanFrame req_cap;
unsigned short cap_old=0;
while(1){
req_cap.data.id='C';
req_cap.data.rtr=1;
snd_dtq(CanTx,req_cap.msg);
cap = periph[ADDR('C')].val;
if(cap != cap_old){
cap_H=(cap & (0xFF00))>>8;
cap_L=cap & (0x00FF);
cap_old=cap;
}
switch(cap_H){
case 'V': if(cap_L==0x01){
nb_tour++;
cap_H=0;
cap_L=0;
if(nb_tour == 4){nb_tour=0;
stp_cyc(ID_HC_2);
V=0;
ter_tsk(ID_task_7);
ter_tsk(ID_task_2);
ter_tsk(ID_task_3);
ter_tsk(ID_task_4);
stp_cyc(ID_HC_1);
stp_cyc(ID_HC_3);}
}
if(cap_L==0x03){
V=2;
copV=2;
dly_tsk(800);
V=0;
copV=0;
sus_tsk(ID_task_3);
dist=700;
dly_tsk(400);
//dly_tsk(200);
//V=3;
//copV=3;
}
break;
case 'B': if(cap_L==0x03){
rsm_tsk(ID_task_3);
V=3;
copV=3;
dly_tsk(200);
V=1;
copV=1;}
break;
}
dly_tsk(10);
}
}
void HC_1(){
LED_V =~ LED_V;
}
void HC_2(){
switch (Bp_G){
case 0: vit=35; LED_R=0; break;
case 1: vit=0; LED_R=1; break;
case 0: V=copV; LED_R=0; break;
case 1: V=0; LED_R=1; break;
}
}
void HC_3(){
if (dist<150 && vit>0){LED_R=1;}
if (dist<150 && V>0){LED_R=1;}
}
branch/tronel_florian/Emb_App/conf_noyau.cfg
initial_start = OFF;
exinf = 0x0;
};
//acquisition du temps
//acquisition du temps & aff ecran
task[]{
entry_address = task_6();
name = ID_task_6;
......
initial_start = OFF;
exinf = 0x0;
};
//acquisition des messages
task[]{
entry_address = task_7();
name = ID_task_7;
stack_size = 256;
stack_section = stack;
priority = 2;
initial_start = OFF;
exinf = 0x0;
};
flag[]{
name = ev_bus_fin_tr;
initial_pattern = 0x0000;

Formats disponibles : Unified diff