Tatsuya Yamamoto / Mbed 2 deprecated UV_Robot_Nucleo

Dependencies:   mbed X_NUCLEO_PLC01A1 ros_lib_melodic

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;
+    }
+}