homologation gros robot et test avec les ack de la carte a tout faire

Fork of CRAC-Strat_2017_HOMOLOGATION_PETIT_ROBOT by CRAC Team

Committer:
ClementBreteau
Date:
Thu May 25 06:36:48 2017 +0000
Revision:
21:7c60d6dfcab5
Parent:
19:b4b91258c275
homologation gros robot avec test au niveau des ack

Who changed what in which revision?

UserRevisionLine numberNew 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 1:116040d14164 10 DigitalOut led2(LED2);//Led d'indication de problème, si elle clignote, c'est pas bon
antbig 8:0edc7dfb7f7e 11 DigitalOut led3(LED3);//Led d'indication de problème, si elle clignote, c'est pas bon
antbig 8:0edc7dfb7f7e 12 DigitalOut led4(LED4);//Led d'indication de problème, si elle clignote, c'est pas bon
antbig 0:ad97421fb1fb 13
antbig 0:ad97421fb1fb 14 /****************************************************************************************/
antbig 0:ad97421fb1fb 15 /* FUNCTION NAME: canRx_ISR */
antbig 0:ad97421fb1fb 16 /* DESCRIPTION : Interruption en réception sur le CAN */
antbig 0:ad97421fb1fb 17 /****************************************************************************************/
antbig 0:ad97421fb1fb 18 void canRx_ISR (void)
antbig 0:ad97421fb1fb 19 {
antbig 0:ad97421fb1fb 20 if (can1.read(msgRxBuffer[FIFO_ecriture])) {
antbig 0:ad97421fb1fb 21 if(msgRxBuffer[FIFO_ecriture].id==RESET_STRAT) mbed_reset();
antbig 0:ad97421fb1fb 22 else FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO;
antbig 0:ad97421fb1fb 23 }
antbig 0:ad97421fb1fb 24 }
antbig 0:ad97421fb1fb 25
antbig 0:ad97421fb1fb 26
antbig 0:ad97421fb1fb 27 /**********************************************************************************/
antbig 0:ad97421fb1fb 28 /* FUNCTION NAME: main */
antbig 0:ad97421fb1fb 29 /* DESCRIPTION : Fonction principal du programme */
antbig 0:ad97421fb1fb 30 /**********************************************************************************/
antbig 0:ad97421fb1fb 31 int main() {
antbig 0:ad97421fb1fb 32 can1.frequency(1000000); // fréquence de travail 1Mbit/s
antbig 0:ad97421fb1fb 33 can1.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN
antbig 0:ad97421fb1fb 34
ClementBreteau 18:cc5fec34ed9c 35
ClementBreteau 14:c8fc06c4887f 36 wait_ms(5000);
antbig 12:14729d584500 37 #ifdef ROBOT_BIG
antbig 12:14729d584500 38 tactile_printf("Initialisation gros robot");
antbig 12:14729d584500 39 #else
antbig 12:14729d584500 40 tactile_printf("Initialisation petit robot");
antbig 12:14729d584500 41 #endif
ClementBreteau 18:cc5fec34ed9c 42 led1 = 1;
antbig 0:ad97421fb1fb 43 initRobot();//Initialisation du robot
ClementBreteau 18:cc5fec34ed9c 44 initRobotActionneur();
ClementBreteau 18:cc5fec34ed9c 45 led1 = 0;
ClementBreteau 14:c8fc06c4887f 46 wait_ms(2000);//Attente pour que toutes les cartes se lancent et surtout le CANBlue
SquirrelGod 19:b4b91258c275 47
antbig 0:ad97421fb1fb 48 /**
antbig 0:ad97421fb1fb 49 A retirer lors de l'utilisation avec selecteur de stratégie sur IHM
antbig 0:ad97421fb1fb 50 **/
antbig 0:ad97421fb1fb 51 //strcpy(cheminFileStart,"/local/test.txt");//On ouvre le fichier test.txt
antbig 0:ad97421fb1fb 52 //loadAllInstruction();//Mise en cache de toute les instructions
ClementBreteau 18:cc5fec34ed9c 53
antbig 0:ad97421fb1fb 54 while(true) {
antbig 9:d0042422d95a 55 automate_process();//Boucle dans l'automate principal
ClementBreteau 16:7321fb3bb396 56 canProcessRx();//Traitement des trames CAN en attente
ClementBreteau 15:c2fc239e85df 57 //AX12_doLoop();//Vérification de la position des AX12
antbig 0:ad97421fb1fb 58 }
antbig 0:ad97421fb1fb 59 }