rainbow

Dependencies:   mbed FastPWM

Revision:
52:8ea76864368a
Parent:
50:3c630b5eba9f
Child:
53:4d66fb1c5dd9
Child:
54:647072f5307a
diff -r b46bed7fec80 -r 8ea76864368a CAN/function_CAN.cpp
--- a/CAN/function_CAN.cpp	Wed Feb 19 00:44:07 2020 +0000
+++ b/CAN/function_CAN.cpp	Wed Feb 19 05:48:57 2020 +0000
@@ -66,11 +66,11 @@
             break;
         }
         case CRX_SET_OPERATING_MODE: {
-            OPERATING_MODE = (int16_t) msg.data[1];
-            
+            OPERATING_MODE = (uint8_t) msg.data[1];
+            SENSING_MODE = (uint8_t) msg.data[2];
+            CURRENT_CONTROL_MODE = (uint8_t) msg.data[3];
+            FLAG_VALVE_DEADZONE = (uint8_t) msg.data[4];
             ROM_RESET_DATA();
-            
-
             break;
         }
         case CRX_SET_ENC_ZERO: {
@@ -766,9 +766,12 @@
     CANMessage temp_msg;
     
     temp_msg.id = CID_TX_INFO;
-    temp_msg.len = 2;
+    temp_msg.len = 5;
     temp_msg.data[0] = (uint8_t) CTX_SEND_OPERATING_MODE;
     temp_msg.data[1] = (uint8_t) OPERATING_MODE;
+    temp_msg.data[2] = (uint8_t) SENSING_MODE;
+    temp_msg.data[3] = (uint8_t) CURRENT_CONTROL_MODE;
+    temp_msg.data[4] = (uint8_t) FLAG_VALVE_DEADZONE;
 
     can.write(temp_msg);
 }
@@ -1290,7 +1293,23 @@
  Sensor & State Transmission Functions
 *******************************************************************************/
 
-void CAN_TX_POSITION(int16_t t_pos, int16_t t_vel, int16_t t_torq) {
+void CAN_TX_POSITION_FT(int16_t t_pos, int16_t t_vel, int16_t t_torq) {
+    CANMessage temp_msg;
+
+    temp_msg.id = CID_TX_POSITION;
+    temp_msg.len = 6;
+    temp_msg.data[0] = (uint8_t) t_pos;
+    temp_msg.data[1] = (uint8_t) (t_pos >> 8);
+    temp_msg.data[2] = (uint8_t) t_vel;
+    temp_msg.data[3] = (uint8_t) (t_vel >> 8);
+    temp_msg.data[4] = (uint8_t) t_torq;
+    temp_msg.data[5] = (uint8_t) (t_torq >> 8);
+
+    can.write(temp_msg);
+}
+
+void CAN_TX_POSITION_PRESSURE(int16_t t_pos, int16_t t_vel, int16_t t_pa, int16_t t_pb) {
+    
     CANMessage temp_msg;
 
     temp_msg.id = CID_TX_POSITION;
@@ -1299,8 +1318,10 @@
     temp_msg.data[1] = (uint8_t) (t_pos >> 8);
     temp_msg.data[2] = (uint8_t) t_vel;
     temp_msg.data[3] = (uint8_t) (t_vel >> 8);
-    temp_msg.data[4] = (uint8_t) t_torq;
-    temp_msg.data[5] = (uint8_t) (t_torq >> 8);
+    temp_msg.data[4] = (uint8_t) t_pa;
+    temp_msg.data[5] = (uint8_t) (t_pa >> 8);
+    temp_msg.data[6] = (uint8_t) t_pb;
+    temp_msg.data[7] = (uint8_t) (t_pb >> 8);
 
     can.write(temp_msg);
 }
@@ -1362,3 +1383,4 @@
 
 
 
+