Carte esclave gros robot

Dependencies:   mbed Herkulex_Library_2019 ident_crac actions_Pr

Committer:
Artiom
Date:
Tue May 14 15:09:14 2019 +0000
Revision:
5:6e198cdd99ad
Parent:
4:4a79942713fa
Child:
6:45f9cf44718a
automate ack ventouse face avant/arriere fonctionel

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Artiom 0:bc74da1c502f 1 #include "mbed.h"
Artiom 0:bc74da1c502f 2 #include "ident_crac.h"
Artiom 0:bc74da1c502f 3 #include "Capteur.h"
Artiom 0:bc74da1c502f 4 #include "Actionneurs.h"
Artiom 0:bc74da1c502f 5 #include "fonctions_herkulex.h"
Artiom 1:568955af8c2b 6 #include "main.h"
Artiom 0:bc74da1c502f 7
Artiom 0:bc74da1c502f 8 #define SIZE_FIFO 50
Artiom 0:bc74da1c502f 9
Artiom 0:bc74da1c502f 10 CAN can(PB_8,PB_9,1000000); // Rx&Tx pour le CAN
Artiom 0:bc74da1c502f 11
Artiom 0:bc74da1c502f 12
Artiom 0:bc74da1c502f 13 CANMessage msgRxBuffer[SIZE_FIFO];
Artiom 0:bc74da1c502f 14 unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN
Artiom 0:bc74da1c502f 15 signed char FIFO_lecture=0;//Position du fifo de lecture des messages CAN
Artiom 0:bc74da1c502f 16 unsigned char EtatGameEnd=0;
Artiom 0:bc74da1c502f 17
Artiom 4:4a79942713fa 18 char fpresentoir_avant=0;
Artiom 5:6e198cdd99ad 19 char fpresentoir_arriere=0;
Artiom 4:4a79942713fa 20
Artiom 4:4a79942713fa 21 char status_pompe=0;
Artiom 4:4a79942713fa 22
Artiom 0:bc74da1c502f 23 void canRx_ISR (void);
Artiom 0:bc74da1c502f 24 void SendAck(unsigned short id, unsigned short from);
Artiom 0:bc74da1c502f 25 void SendRawId (unsigned short id);
Artiom 0:bc74da1c502f 26 void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement);
Artiom 0:bc74da1c502f 27 void canProcessRx(void);
Artiom 4:4a79942713fa 28 void automate_ventouse_presentoir_avant(void);
Artiom 5:6e198cdd99ad 29 void automate_ventouse_presentoir_arriere (void);
Artiom 0:bc74da1c502f 30
Artiom 0:bc74da1c502f 31 /*********************************************************************************************/
Artiom 0:bc74da1c502f 32 /* FUNCTION NAME: canRx_ISR */
Artiom 0:bc74da1c502f 33 /* DESCRIPTION : lit les messages sur le can et les stocke dans la FIFO */
Artiom 0:bc74da1c502f 34 /*********************************************************************************************/
Artiom 0:bc74da1c502f 35 void canRx_ISR (void)
Artiom 0:bc74da1c502f 36 {
Artiom 0:bc74da1c502f 37 if (can.read(msgRxBuffer[FIFO_ecriture])) {
Artiom 0:bc74da1c502f 38 if (msgRxBuffer[FIFO_ecriture].id==GLOBAL_GAME_END) {
Artiom 0:bc74da1c502f 39
Artiom 0:bc74da1c502f 40 }
Artiom 0:bc74da1c502f 41 FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO;
Artiom 0:bc74da1c502f 42
Artiom 0:bc74da1c502f 43 }
Artiom 0:bc74da1c502f 44
Artiom 0:bc74da1c502f 45 }
Artiom 0:bc74da1c502f 46 /*********************************************************************************************/
Artiom 0:bc74da1c502f 47 /* FUNCTION NAME: SendAck */
Artiom 0:bc74da1c502f 48 /* DESCRIPTION : */
Artiom 0:bc74da1c502f 49 /*********************************************************************************************/
Artiom 0:bc74da1c502f 50 void SendAck(unsigned short from, unsigned short id) //FROM et ID sont inversés pour convenir à la lecture d'ACK de la carte principale
Artiom 0:bc74da1c502f 51 {
Artiom 0:bc74da1c502f 52 CANMessage msgTx=CANMessage();
Artiom 0:bc74da1c502f 53 msgTx.id=from; //waitingAckFrom
Artiom 0:bc74da1c502f 54 msgTx.len=2;
Artiom 0:bc74da1c502f 55 msgTx.format=CANStandard;
Artiom 0:bc74da1c502f 56 msgTx.type=CANData;
Artiom 0:bc74da1c502f 57 // from sur 2 octets
Artiom 0:bc74da1c502f 58 msgTx.data[0]=(unsigned char)id; //waitingAckID
Artiom 0:bc74da1c502f 59 msgTx.data[1]=(unsigned char)(id>>8);
Artiom 0:bc74da1c502f 60 can.write(msgTx);
Artiom 0:bc74da1c502f 61 }
Artiom 0:bc74da1c502f 62 /*********************************************************************************************/
Artiom 0:bc74da1c502f 63 /* FUNCTION NAME: SendRawId */
Artiom 0:bc74da1c502f 64 /* DESCRIPTION : */
Artiom 0:bc74da1c502f 65 /*********************************************************************************************/
Artiom 0:bc74da1c502f 66 void SendRawId (unsigned short id)
Artiom 0:bc74da1c502f 67 {
Artiom 0:bc74da1c502f 68 CANMessage msgTx=CANMessage();
Artiom 0:bc74da1c502f 69 msgTx.id=id;
Artiom 0:bc74da1c502f 70 msgTx.len=0;
Artiom 0:bc74da1c502f 71 can.write(msgTx); //carte esclave f446re
Artiom 0:bc74da1c502f 72 wait_us(200);
Artiom 0:bc74da1c502f 73 }
Artiom 0:bc74da1c502f 74
Artiom 0:bc74da1c502f 75 /*********************************************************************************************/
Artiom 0:bc74da1c502f 76 /* FUNCTION NAME: GoStraight */
Artiom 0:bc74da1c502f 77 /* DESCRIPTION : Transmission CAN correspondant à une ligne droite, avec ou sans recalage */
Artiom 0:bc74da1c502f 78 /* recalage : 0 => pas de recalage */
Artiom 0:bc74da1c502f 79 /* 1 => recalage en X */
Artiom 0:bc74da1c502f 80 /* 2 => Recalage en Y */
Artiom 0:bc74da1c502f 81 /* newValue : Uniquement en cas de recalage, indique la nouvelle valeur de l'odo */
Artiom 0:bc74da1c502f 82 /* isEnchainement : Indique si il faut executer l'instruction en enchainement */
Artiom 0:bc74da1c502f 83 /* 0 => non */
Artiom 0:bc74da1c502f 84 /* 1 => oui */
Artiom 0:bc74da1c502f 85 /* 2 => dernière instruction de l'enchainement */
Artiom 0:bc74da1c502f 86 /*********************************************************************************************/
Artiom 0:bc74da1c502f 87 void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement)
Artiom 0:bc74da1c502f 88 {
Artiom 0:bc74da1c502f 89 CANMessage msgTx=CANMessage();
Artiom 0:bc74da1c502f 90 msgTx.id=ASSERVISSEMENT_RECALAGE;
Artiom 0:bc74da1c502f 91 msgTx.len=6;
Artiom 0:bc74da1c502f 92 msgTx.format=CANStandard;
Artiom 0:bc74da1c502f 93 msgTx.type=CANData;
Artiom 0:bc74da1c502f 94 // x sur 2 octets
Artiom 0:bc74da1c502f 95 msgTx.data[0]=(unsigned char)distance;
Artiom 0:bc74da1c502f 96 msgTx.data[1]=(unsigned char)(distance>>8);
Artiom 0:bc74da1c502f 97 //Recalage sur 1 octet
Artiom 0:bc74da1c502f 98 msgTx.data[2]=recalage;
Artiom 0:bc74da1c502f 99 //Valeur du recalage sur 2 octets
Artiom 0:bc74da1c502f 100 msgTx.data[3]=(unsigned char)newValue;
Artiom 0:bc74da1c502f 101 msgTx.data[4]=(unsigned char)(newValue>>8);
Artiom 0:bc74da1c502f 102 //Enchainement sur 1 octet
Artiom 0:bc74da1c502f 103 msgTx.data[5]=isEnchainement;
Artiom 0:bc74da1c502f 104
Artiom 0:bc74da1c502f 105 can.write(msgTx);
Artiom 0:bc74da1c502f 106 //wait_ms(500);
Artiom 0:bc74da1c502f 107 }
Artiom 0:bc74da1c502f 108
Artiom 0:bc74da1c502f 109 int main()
Artiom 0:bc74da1c502f 110 {
Artiom 0:bc74da1c502f 111 can.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN
Artiom 0:bc74da1c502f 112 servo_interrupt_en(); //permettre les interuptions
Artiom 0:bc74da1c502f 113 wait(1);//attente servo boot
Artiom 2:9e63099cca99 114 gabarit_petit_robot();
Artiom 0:bc74da1c502f 115
Artiom 0:bc74da1c502f 116 while(1) {
Artiom 0:bc74da1c502f 117 canProcessRx();
Artiom 4:4a79942713fa 118 automate_ventouse_presentoir_avant();
Artiom 5:6e198cdd99ad 119 automate_ventouse_presentoir_arriere();
Artiom 0:bc74da1c502f 120 if(EtatGameEnd==1) {
Artiom 0:bc74da1c502f 121 while(1);
Artiom 0:bc74da1c502f 122 }
Artiom 0:bc74da1c502f 123
Artiom 0:bc74da1c502f 124 }
Artiom 0:bc74da1c502f 125 }
Artiom 0:bc74da1c502f 126
Artiom 0:bc74da1c502f 127 /****************************************************************************************/
Artiom 0:bc74da1c502f 128 /* FUNCTION NAME: canProcessRx */
Artiom 0:bc74da1c502f 129 /* DESCRIPTION : Fonction de traitement des messages CAN */
Artiom 0:bc74da1c502f 130 /****************************************************************************************/
Artiom 0:bc74da1c502f 131 void canProcessRx(void)
Artiom 0:bc74da1c502f 132 {
Artiom 0:bc74da1c502f 133 static signed char FIFO_occupation=0,FIFO_max_occupation=0;
Artiom 0:bc74da1c502f 134 CANMessage msgTx=CANMessage();
Artiom 0:bc74da1c502f 135 FIFO_occupation=FIFO_ecriture-FIFO_lecture;
Artiom 0:bc74da1c502f 136 if(FIFO_occupation<0)
Artiom 0:bc74da1c502f 137 FIFO_occupation=FIFO_occupation+SIZE_FIFO;
Artiom 0:bc74da1c502f 138 if(FIFO_max_occupation<FIFO_occupation)
Artiom 0:bc74da1c502f 139 FIFO_max_occupation=FIFO_occupation;
Artiom 0:bc74da1c502f 140 if(FIFO_occupation!=0) {
Artiom 0:bc74da1c502f 141 int identifiant=msgRxBuffer[FIFO_lecture].id;
Artiom 0:bc74da1c502f 142
Artiom 0:bc74da1c502f 143 switch(identifiant) {
Artiom 0:bc74da1c502f 144
Artiom 0:bc74da1c502f 145 case GLOBAL_GAME_END:
Artiom 0:bc74da1c502f 146 EtatGameEnd = 1;
Artiom 0:bc74da1c502f 147 break;
Artiom 0:bc74da1c502f 148
Artiom 0:bc74da1c502f 149 case DATA_TELEMETRE: //Lit le telemetre N°X suivant la data dans le CAN
Artiom 0:bc74da1c502f 150 char numero_telemetre=msgRxBuffer[FIFO_lecture].data[0];
Artiom 0:bc74da1c502f 151 short distance=lecture_telemetre(numero_telemetre);
Artiom 0:bc74da1c502f 152
Artiom 0:bc74da1c502f 153
Artiom 0:bc74da1c502f 154 msgTx.id=RECEPTION_DATA; // tx Valeur Telemetre1
Artiom 0:bc74da1c502f 155 msgTx.len=2;
Artiom 0:bc74da1c502f 156 msgTx.format=CANStandard;
Artiom 0:bc74da1c502f 157 msgTx.type=CANData;
Artiom 0:bc74da1c502f 158 // Rayon sur 2 octets
Artiom 0:bc74da1c502f 159 msgTx.data[0]=(unsigned char)distance;
Artiom 0:bc74da1c502f 160 msgTx.data[1]=(unsigned char)(distance>>8);
Artiom 0:bc74da1c502f 161
Artiom 0:bc74da1c502f 162 can.write(msgTx);
Artiom 0:bc74da1c502f 163 SendAck(ACKNOWLEDGE_TELEMETRE,RECEPTION_DATA);
Artiom 0:bc74da1c502f 164 break;
Artiom 0:bc74da1c502f 165
Artiom 0:bc74da1c502f 166 case DATA_RECALAGE:
Artiom 0:bc74da1c502f 167 short distance1=lecture_telemetre(1);
Artiom 0:bc74da1c502f 168 short distance2=lecture_telemetre(2);
Artiom 0:bc74da1c502f 169 short distance3=lecture_telemetre(3);
Artiom 0:bc74da1c502f 170 short distance4=lecture_telemetre(4);
Artiom 0:bc74da1c502f 171
Artiom 0:bc74da1c502f 172 msgTx.id=RECEPTION_RECALAGE; // tx Valeur Telemetre1
Artiom 0:bc74da1c502f 173 msgTx.len=8;
Artiom 0:bc74da1c502f 174 msgTx.format=CANStandard;
Artiom 0:bc74da1c502f 175 msgTx.type=CANData;
Artiom 0:bc74da1c502f 176 // Rayon sur 2 octets
Artiom 0:bc74da1c502f 177 msgTx.data[0]=(unsigned char)distance1;
Artiom 0:bc74da1c502f 178 msgTx.data[1]=(unsigned char)(distance1>>8);
Artiom 0:bc74da1c502f 179 msgTx.data[2]=(unsigned char)distance2;
Artiom 0:bc74da1c502f 180 msgTx.data[3]=(unsigned char)(distance2>>8);
Artiom 0:bc74da1c502f 181 msgTx.data[4]=(unsigned char)distance3;
Artiom 0:bc74da1c502f 182 msgTx.data[5]=(unsigned char)(distance3>>8);
Artiom 0:bc74da1c502f 183 msgTx.data[6]=(unsigned char)distance4;
Artiom 0:bc74da1c502f 184 msgTx.data[7]=(unsigned char)(distance4>>8);
Artiom 0:bc74da1c502f 185 can.write(msgTx);
Artiom 0:bc74da1c502f 186 SendAck(ACKNOWLEDGE_TELEMETRE,RECEPTION_RECALAGE);
Artiom 0:bc74da1c502f 187 break;
Artiom 0:bc74da1c502f 188
Artiom 0:bc74da1c502f 189 #ifdef ROBOT_SMALL
Artiom 4:4a79942713fa 190 //-------------------------------------------------------------------------Actions petit robot----------------------------------------------
Artiom 2:9e63099cca99 191 case GABARIT_PETIT_ROBOT:
Artiom 2:9e63099cca99 192 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 193 gabarit_petit_robot();
Artiom 2:9e63099cca99 194 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 0:bc74da1c502f 195 break;
Artiom 0:bc74da1c502f 196
Artiom 0:bc74da1c502f 197 case PRESENTOIR_AVANT:
Artiom 4:4a79942713fa 198 fpresentoir_avant=1;
Artiom 0:bc74da1c502f 199 break;
Artiom 0:bc74da1c502f 200
Artiom 0:bc74da1c502f 201 case PRESENTOIR_ARRIERE:
Artiom 5:6e198cdd99ad 202 fpresentoir_arriere=1;
Artiom 0:bc74da1c502f 203 break;
Artiom 0:bc74da1c502f 204
Artiom 0:bc74da1c502f 205 case BALANCE_AVANT:
Artiom 2:9e63099cca99 206 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 0:bc74da1c502f 207 balance_avant();
Artiom 2:9e63099cca99 208 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 0:bc74da1c502f 209 break;
Artiom 0:bc74da1c502f 210
Artiom 0:bc74da1c502f 211 case BALANCE_ARRIERE:
Artiom 2:9e63099cca99 212 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 0:bc74da1c502f 213 balance_arriere();
Artiom 2:9e63099cca99 214 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 215 break;
Artiom 2:9e63099cca99 216
Artiom 2:9e63099cca99 217 case ACCELERATEUR_AVANT:
Artiom 2:9e63099cca99 218 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 219 accelerateur_avant();
Artiom 2:9e63099cca99 220 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 221 break;
Artiom 2:9e63099cca99 222
Artiom 2:9e63099cca99 223 case ACCELERATEUR_ARRIERE:
Artiom 2:9e63099cca99 224 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 225 accelerateur_arriere();
Artiom 2:9e63099cca99 226 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 227 break;
Artiom 2:9e63099cca99 228 case GOLDENIUM_AVANT:
Artiom 2:9e63099cca99 229 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 230 balance_avant();
Artiom 2:9e63099cca99 231 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 232 break;
Artiom 2:9e63099cca99 233
Artiom 2:9e63099cca99 234 case GOLDENIUM_ARRIERE:
Artiom 2:9e63099cca99 235 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 236 balance_arriere();
Artiom 2:9e63099cca99 237 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 238 break;
Artiom 2:9e63099cca99 239 case SOL_AVANT:
Artiom 2:9e63099cca99 240 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 241 sol_avant();
Artiom 2:9e63099cca99 242 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 243 break;
Artiom 2:9e63099cca99 244
Artiom 2:9e63099cca99 245 case SOL_ARRIERE:
Artiom 2:9e63099cca99 246 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 247 sol_arriere();
Artiom 2:9e63099cca99 248 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 249 break;
Artiom 2:9e63099cca99 250
Artiom 2:9e63099cca99 251 case SOL_AVANT_RELACHE:
Artiom 2:9e63099cca99 252 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 253 sol_avant_relache();
Artiom 2:9e63099cca99 254 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 2:9e63099cca99 255 break;
Artiom 2:9e63099cca99 256
Artiom 2:9e63099cca99 257 case SOL_ARRIERE_RELACHE:
Artiom 2:9e63099cca99 258 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 2:9e63099cca99 259 sol_arriere_relache();
Artiom 2:9e63099cca99 260 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 0:bc74da1c502f 261 break;
Artiom 4:4a79942713fa 262 //--------------------------------------------------------------------------ACK carte pompe----------------------------------------------
Artiom 4:4a79942713fa 263
Artiom 4:4a79942713fa 264
Artiom 4:4a79942713fa 265 case HACHEUR_STATUT_VENTOUSES:
Artiom 4:4a79942713fa 266 status_pompe = msgRxBuffer[FIFO_lecture].data[1];
Artiom 5:6e198cdd99ad 267 //can.write(CANMessage(0x529, &status_pompe,1));
Artiom 4:4a79942713fa 268 break;
Artiom 4:4a79942713fa 269
Artiom 4:4a79942713fa 270 case HACHEUR_GET_ATOM_ACK:
Artiom 4:4a79942713fa 271 status_pompe |= (0x01 << msgRxBuffer[FIFO_lecture].data[0]);
Artiom 5:6e198cdd99ad 272 //can.write(CANMessage(0x529, &status_pompe,1));
Artiom 4:4a79942713fa 273 break;
Artiom 4:4a79942713fa 274
Artiom 4:4a79942713fa 275 case HACHEUR_RELEASE_ATOM_ACK :
Artiom 4:4a79942713fa 276 status_pompe &= ~(0x01 << msgRxBuffer[FIFO_lecture].data[0]);
Artiom 4:4a79942713fa 277 break;
Artiom 4:4a79942713fa 278 //-------------------------------------------------------------------------------------------------------------------------------------------
Artiom 4:4a79942713fa 279
Artiom 0:bc74da1c502f 280
Artiom 0:bc74da1c502f 281 #endif
Artiom 0:bc74da1c502f 282 #ifdef ROBOT_BIG
Artiom 0:bc74da1c502f 283 case 3:
Artiom 0:bc74da1c502f 284
Artiom 0:bc74da1c502f 285 break;
Artiom 0:bc74da1c502f 286
Artiom 0:bc74da1c502f 287 case 5:
Artiom 0:bc74da1c502f 288
Artiom 0:bc74da1c502f 289 break;
Artiom 0:bc74da1c502f 290
Artiom 0:bc74da1c502f 291 #endif
Artiom 0:bc74da1c502f 292 }
Artiom 0:bc74da1c502f 293 FIFO_lecture=(FIFO_lecture+1)%SIZE_FIFO;
Artiom 0:bc74da1c502f 294
Artiom 0:bc74da1c502f 295 }
Artiom 4:4a79942713fa 296
Artiom 4:4a79942713fa 297
Artiom 4:4a79942713fa 298 }
Artiom 4:4a79942713fa 299
Artiom 4:4a79942713fa 300 void automate_ventouse_presentoir_avant (void)
Artiom 4:4a79942713fa 301 {
Artiom 4:4a79942713fa 302
Artiom 4:4a79942713fa 303 typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat;
Artiom 4:4a79942713fa 304 static type_etat etat = init;
Artiom 4:4a79942713fa 305
Artiom 4:4a79942713fa 306 switch(etat) {
Artiom 4:4a79942713fa 307 case init: //attente d'initialisation
Artiom 4:4a79942713fa 308 if(fpresentoir_avant)
Artiom 4:4a79942713fa 309 etat=envoi_instruction;
Artiom 4:4a79942713fa 310 break;
Artiom 4:4a79942713fa 311
Artiom 4:4a79942713fa 312 case envoi_instruction://envoi instruction
Artiom 4:4a79942713fa 313 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 4:4a79942713fa 314 presentoir_avant();
Artiom 5:6e198cdd99ad 315 SendRawId(HACHEUR_STATUT_VENTOUSES);
Artiom 4:4a79942713fa 316 etat = attente_ack_ventouse;
Artiom 4:4a79942713fa 317 break;
Artiom 4:4a79942713fa 318
Artiom 4:4a79942713fa 319 case attente_ack_ventouse:
Artiom 5:6e198cdd99ad 320 if((status_pompe&MASK_PRESENTOIR_AV)==MASK_PRESENTOIR_AV) {
Artiom 4:4a79942713fa 321 fpresentoir_avant=0;
Artiom 5:6e198cdd99ad 322 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 4:4a79942713fa 323 etat = init;
Artiom 5:6e198cdd99ad 324 }
Artiom 5:6e198cdd99ad 325 break;
Artiom 5:6e198cdd99ad 326
Artiom 5:6e198cdd99ad 327 }
Artiom 5:6e198cdd99ad 328 }
Artiom 5:6e198cdd99ad 329 void automate_ventouse_presentoir_arriere (void)
Artiom 5:6e198cdd99ad 330 {
Artiom 5:6e198cdd99ad 331
Artiom 5:6e198cdd99ad 332 typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat;
Artiom 5:6e198cdd99ad 333 static type_etat etat = init;
Artiom 5:6e198cdd99ad 334
Artiom 5:6e198cdd99ad 335 switch(etat) {
Artiom 5:6e198cdd99ad 336 case init: //attente d'initialisation
Artiom 5:6e198cdd99ad 337 if(fpresentoir_arriere)
Artiom 5:6e198cdd99ad 338 etat=envoi_instruction;
Artiom 5:6e198cdd99ad 339 break;
Artiom 5:6e198cdd99ad 340
Artiom 5:6e198cdd99ad 341 case envoi_instruction://envoi instruction
Artiom 5:6e198cdd99ad 342 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
Artiom 5:6e198cdd99ad 343 presentoir_arriere();
Artiom 5:6e198cdd99ad 344 SendRawId(HACHEUR_STATUT_VENTOUSES);
Artiom 5:6e198cdd99ad 345 etat = attente_ack_ventouse;
Artiom 5:6e198cdd99ad 346 break;
Artiom 5:6e198cdd99ad 347
Artiom 5:6e198cdd99ad 348 case attente_ack_ventouse:
Artiom 5:6e198cdd99ad 349 if((status_pompe&MASK_PRESENTOIR_AR)==MASK_PRESENTOIR_AR) {
Artiom 5:6e198cdd99ad 350 fpresentoir_arriere=0;
Artiom 5:6e198cdd99ad 351 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
Artiom 5:6e198cdd99ad 352 etat = init;
Artiom 4:4a79942713fa 353 }
Artiom 4:4a79942713fa 354 break;
Artiom 4:4a79942713fa 355
Artiom 4:4a79942713fa 356 }
Artiom 4:4a79942713fa 357
Artiom 4:4a79942713fa 358
Artiom 4:4a79942713fa 359
Artiom 0:bc74da1c502f 360 }