Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed bloc_8_pompe2 Herkulex_library_2022 ident_crac1 bloc_pompe2
Diff: main.cpp
- Revision:
- 2:c7f2e7d8b305
- Child:
- 3:77e937c315f1
diff -r 9bf1cb351f77 -r c7f2e7d8b305 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Mar 08 16:03:27 2022 +0000
@@ -0,0 +1,84 @@
+#include "main.h"
+
+//initialisations relatives au Bus CAN
+CAN bus_can(PB_8,PB_9,1000000);
+
+CANMessage rx_message ;
+char data[1] = {0x28};
+CANMessage tx_message(0x220,data,1,CANData,CANStandard);
+
+int flag_reception_CAN = 0 ;
+void interruption_reception(void) ;
+void gestion_Message_CAN(void) ;
+void Envoi_msg_CAN(char donnee);
+
+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
+unsigned short ackFinAction = 0;
+
+int main (void)
+{
+ wait_ms(200); //tempo pour boot
+ bus_can.attach(&interruption_reception); //création de l'interrupt attachée à la réception sur le CAN
+ //servo_interrupt_en(); //permettre les interuptions
+ //activer_torque();
+ wait_ms(200);
+ //pc.printf("\nLAUNCHED\n\r");
+
+ while(1)
+ {
+ if(flag_reception_CAN)
+ {
+ gestion_Message_CAN();
+ }
+ }
+}
+
+void interruption_reception(void)
+{
+ bus_can.write(tx_message);
+ bus_can.read(rx_message);
+ flag_reception_CAN = 1 ;
+}
+
+void gestion_Message_CAN(void)
+{
+ int identifiant = rx_message.id ;
+
+ switch (identifiant)
+ {
+ case TORQUE_ACT:
+ activer_torque();
+ break;
+
+ case TORQUE_DESACT:
+ desactiver_torque();
+ break;
+
+ case BRAS_PRISE:
+ fct_prise_avant(SERIAL_BAS_DROITE);
+ break;
+
+ case TORQUE_1:
+ setTorque(AV_BASE,TORQUE_ON,5);
+ break;
+
+ default:
+ break;
+ }
+ flag_reception_CAN = 0 ;
+
+}
+
+void Envoi_msg_CAN(char donnee)
+{
+ CANMessage message;
+ message.id = 0x220;
+ message.len=1;
+ message.format=CANStandard;
+ message.type=CANData;
+ message.data[0]=donnee;
+
+ bus_can.write(message);
+}