PINOUT à jour, trame CAN OK
Dependencies: mbed ident_crac
Code carte pompe
Diff: main.cpp
- Revision:
- 2:4cc8fa2f64be
- Parent:
- 1:8a55f1d5cb26
- Child:
- 3:cf33f9d4d6ff
- Child:
- 4:82c90657da4a
--- a/main.cpp Tue May 07 08:33:42 2019 +0000 +++ b/main.cpp Tue May 07 13:14:29 2019 +0000 @@ -6,10 +6,6 @@ #define SIZE_FIFO 50 -CAN can(PB_8,PB_9,1000000); -Serial pc(USBTX,USBRX); - - CANMessage msgRxBuffer[SIZE_FIFO]; unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN signed char FIFO_lecture=0;//Position du fifo de lecture des messages CAN @@ -20,6 +16,8 @@ void get_etat_ventouses(); +CAN can(PB_8,PB_9,1000000); +Serial pc(USBTX,USBRX); /*********************************************************************************************************/ /* FUNCTION NAME: canRx_ISR */ @@ -54,27 +52,27 @@ case HACHEUR_GET_ATOM: BRAS = msgRxBuffer[FIFO_lecture].data[0]; pc.printf("HACHEUR_GET_ATOM bras %d\n", BRAS); - ventouse[BRAS]->attraper(); + ventouse[BRAS]->action(1); break; case HACHEUR_RELEASE_ATOM: BRAS = msgRxBuffer[FIFO_lecture].data[0]; pc.printf("HACHEUR_RELEASE_ATOM bras %d\n", BRAS); - ventouse[BRAS]->relacher(); + ventouse[BRAS]->action(0); break; case HACHEUR_GET_PRESENTOIR_AR: pc.printf("HACHEUR_GET_DISTRIB_AR\n"); - ventouse[AR_GAUCHE]->attraper(); - ventouse[AR_CENTRE]->attraper(); - ventouse[AR_DROIT]->attraper(); + ventouse[AR_GAUCHE]->action(1);; + ventouse[AR_CENTRE]->action(1);; + ventouse[AR_DROIT]->action(1);; break; case HACHEUR_GET_PRESENTOIR_AV : pc.printf("HACHEUR_GET_DISTRIB_AV\n"); - ventouse[AV_GAUCHE]->relacher(); - ventouse[AV_CENTRE]->relacher(); - ventouse[AV_DROIT]->relacher(); + ventouse[AV_GAUCHE]->action(1);; + ventouse[AV_CENTRE]->action(1);; + ventouse[AV_DROIT]->action(1);; break; case HACHEUR_STATUT_VENTOUSES: @@ -100,20 +98,23 @@ can.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN wait(1); #ifdef ROBOT_SMALL - ventouse[AR_CENTRE] = new Ventouse(PC_9, PA_8, PB_0); - ventouse[AR_DROIT] = new Ventouse(PA_9, PA_10, PB_1); - ventouse[AR_BAS] = new Ventouse(PA_11, PA_15, PC_1); - ventouse[AV_GAUCHE] = new Ventouse(PB_7, PB_6, PC_0); + ventouse[AR_CENTRE] = new Ventouse(PC_9, PA_8, PB_0, AR_CENTRE); + ventouse[AR_DROIT] = new Ventouse(PA_9, PA_10, PB_1, AR_DROIT); + ventouse[AR_BAS] = new Ventouse(PA_11, PA_15, PC_1, AR_BAS); + ventouse[AV_GAUCHE] = new Ventouse(PB_7, PB_6, PC_0, AV_GAUCHE); - ventouse[AV_CENTRE] = new Ventouse(PC_7,PC_8 , PC_5); - ventouse[AV_BAS] = new Ventouse(PB_10, PB_2, PC_4); - ventouse[AR_GAUCHE] = new Ventouse(PA_6, PA_5, PA_7); - ventouse[AV_DROIT] = new Ventouse(PA_0, PA_1, PA_4); + ventouse[AV_CENTRE] = new Ventouse(PC_7,PC_8 , PC_5, AV_CENTRE); + ventouse[AV_BAS] = new Ventouse(PB_10, PB_2, PC_4, AV_BAS); + ventouse[AR_GAUCHE] = new Ventouse(PA_6, PA_5, PA_7, AR_GAUCHE); + ventouse[AV_DROIT] = new Ventouse(PA_0, PA_1, PA_4, AV_DROIT); #endif pc.printf("LAUNCHED"); while(1) { canProcessRx(); + for(int i=0; i<8; i++){ + ventouse[i]->automate(); + } if(end_game){ for(int i=0; i<8;i++){ ventouse[i]->setPompe(0.0); @@ -132,6 +133,8 @@ etat_ventouses.len=2; etat_ventouses.format=CANStandard; etat_ventouses.type=CANData; + etat_ventouses.data[0]=0; + etat_ventouses.data[0]=1; for(int i=7; i>=0; i--){ etat_ventouses.data[0] = (etat_ventouses.data[0]<<1) + ventouse[i]->getPompe(); etat_ventouses.data[1] = (etat_ventouses.data[1]<<1) + ventouse[i]->getPression();