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 X-NUCLEO-IHM05A1
Diff: main.cpp
- Revision:
- 18:65707db67191
- Parent:
- 17:dc1b04f0b55d
- Child:
- 19:9680ebe86f4a
--- a/main.cpp Thu Feb 07 09:13:56 2019 +0000
+++ b/main.cpp Thu Feb 07 18:38:41 2019 +0000
@@ -19,7 +19,7 @@
FALSE, //Automatic HIZ STOP
100000 //VREFA and VREFB PWM frequency (Hz)
};
-
+Thread canrxa;
// Utility
InterruptIn button(USER_BUTTON);
@@ -78,20 +78,22 @@
}
// CAN
-CAN can1(PB_8, PB_9); // RX, TX
+CAN can1(PA_11, PA_12); // RX, TX
CANMessage messageIn;
CANMessage messageOut;
int filter = can1.filter(0x020, 0x4FF, CANStandard);
-void can_rx_handler()
+void canrx()
{
- printf("CAN: Rec\n\r");
-
+ printf("CAN: in\n\r");
+ while(1){
if(can1.read(messageIn, filter))
{
- printf("CAN: Rec %d\n\r", (messageIn.data[0] + (messageIn.data[1] << 8) + (messageIn.data[2] << 16) + (messageIn.data[3] << 24)));
+ printf("CAN: mess %d\n\r", (messageIn.data[0] + (messageIn.data[1] << 8) + (messageIn.data[2] << 16) + (messageIn.data[3] << 24)));
+ printf("CANaacc: id %x \n\r ",messageIn.id);
+}
}
}
@@ -106,7 +108,7 @@
if (motor->init(&init) != COMPONENT_OK)
{
- printf("ERROR: Motor Init\n\r");
+ printf("ERROR: vvMotor Init\n\r");
exit(EXIT_FAILURE);
}
@@ -118,13 +120,14 @@
button.rise(&button_int_handler);
- printf("DONE: Motor Init\n\r");
+ printf("DONE: Mobjhbtor Init\n\r");
// CAN Initialization
- can1.reset();
- can1.frequency(500000);
- can1.attach(&can_rx_handler);
+ //can1.reset();
+ // can1.frequency(500000);
+ //can1.attach(&can_rx_handler);
+canrxa.start(canrx);
printf("DONE: CAN Init\n\r");
motor->run(StepperMotor::FWD);