![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Programme carte strategie (disco)
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
main.cpp@29:41e02746041d, 2018-04-06 (annotated)
- Committer:
- Sitkah
- Date:
- Fri Apr 06 13:47:19 2018 +0000
- Revision:
- 29:41e02746041d
- Parent:
- 19:b4b91258c275
- Child:
- 30:a1e37af4bbde
version fusionn?e
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sitkah | 29:41e02746041d | 1 | #include "mbed.h" |
antbig | 0:ad97421fb1fb | 2 | #include "global.h" |
Sitkah | 29:41e02746041d | 3 | #include <CAN.h> |
Sitkah | 29:41e02746041d | 4 | |
Sitkah | 29:41e02746041d | 5 | CAN can1(PB_8,PB_9); // Rx&Tx pour le CAN |
Sitkah | 29:41e02746041d | 6 | CAN can2(PB_5, PB_13); |
Sitkah | 29:41e02746041d | 7 | CANMessage msgRxBuffer[SIZE_FIFO]; |
Sitkah | 29:41e02746041d | 8 | unsigned char FIFO_ecriture; |
Sitkah | 29:41e02746041d | 9 | char strat_sd[10][SIZE+8]; |
Sitkah | 29:41e02746041d | 10 | char PATH[10][SIZE+8]; |
Sitkah | 29:41e02746041d | 11 | |
Sitkah | 29:41e02746041d | 12 | |
antbig | 0:ad97421fb1fb | 13 | |
Sitkah | 29:41e02746041d | 14 | char cheminFileStart[SIZE+8]; //Le chemin du fichier de strat, utiliser strcpy(cheminFileStart,"/local/strat.txt"); |
Sitkah | 29:41e02746041d | 15 | struct S_Instruction strat_instructions[SIZE_BUFFER_FILE]; //La liste des instruction chargé en mémoire |
Sitkah | 29:41e02746041d | 16 | unsigned char nb_instructions; //Le nombre d'instruction dans le fichier de strategie |
Sitkah | 29:41e02746041d | 17 | unsigned char actual_instruction;//La ligne de l'instruction en cours d'execution |
Sitkah | 29:41e02746041d | 18 | |
Sitkah | 29:41e02746041d | 19 | unsigned short telemetreDistance=0; |
antbig | 0:ad97421fb1fb | 20 | |
Sitkah | 29:41e02746041d | 21 | unsigned char InversStrat = 1;//Si à 1, indique que l'on part de l'autre cote de la table(inversion des Y) |
Sitkah | 29:41e02746041d | 22 | |
Sitkah | 29:41e02746041d | 23 | |
Sitkah | 29:41e02746041d | 24 | unsigned short waitingAckID=0;//L'id du ack attendu |
Sitkah | 29:41e02746041d | 25 | unsigned short waitingAckFrom=0;//La provenance du ack attendu |
Sitkah | 29:41e02746041d | 26 | char modeTelemetre; // Si à 1, indique que l'on attend une reponse du telemetre |
antbig | 0:ad97421fb1fb | 27 | |
antbig | 0:ad97421fb1fb | 28 | DigitalOut led1(LED1);//Led d'indication de problème, si elle clignote, c'est pas bon |
antbig | 1:116040d14164 | 29 | DigitalOut led2(LED2);//Led d'indication de problème, si elle clignote, c'est pas bon |
antbig | 8:0edc7dfb7f7e | 30 | DigitalOut led3(LED3);//Led d'indication de problème, si elle clignote, c'est pas bon |
antbig | 8:0edc7dfb7f7e | 31 | DigitalOut led4(LED4);//Led d'indication de problème, si elle clignote, c'est pas bon |
antbig | 0:ad97421fb1fb | 32 | |
antbig | 0:ad97421fb1fb | 33 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 34 | /* FUNCTION NAME: canRx_ISR */ |
antbig | 0:ad97421fb1fb | 35 | /* DESCRIPTION : Interruption en réception sur le CAN */ |
antbig | 0:ad97421fb1fb | 36 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 37 | void canRx_ISR (void) |
antbig | 0:ad97421fb1fb | 38 | { |
antbig | 0:ad97421fb1fb | 39 | if (can1.read(msgRxBuffer[FIFO_ecriture])) { |
Sitkah | 29:41e02746041d | 40 | //if(msgRxBuffer[FIFO_ecriture].id==RESET_STRAT) mbed_reset(); |
Sitkah | 29:41e02746041d | 41 | /*else*/ FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO; |
antbig | 0:ad97421fb1fb | 42 | } |
antbig | 0:ad97421fb1fb | 43 | } |
antbig | 0:ad97421fb1fb | 44 | |
antbig | 0:ad97421fb1fb | 45 | |
Sitkah | 29:41e02746041d | 46 | |
Sitkah | 29:41e02746041d | 47 | |
antbig | 0:ad97421fb1fb | 48 | /**********************************************************************************/ |
antbig | 0:ad97421fb1fb | 49 | /* FUNCTION NAME: main */ |
antbig | 0:ad97421fb1fb | 50 | /* DESCRIPTION : Fonction principal du programme */ |
antbig | 0:ad97421fb1fb | 51 | /**********************************************************************************/ |
antbig | 0:ad97421fb1fb | 52 | int main() { |
antbig | 0:ad97421fb1fb | 53 | can1.frequency(1000000); // fréquence de travail 1Mbit/s |
antbig | 0:ad97421fb1fb | 54 | can1.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN |
Sitkah | 29:41e02746041d | 55 | can2.frequency(1000000); |
ClementBreteau | 18:cc5fec34ed9c | 56 | |
antbig | 12:14729d584500 | 57 | #ifdef ROBOT_BIG |
antbig | 12:14729d584500 | 58 | tactile_printf("Initialisation gros robot"); |
antbig | 12:14729d584500 | 59 | #else |
antbig | 12:14729d584500 | 60 | tactile_printf("Initialisation petit robot"); |
antbig | 12:14729d584500 | 61 | #endif |
ClementBreteau | 18:cc5fec34ed9c | 62 | led1 = 1; |
Sitkah | 29:41e02746041d | 63 | bluetooth_init(); |
antbig | 0:ad97421fb1fb | 64 | initRobot();//Initialisation du robot |
ClementBreteau | 18:cc5fec34ed9c | 65 | initRobotActionneur(); |
Sitkah | 29:41e02746041d | 66 | lecture_fichier(); |
ClementBreteau | 18:cc5fec34ed9c | 67 | led1 = 0; |
Sitkah | 29:41e02746041d | 68 | //wait_ms(2000);//Attente pour que toutes les cartes se lancent et surtout le CANBlue |
Sitkah | 29:41e02746041d | 69 | |
antbig | 0:ad97421fb1fb | 70 | while(true) { |
Sitkah | 29:41e02746041d | 71 | automate_etat_ihm(); |
antbig | 9:d0042422d95a | 72 | automate_process();//Boucle dans l'automate principal |
ClementBreteau | 15:c2fc239e85df | 73 | //AX12_doLoop();//Vérification de la position des AX12 |
antbig | 0:ad97421fb1fb | 74 | } |
antbig | 0:ad97421fb1fb | 75 | } |