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