carte_strategie_2019
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
main.cpp@0:ad97421fb1fb, 2016-04-13 (annotated)
- Committer:
- antbig
- Date:
- Wed Apr 13 22:04:54 2016 +0000
- Revision:
- 0:ad97421fb1fb
- Child:
- 1:116040d14164
Ajout interruption fin de match
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
antbig | 0:ad97421fb1fb | 1 | #include "global.h" |
antbig | 0:ad97421fb1fb | 2 | |
antbig | 0:ad97421fb1fb | 3 | CAN can1(p30,p29); // Rx&Tx pour le CAN |
antbig | 0:ad97421fb1fb | 4 | CANMessage msgRxBuffer[SIZE_FIFO]; // buffer en réception pour le CAN |
antbig | 0:ad97421fb1fb | 5 | unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN |
antbig | 0:ad97421fb1fb | 6 | |
antbig | 0:ad97421fb1fb | 7 | extern "C" void mbed_reset();//Pour pouvoir reset la carte |
antbig | 0:ad97421fb1fb | 8 | |
antbig | 0:ad97421fb1fb | 9 | DigitalOut led1(LED1);//Led d'indication de problème, si elle clignote, c'est pas bon |
antbig | 0:ad97421fb1fb | 10 | |
antbig | 0:ad97421fb1fb | 11 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 12 | /* FUNCTION NAME: canRx_ISR */ |
antbig | 0:ad97421fb1fb | 13 | /* DESCRIPTION : Interruption en réception sur le CAN */ |
antbig | 0:ad97421fb1fb | 14 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 15 | void canRx_ISR (void) |
antbig | 0:ad97421fb1fb | 16 | { |
antbig | 0:ad97421fb1fb | 17 | if (can1.read(msgRxBuffer[FIFO_ecriture])) { |
antbig | 0:ad97421fb1fb | 18 | if(msgRxBuffer[FIFO_ecriture].id==RESET_STRAT) mbed_reset(); |
antbig | 0:ad97421fb1fb | 19 | else FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO; |
antbig | 0:ad97421fb1fb | 20 | } |
antbig | 0:ad97421fb1fb | 21 | } |
antbig | 0:ad97421fb1fb | 22 | |
antbig | 0:ad97421fb1fb | 23 | |
antbig | 0:ad97421fb1fb | 24 | /**********************************************************************************/ |
antbig | 0:ad97421fb1fb | 25 | /* FUNCTION NAME: main */ |
antbig | 0:ad97421fb1fb | 26 | /* DESCRIPTION : Fonction principal du programme */ |
antbig | 0:ad97421fb1fb | 27 | /**********************************************************************************/ |
antbig | 0:ad97421fb1fb | 28 | int main() { |
antbig | 0:ad97421fb1fb | 29 | can1.frequency(1000000); // fréquence de travail 1Mbit/s |
antbig | 0:ad97421fb1fb | 30 | can1.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN |
antbig | 0:ad97421fb1fb | 31 | |
antbig | 0:ad97421fb1fb | 32 | /** |
antbig | 0:ad97421fb1fb | 33 | On enregistre les id des AX12 présent sur la carte |
antbig | 0:ad97421fb1fb | 34 | **/ |
antbig | 0:ad97421fb1fb | 35 | AX12_register(1,0x0FF); |
antbig | 0:ad97421fb1fb | 36 | AX12_register(2); |
antbig | 0:ad97421fb1fb | 37 | |
antbig | 0:ad97421fb1fb | 38 | wait_ms(1000); |
antbig | 0:ad97421fb1fb | 39 | |
antbig | 0:ad97421fb1fb | 40 | initRobot();//Initialisation du robot |
antbig | 0:ad97421fb1fb | 41 | |
antbig | 0:ad97421fb1fb | 42 | wait_ms(9000);//Attente pour que toutes les cartes se lancent et surtout le CANBlue |
antbig | 0:ad97421fb1fb | 43 | tactile_printf("Initialisation cartes..."); |
antbig | 0:ad97421fb1fb | 44 | |
antbig | 0:ad97421fb1fb | 45 | /** |
antbig | 0:ad97421fb1fb | 46 | A retirer lors de l'utilisation avec selecteur de stratégie sur IHM |
antbig | 0:ad97421fb1fb | 47 | **/ |
antbig | 0:ad97421fb1fb | 48 | //strcpy(cheminFileStart,"/local/test.txt");//On ouvre le fichier test.txt |
antbig | 0:ad97421fb1fb | 49 | //loadAllInstruction();//Mise en cache de toute les instructions |
antbig | 0:ad97421fb1fb | 50 | |
antbig | 0:ad97421fb1fb | 51 | |
antbig | 0:ad97421fb1fb | 52 | while(true) { |
antbig | 0:ad97421fb1fb | 53 | //automate_process();//Boucle dans l'automate principal |
antbig | 0:ad97421fb1fb | 54 | canProcessRx();//Traitement des trames CAN en attente |
antbig | 0:ad97421fb1fb | 55 | AX12_doLoop();//Vérification de la position des AX12 |
antbig | 0:ad97421fb1fb | 56 | } |
antbig | 0:ad97421fb1fb | 57 | } |