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_PLC01A1 ros_lib_melodic
Diff: can_controller.cpp
- Revision:
- 0:43eb9ccc1583
- Child:
- 1:ef4b86795d79
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/can_controller.cpp Sat Aug 08 23:54:01 2020 +0000
@@ -0,0 +1,25 @@
+#include "can_controller.h"
+
+/**
+ * @brief Initialize CAN controller
+ * @param None
+*/
+CANController::CANController()
+:can1(MBED_CONF_APP_CAN1_RD, MBED_CONF_APP_CAN1_TD)
+{}
+
+/**
+ * @brief Send CAN message
+ * @param ID: CAN ID of the target device
+ * @param msgData: Address of the message data to be sent
+ * @retval 0: Transmission is successful, -1:Transmission is failed
+*/
+int CANController::sendMessage( uint16_t ID, char *msgData ){
+ CANMessage msg(ID, msgData, 8, CANData, CANStandard);
+ int successFlag = can1.write(msg);
+ if(successFlag){
+ return 0;
+ }else{
+ return -1;
+ }
+}