2018.07.26
Dependencies: TextLCD USBDevice mbed-rtos mbed
common.h@2:d0a5ee4e7bb8, 2018-07-26 (annotated)
- Committer:
- sayzyas
- Date:
- Thu Jul 26 00:20:57 2018 +0000
- Revision:
- 2:d0a5ee4e7bb8
- Parent:
- 1:368ba89c2e6b
2018.07.26
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sayzyas | 2:d0a5ee4e7bb8 | 1 | /* |
sayzyas | 2:d0a5ee4e7bb8 | 2 | DEBUG PRINT MACRO |
sayzyas | 2:d0a5ee4e7bb8 | 3 | http://qiita.com/saltheads/items/e1b0ab54d3d6029c9593 |
sayzyas | 2:d0a5ee4e7bb8 | 4 | http://tricky-code.net/nicecode/code10.php |
sayzyas | 2:d0a5ee4e7bb8 | 5 | */ |
sayzyas | 0:f4e2a62331ef | 6 | /* Information */ |
sayzyas | 2:d0a5ee4e7bb8 | 7 | #define LatestUpDate "2016.11.04" |
sayzyas | 2:d0a5ee4e7bb8 | 8 | #define ProgramRevision "Rev 2.40" |
sayzyas | 2:d0a5ee4e7bb8 | 9 | #define Author "ZisNotRevast" |
sayzyas | 1:368ba89c2e6b | 10 | #define Company "Revast Co.,Ltd." |
sayzyas | 2:d0a5ee4e7bb8 | 11 | |
sayzyas | 2:d0a5ee4e7bb8 | 12 | //#define __CREATE_SETTING_FILE__ |
sayzyas | 2:d0a5ee4e7bb8 | 13 | //#define __TARGET_BOARD_CHECK__ |
sayzyas | 2:d0a5ee4e7bb8 | 14 | |
sayzyas | 2:d0a5ee4e7bb8 | 15 | |
sayzyas | 2:d0a5ee4e7bb8 | 16 | //#define __WInchDebug__ // For debugging |
sayzyas | 2:d0a5ee4e7bb8 | 17 | |
sayzyas | 2:d0a5ee4e7bb8 | 18 | |
sayzyas | 0:f4e2a62331ef | 19 | |
sayzyas | 2:d0a5ee4e7bb8 | 20 | // Read motor current |
sayzyas | 2:d0a5ee4e7bb8 | 21 | #define __READ_TFM_MOTOR_CURRENT__ |
sayzyas | 2:d0a5ee4e7bb8 | 22 | |
sayzyas | 2:d0a5ee4e7bb8 | 23 | #define __IIC_COMAMND_SEND__ |
sayzyas | 2:d0a5ee4e7bb8 | 24 | |
sayzyas | 2:d0a5ee4e7bb8 | 25 | #define __SET_WINCH_MOTOR_SPEED_BY_VOLUME__ |
sayzyas | 2:d0a5ee4e7bb8 | 26 | |
sayzyas | 2:d0a5ee4e7bb8 | 27 | // ====================================================================== |
sayzyas | 2:d0a5ee4e7bb8 | 28 | // For Debugging |
sayzyas | 2:d0a5ee4e7bb8 | 29 | // ====================================================================== |
sayzyas | 2:d0a5ee4e7bb8 | 30 | //#define __DEBUG_PRINT_SW__ // Display SW Status to console |
sayzyas | 0:f4e2a62331ef | 31 | #define __DEBUG_L0__ |
sayzyas | 2:d0a5ee4e7bb8 | 32 | //#define __DEBUG_L1__ |
sayzyas | 2:d0a5ee4e7bb8 | 33 | //#define __DEBUG_L2__ |
sayzyas | 2:d0a5ee4e7bb8 | 34 | #define __DEBUG_L3__ |
sayzyas | 0:f4e2a62331ef | 35 | //#define __DEBUG_L4__ |
sayzyas | 2:d0a5ee4e7bb8 | 36 | //#define __DEBUG_L5__ |
sayzyas | 2:d0a5ee4e7bb8 | 37 | |
sayzyas | 2:d0a5ee4e7bb8 | 38 | #define __DEBUG_WINCH_DATA__ |
sayzyas | 2:d0a5ee4e7bb8 | 39 | |
sayzyas | 2:d0a5ee4e7bb8 | 40 | |
sayzyas | 2:d0a5ee4e7bb8 | 41 | #ifdef __DEBUG_WINCH_DATA__ |
sayzyas | 2:d0a5ee4e7bb8 | 42 | #define DEBUG_PRINT_WINCH_DATA(...) pc.printf(__VA_ARGS__) |
sayzyas | 2:d0a5ee4e7bb8 | 43 | #else |
sayzyas | 2:d0a5ee4e7bb8 | 44 | #define DEBUG_PRINT_WINCH_DATA(...) |
sayzyas | 2:d0a5ee4e7bb8 | 45 | #endif |
sayzyas | 2:d0a5ee4e7bb8 | 46 | |
sayzyas | 2:d0a5ee4e7bb8 | 47 | #ifdef __DEBUG_PRINT_SW__ |
sayzyas | 2:d0a5ee4e7bb8 | 48 | #define DEBUG_PRINT_SW(...) pc.printf(__VA_ARGS__) |
sayzyas | 2:d0a5ee4e7bb8 | 49 | #else |
sayzyas | 2:d0a5ee4e7bb8 | 50 | #define DEBUG_PRINT_SW(...) |
sayzyas | 2:d0a5ee4e7bb8 | 51 | #endif |
sayzyas | 0:f4e2a62331ef | 52 | |
sayzyas | 0:f4e2a62331ef | 53 | #ifdef __DEBUG_L0__ |
sayzyas | 0:f4e2a62331ef | 54 | #define DEBUG_PRINT_L0(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:f4e2a62331ef | 55 | #else |
sayzyas | 0:f4e2a62331ef | 56 | #define DEBUG_PRINT_L0(...) |
sayzyas | 0:f4e2a62331ef | 57 | #endif |
sayzyas | 0:f4e2a62331ef | 58 | #ifdef __DEBUG_L1__ |
sayzyas | 0:f4e2a62331ef | 59 | #define DEBUG_PRINT_L1(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:f4e2a62331ef | 60 | #else |
sayzyas | 0:f4e2a62331ef | 61 | #define DEBUG_PRINT_L1(...) |
sayzyas | 0:f4e2a62331ef | 62 | #endif |
sayzyas | 0:f4e2a62331ef | 63 | #ifdef __DEBUG_L2__ |
sayzyas | 0:f4e2a62331ef | 64 | #define DEBUG_PRINT_L2(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:f4e2a62331ef | 65 | #else |
sayzyas | 0:f4e2a62331ef | 66 | #define DEBUG_PRINT_L2(...) |
sayzyas | 0:f4e2a62331ef | 67 | #endif |
sayzyas | 0:f4e2a62331ef | 68 | #ifdef __DEBUG_L3__ |
sayzyas | 0:f4e2a62331ef | 69 | #define DEBUG_PRINT_L3(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:f4e2a62331ef | 70 | #else |
sayzyas | 0:f4e2a62331ef | 71 | #define DEBUG_PRINT_L3(...) |
sayzyas | 0:f4e2a62331ef | 72 | #endif |
sayzyas | 0:f4e2a62331ef | 73 | #ifdef __DEBUG_L4__ |
sayzyas | 0:f4e2a62331ef | 74 | #define DEBUG_PRINT_L4(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:f4e2a62331ef | 75 | #else |
sayzyas | 0:f4e2a62331ef | 76 | #define DEBUG_PRINT_L4(...) |
sayzyas | 0:f4e2a62331ef | 77 | #endif |
sayzyas | 2:d0a5ee4e7bb8 | 78 | #ifdef __DEBUG_L5__ |
sayzyas | 2:d0a5ee4e7bb8 | 79 | #define DEBUG_PRINT_L5(...) pc.printf(__VA_ARGS__) |
sayzyas | 2:d0a5ee4e7bb8 | 80 | #else |
sayzyas | 2:d0a5ee4e7bb8 | 81 | #define DEBUG_PRINT_L5(...) |
sayzyas | 2:d0a5ee4e7bb8 | 82 | #endif |
sayzyas | 0:f4e2a62331ef | 83 | |
sayzyas | 2:d0a5ee4e7bb8 | 84 | /* ********************************************* */ |
sayzyas | 2:d0a5ee4e7bb8 | 85 | |
sayzyas | 2:d0a5ee4e7bb8 | 86 | // Motor Controller RoboCAN ID definition |
sayzyas | 2:d0a5ee4e7bb8 | 87 | #define MCTR_CANID_PANTILTWCH 2 // Pan/Tilt or Winch motor's ID |
sayzyas | 2:d0a5ee4e7bb8 | 88 | #define MCTR_CANID_TFM 3 // Trabsform motor's ID |
sayzyas | 2:d0a5ee4e7bb8 | 89 | #define MCTR_CANID_CRW 1 // Crawler motor's ID |
sayzyas | 2:d0a5ee4e7bb8 | 90 | |
sayzyas | 2:d0a5ee4e7bb8 | 91 | #define NUMBER_OF_MCCMD 7 |
sayzyas | 2:d0a5ee4e7bb8 | 92 | #define WINCH_OFFSET_VALUE 20 |
sayzyas | 2:d0a5ee4e7bb8 | 93 | |
sayzyas | 2:d0a5ee4e7bb8 | 94 | /* |
sayzyas | 2:d0a5ee4e7bb8 | 95 | B1/B2 demo machine controller control command list |
sayzyas | 2:d0a5ee4e7bb8 | 96 | */ |
sayzyas | 2:d0a5ee4e7bb8 | 97 | enum{ |
sayzyas | 2:d0a5ee4e7bb8 | 98 | XX_WICH, // Winch |
sayzyas | 2:d0a5ee4e7bb8 | 99 | XX_CLRF, // R Crawler |
sayzyas | 2:d0a5ee4e7bb8 | 100 | XX_CLLB, // L Crawler |
sayzyas | 2:d0a5ee4e7bb8 | 101 | XX_TFRF, // R Transform |
sayzyas | 2:d0a5ee4e7bb8 | 102 | XX_TFLB, // R Transform |
sayzyas | 2:d0a5ee4e7bb8 | 103 | ZTRF_I_1, // RF-I Transform ON |
sayzyas | 2:d0a5ee4e7bb8 | 104 | ZTRF_I_0, // RF-I Transform OFF |
sayzyas | 2:d0a5ee4e7bb8 | 105 | ZTRF_K_1, // RF-K Transform ON |
sayzyas | 2:d0a5ee4e7bb8 | 106 | ZTRF_K_0, // RF-K Transform OFF |
sayzyas | 2:d0a5ee4e7bb8 | 107 | ZTLB_I_1, // LB-I Transform ON |
sayzyas | 2:d0a5ee4e7bb8 | 108 | ZTLB_I_0, // LB-I Transform OFF |
sayzyas | 2:d0a5ee4e7bb8 | 109 | ZTLB_K_1, // LB-K Transform ON |
sayzyas | 2:d0a5ee4e7bb8 | 110 | ZTLB_K_0, // LB-K Transform OFF |
sayzyas | 2:d0a5ee4e7bb8 | 111 | ZCP_FW_1, // Camera PAN Forward ON |
sayzyas | 2:d0a5ee4e7bb8 | 112 | ZCP_FW_0, // Camera PAN Forward OFF |
sayzyas | 2:d0a5ee4e7bb8 | 113 | ZCP_RS_1, // Camera PAN Reverse ON |
sayzyas | 2:d0a5ee4e7bb8 | 114 | ZCP_RS_0, // Camera PAN Reverse OFF |
sayzyas | 2:d0a5ee4e7bb8 | 115 | ZCT_FW_1, // Camera TILT Forward ON |
sayzyas | 2:d0a5ee4e7bb8 | 116 | ZCT_FW_0, // Camera TILT Forward OFF |
sayzyas | 2:d0a5ee4e7bb8 | 117 | ZCT_RS_1, // Camera TILT Reverse ON |
sayzyas | 2:d0a5ee4e7bb8 | 118 | ZCT_RS_0, // Camera TILT Reverse OFF |
sayzyas | 2:d0a5ee4e7bb8 | 119 | ZESHAPE_I, // Shape I : Switch ON |
sayzyas | 2:d0a5ee4e7bb8 | 120 | ZESHAPE_K, // Shape K : Switch OFF |
sayzyas | 2:d0a5ee4e7bb8 | 121 | ZTFCWP_VD, // TFM,CRW Part valid : Switch ON |
sayzyas | 2:d0a5ee4e7bb8 | 122 | ZWICHP_VD // Winch Part valid : Switch OFF |
sayzyas | 2:d0a5ee4e7bb8 | 123 | }; |
sayzyas | 2:d0a5ee4e7bb8 | 124 | |
sayzyas | 2:d0a5ee4e7bb8 | 125 | |
sayzyas | 2:d0a5ee4e7bb8 | 126 | enum{ |
sayzyas | 2:d0a5ee4e7bb8 | 127 | MOTOR_NO0, |
sayzyas | 2:d0a5ee4e7bb8 | 128 | MOTOR_NO1, |
sayzyas | 2:d0a5ee4e7bb8 | 129 | MOTOR_NO2, |
sayzyas | 2:d0a5ee4e7bb8 | 130 | MOTOR_NO3 |
sayzyas | 2:d0a5ee4e7bb8 | 131 | }; |
sayzyas | 2:d0a5ee4e7bb8 | 132 | |
sayzyas | 2:d0a5ee4e7bb8 | 133 | enum{ |
sayzyas | 2:d0a5ee4e7bb8 | 134 | MOTOR_FORWARD, |
sayzyas | 2:d0a5ee4e7bb8 | 135 | MOTOR_REVERSE, |
sayzyas | 2:d0a5ee4e7bb8 | 136 | MOTOR_STOP |
sayzyas | 2:d0a5ee4e7bb8 | 137 | }; |
sayzyas | 2:d0a5ee4e7bb8 | 138 | |
sayzyas | 2:d0a5ee4e7bb8 | 139 | #define MC_LOCK_COUNT 5 |
sayzyas | 2:d0a5ee4e7bb8 | 140 | |
sayzyas | 2:d0a5ee4e7bb8 | 141 | /* ********************************************* */ |
sayzyas | 2:d0a5ee4e7bb8 | 142 | |
sayzyas | 2:d0a5ee4e7bb8 | 143 | #define MOTOR_1 '1' |
sayzyas | 2:d0a5ee4e7bb8 | 144 | #define MOTOR_2 '2' |
sayzyas | 2:d0a5ee4e7bb8 | 145 | |
sayzyas | 2:d0a5ee4e7bb8 | 146 | #define MOTOR_ |
sayzyas | 2:d0a5ee4e7bb8 | 147 | |
sayzyas | 2:d0a5ee4e7bb8 | 148 | /* Above is still under construction ..... */ |
sayzyas | 2:d0a5ee4e7bb8 | 149 | |
sayzyas | 2:d0a5ee4e7bb8 | 150 | #define __DISP_GAMAPAD_STATUS_ALL__ |
sayzyas | 2:d0a5ee4e7bb8 | 151 | #define __DISP_WRITE_VALUE__ |
sayzyas | 2:d0a5ee4e7bb8 | 152 | |
sayzyas | 2:d0a5ee4e7bb8 | 153 | #define I2C_ADDRESS_HANDY 0x20 |
sayzyas | 2:d0a5ee4e7bb8 | 154 | #define I2C_ADDRESS_WINCH 0x10 |
sayzyas | 2:d0a5ee4e7bb8 | 155 | #define I2C_ADDRESS_TRANSFORM 0x08 |
sayzyas | 2:d0a5ee4e7bb8 | 156 | #define I2C_ADDRESS_CRAWLER 0x04 |
sayzyas | 2:d0a5ee4e7bb8 | 157 | #define I2C_ADDRESS_RESOLVER 0x02 |
sayzyas | 2:d0a5ee4e7bb8 | 158 | |
sayzyas | 2:d0a5ee4e7bb8 | 159 | |
sayzyas | 2:d0a5ee4e7bb8 | 160 | #define _OK_ 1 |
sayzyas | 2:d0a5ee4e7bb8 | 161 | #define _NG_ 0 |
sayzyas | 2:d0a5ee4e7bb8 | 162 | #define _FAIL_ 0 |
sayzyas | 2:d0a5ee4e7bb8 | 163 | |
sayzyas | 2:d0a5ee4e7bb8 | 164 | #define ON 1 |
sayzyas | 2:d0a5ee4e7bb8 | 165 | #define OFF 0 |
sayzyas | 2:d0a5ee4e7bb8 | 166 | |
sayzyas | 2:d0a5ee4e7bb8 | 167 | #define LFS_READ_COUNT 3 |
sayzyas | 2:d0a5ee4e7bb8 | 168 | #define TARGET_CHECK_COUNT 10 |
sayzyas | 2:d0a5ee4e7bb8 | 169 | |
sayzyas | 2:d0a5ee4e7bb8 | 170 | //#define __DSP_MOTOR_CURRENT_ |
sayzyas | 2:d0a5ee4e7bb8 | 171 | |
sayzyas | 2:d0a5ee4e7bb8 | 172 | /* Usually this should be comment out */ |
sayzyas | 2:d0a5ee4e7bb8 | 173 | //#define _COMMUNCATE_PC_BY_SERIAL_ |
sayzyas | 2:d0a5ee4e7bb8 | 174 | |
sayzyas | 2:d0a5ee4e7bb8 | 175 | // Should validate this definition when you use DHCP. |
sayzyas | 2:d0a5ee4e7bb8 | 176 | //#define __ETERNET_DHCP__ |
sayzyas | 2:d0a5ee4e7bb8 | 177 | |
sayzyas | 2:d0a5ee4e7bb8 | 178 | #define NumberOfPcCommand 11 |
sayzyas | 2:d0a5ee4e7bb8 | 179 | #define NumberOfI2CCommand 14 |
sayzyas | 2:d0a5ee4e7bb8 | 180 | |
sayzyas | 2:d0a5ee4e7bb8 | 181 | /* I2C Command packet to motor controller */ |
sayzyas | 2:d0a5ee4e7bb8 | 182 | /* For motor controller */ |
sayzyas | 2:d0a5ee4e7bb8 | 183 | enum{ |
sayzyas | 2:d0a5ee4e7bb8 | 184 | I2C_CP_PREAMBLE, // Preamble of command packet |
sayzyas | 2:d0a5ee4e7bb8 | 185 | I2C_CP_COMMAND, // instruction command |
sayzyas | 2:d0a5ee4e7bb8 | 186 | I2C_CP_M1_DIR, // motor1 rotation direction |
sayzyas | 2:d0a5ee4e7bb8 | 187 | I2C_CP_M1_SPEED, // motor1 rotation speed |
sayzyas | 2:d0a5ee4e7bb8 | 188 | I2C_CP_M1_FWD_CNTTH_U, // motor1 current limit detection threshold upper byte |
sayzyas | 2:d0a5ee4e7bb8 | 189 | I2C_CP_M1_FWD_CNTTH_L, // motor1 current limit detection threshold lower byte |
sayzyas | 2:d0a5ee4e7bb8 | 190 | I2C_CP_M1_RVS_CNTTH_U, // motor1 current limit detection threshold upper byte |
sayzyas | 2:d0a5ee4e7bb8 | 191 | I2C_CP_M1_RVS_CNTTH_L, // motor1 current limit detection threshold lower byte |
sayzyas | 2:d0a5ee4e7bb8 | 192 | I2C_CP_M2_DIR, // motor2 rotation direction |
sayzyas | 2:d0a5ee4e7bb8 | 193 | I2C_CP_M2_SPEED, // motor2 rotation speed |
sayzyas | 2:d0a5ee4e7bb8 | 194 | I2C_CP_M2_FWD_CNTTH_U, // motor2 current limit detection threshold upper byte |
sayzyas | 2:d0a5ee4e7bb8 | 195 | I2C_CP_M2_FWD_CNTTH_L, // motor2 current limit detection threshold lower byte |
sayzyas | 2:d0a5ee4e7bb8 | 196 | I2C_CP_M2_RVS_CNTTH_U, // motor2 current limit detection threshold upper byte |
sayzyas | 2:d0a5ee4e7bb8 | 197 | I2C_CP_M2_RVS_CNTTH_L, // motor2 current limit detection threshold lower byte |
sayzyas | 2:d0a5ee4e7bb8 | 198 | }; |
sayzyas | 2:d0a5ee4e7bb8 | 199 | /* For resolver reader controller */ |
sayzyas | 2:d0a5ee4e7bb8 | 200 | enum{ |
sayzyas | 2:d0a5ee4e7bb8 | 201 | I2C_CP_PREAMBLE_R, // Preamble of command packet |
sayzyas | 2:d0a5ee4e7bb8 | 202 | I2C_CP_COMMAND_R, // instruction command |
sayzyas | 2:d0a5ee4e7bb8 | 203 | I2C_CP_WDRAM_DIA_UPPER, // motor1 rotation direction |
sayzyas | 2:d0a5ee4e7bb8 | 204 | I2C_CP_WDRAM_DIA_LOWER, // motor1 rotation speed |
sayzyas | 2:d0a5ee4e7bb8 | 205 | I2C_CP_CCABLE_DIA_UPPER, // motor1 current limit detection threshold upper byte |
sayzyas | 2:d0a5ee4e7bb8 | 206 | I2C_CP_CCABLE_DIA_LOWER, // motor1 current limit detection threshold lower byte |
sayzyas | 2:d0a5ee4e7bb8 | 207 | I2C_CP_RESOLVER_RESO, // motor1 current limit detection threshold upper byte |
sayzyas | 2:d0a5ee4e7bb8 | 208 | I2C_CP_PRESET_CPOS_UPPER, // reserved |
sayzyas | 2:d0a5ee4e7bb8 | 209 | I2C_CP_PRESET_CPOS_LOWER, // reserved |
sayzyas | 2:d0a5ee4e7bb8 | 210 | I2C_CP_RES3, // reserved |
sayzyas | 2:d0a5ee4e7bb8 | 211 | I2C_CP_RES4, // reserved |
sayzyas | 2:d0a5ee4e7bb8 | 212 | I2C_CP_RES5, // reserved |
sayzyas | 2:d0a5ee4e7bb8 | 213 | I2C_CP_RES6, // reserved |
sayzyas | 2:d0a5ee4e7bb8 | 214 | I2C_CP_RES7, // reserved |
sayzyas | 2:d0a5ee4e7bb8 | 215 | }; |
sayzyas | 0:f4e2a62331ef | 216 | |
sayzyas | 2:d0a5ee4e7bb8 | 217 | /* Winch Operating mode */ |
sayzyas | 2:d0a5ee4e7bb8 | 218 | enum{ |
sayzyas | 2:d0a5ee4e7bb8 | 219 | WINCH_POSITION_CLEAR, |
sayzyas | 2:d0a5ee4e7bb8 | 220 | WINCH_PRESET_BASEDATA, |
sayzyas | 2:d0a5ee4e7bb8 | 221 | WINCH_MMODE_RELATIVE, |
sayzyas | 2:d0a5ee4e7bb8 | 222 | WINCH_MMODE_ABSOLUTE, |
sayzyas | 2:d0a5ee4e7bb8 | 223 | WINCH_STEPDOWN_BTN_ON, |
sayzyas | 2:d0a5ee4e7bb8 | 224 | WINCH_STEPDOWN_BTN_OFF, |
sayzyas | 2:d0a5ee4e7bb8 | 225 | WINCH_STEPUP_BTN_ON, |
sayzyas | 2:d0a5ee4e7bb8 | 226 | WINCH_STEPUP_BTN_OFF, |
sayzyas | 2:d0a5ee4e7bb8 | 227 | WINCH_U_STEPDOWN_BTN_ON, |
sayzyas | 2:d0a5ee4e7bb8 | 228 | WINCH_U_STEPDOWN_BTN_OFF, |
sayzyas | 2:d0a5ee4e7bb8 | 229 | WINCH_U_STEPUP_BTN_ON, |
sayzyas | 2:d0a5ee4e7bb8 | 230 | WINCH_U_STEPUP_BTN_OFF, |
sayzyas | 2:d0a5ee4e7bb8 | 231 | WINCH_PRESET_POSITION, |
sayzyas | 2:d0a5ee4e7bb8 | 232 | }; |
sayzyas | 2:d0a5ee4e7bb8 | 233 | |
sayzyas | 2:d0a5ee4e7bb8 | 234 | /* Ether net */ |
sayzyas | 2:d0a5ee4e7bb8 | 235 | #define TCP_PCCSERVER_PORT 10004 |
sayzyas | 2:d0a5ee4e7bb8 | 236 | #define TCP_CMDSERVER_PORT 10002 |
sayzyas | 2:d0a5ee4e7bb8 | 237 | #define UDP_SERVER_PORT 10000 |
sayzyas | 2:d0a5ee4e7bb8 | 238 | |
sayzyas | 2:d0a5ee4e7bb8 | 239 | #define MOTOR_FWD 'F' /* Forward Rotation */ |
sayzyas | 2:d0a5ee4e7bb8 | 240 | #define MOTOR_RVS 'R' /* Reverse Rotation */ |
sayzyas | 2:d0a5ee4e7bb8 | 241 | #define MOTOR_STP 'S' /* Stop */ |
sayzyas | 0:f4e2a62331ef | 242 | |
sayzyas | 2:d0a5ee4e7bb8 | 243 | // ========================================================= |
sayzyas | 2:d0a5ee4e7bb8 | 244 | // Setting Values |
sayzyas | 2:d0a5ee4e7bb8 | 245 | // ========================================================= |
sayzyas | 2:d0a5ee4e7bb8 | 246 | typedef struct { |
sayzyas | 2:d0a5ee4e7bb8 | 247 | int8_t sv_JS_ShapeMode; // JS Shape: 0=I, 1=KO |
sayzyas | 2:d0a5ee4e7bb8 | 248 | int8_t sv_JS_OpeMode; // JS Operation: 0=single, 1=dual |
sayzyas | 2:d0a5ee4e7bb8 | 249 | int8_t sv_WinchValid; // Winch function valid or not: 0=Tfm, Crawler valid, 1=Winch valid |
sayzyas | 2:d0a5ee4e7bb8 | 250 | int8_t res; |
sayzyas | 2:d0a5ee4e7bb8 | 251 | } basic_operation_t; |
sayzyas | 2:d0a5ee4e7bb8 | 252 | |
sayzyas | 2:d0a5ee4e7bb8 | 253 | |
sayzyas | 2:d0a5ee4e7bb8 | 254 | |
sayzyas | 2:d0a5ee4e7bb8 | 255 | |
sayzyas | 2:d0a5ee4e7bb8 | 256 | typedef struct { |
sayzyas | 2:d0a5ee4e7bb8 | 257 | uint16_t drm_mtr_ithd_f; // 2 Current threshold winch dram Motor ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 258 | uint16_t drm_mtr_ithd_r; // 2 Current threshold winch dram Motor ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 259 | uint16_t tmp_mtr_ithd_f; // 2 Current threshold winch No2 Motor ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 260 | uint16_t tmp_mtr_ithd_r; // 2 Current threshold winch No2 Motor ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 261 | uint8_t drm_mtr_hspd_f; // 1 Motor speed winch dram motor high speed ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 262 | uint8_t drm_mtr_hspd_r; // 1 Motor speed winch dram motor high speed ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 263 | uint8_t drm_mtr_lspd_f; // 1 Motor speed winch dram motor low speed ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 264 | uint8_t drm_mtr_lspd_r; // 1 Motor speed winch dram motor low speed ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 265 | uint8_t tmp_mtr_hspd_f; // 1 Motor speed winch No2 motor high speed ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 266 | uint8_t tmp_mtr_hspd_r; // 1 Motor speed winch No2 motor high speed ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 267 | uint8_t tmp_mtr_lspd_f; // 1 Motor speed winch No2 motor low speed ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 268 | uint8_t tmp_mtr_lspd_r; // 1 Motor speed winch No2 motor low speed ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 269 | uint16_t dram_dmtr_x100; // 2 Winch dram diameter x 100 |
sayzyas | 2:d0a5ee4e7bb8 | 270 | uint16_t adj_val_x10000; // 2 Winch adjust value x 100 |
sayzyas | 2:d0a5ee4e7bb8 | 271 | uint8_t res_resolution; // 1 Winch resolver resolution (bit) |
sayzyas | 2:d0a5ee4e7bb8 | 272 | uint8_t reserved_1; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 273 | uint8_t reserved_2; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 274 | uint8_t reserved_3; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 275 | } winch_SetValue_t; // << 24 byte >> |
sayzyas | 0:f4e2a62331ef | 276 | |
sayzyas | 2:d0a5ee4e7bb8 | 277 | typedef struct { |
sayzyas | 2:d0a5ee4e7bb8 | 278 | uint16_t rf_mtr_ithd_f; // 2 Current threshold RF motor ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 279 | uint16_t rf_mtr_ithd_r; // 2 Current threshold RF motor ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 280 | uint16_t lb_mtr_ithd_f; // 2 Current threshold LB motor ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 281 | uint16_t lb_mtr_ithd_r; // 2 Current threshold LB motor ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 282 | uint8_t rf_mtr_hspd_f; // 1 Motor speed RF ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 283 | uint8_t rf_mtr_hspd_r; // 1 Motor speed RF ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 284 | uint8_t lb_mtr_hspd_f; // 1 Motor speed LB ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 285 | uint8_t lb_mtr_hspd_r; // 1 Motor speed LB ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 286 | uint8_t reserved_1; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 287 | uint8_t reserved_2; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 288 | uint8_t reserved_3; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 289 | uint8_t reserved_4; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 290 | } tfm_SetValue_t; // << 16 byte >> |
sayzyas | 2:d0a5ee4e7bb8 | 291 | |
sayzyas | 2:d0a5ee4e7bb8 | 292 | typedef struct { |
sayzyas | 2:d0a5ee4e7bb8 | 293 | uint16_t rf_mtr_ithd_f; // 2 Current threshold RF motor ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 294 | uint16_t rf_mtr_ithd_r; // 2 Current threshold RF motor ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 295 | uint16_t lb_mtr_ithd_f; // 2 Current threshold LB motor ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 296 | uint16_t lb_mtr_ithd_r; // 2 Current threshold LB motor ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 297 | uint8_t rf_mtr_hspd_f; // 1 Motor speed RF ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 298 | uint8_t rf_mtr_hspd_r; // 1 Motor speed RF ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 299 | uint8_t lb_mtr_hspd_f; // 1 Motor speed LB ( forward ) |
sayzyas | 2:d0a5ee4e7bb8 | 300 | uint8_t lb_mtr_hspd_r; // 1 Motor speed LB ( reverse ) |
sayzyas | 2:d0a5ee4e7bb8 | 301 | uint8_t reserved_1; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 302 | uint8_t reserved_2; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 303 | uint8_t reserved_3; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 304 | uint8_t reserved_4; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 305 | } crawler_SetValue_t; // << 16 byte >> |
sayzyas | 0:f4e2a62331ef | 306 | |
sayzyas | 2:d0a5ee4e7bb8 | 307 | typedef struct { |
sayzyas | 2:d0a5ee4e7bb8 | 308 | uint8_t rjs_centervalue; // 1 R JoyStick center value |
sayzyas | 2:d0a5ee4e7bb8 | 309 | uint8_t rjs_u_dead_zone; // 1 R Joystick upper dead zone width |
sayzyas | 2:d0a5ee4e7bb8 | 310 | uint8_t rjs_l_dead_zone; // 1 R Joystick lower dead zone width |
sayzyas | 2:d0a5ee4e7bb8 | 311 | uint8_t ljs_centervalue; // 1 L JoyStick center value |
sayzyas | 2:d0a5ee4e7bb8 | 312 | uint8_t ljs_u_dead_zone; // 1 L Joystick upper dead zone width |
sayzyas | 2:d0a5ee4e7bb8 | 313 | uint8_t ljs_l_dead_zone; // 1 L Joystick lower dead zone width |
sayzyas | 2:d0a5ee4e7bb8 | 314 | uint8_t reserved_1; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 315 | uint8_t reserved_2; // 1 reserved for future use |
sayzyas | 2:d0a5ee4e7bb8 | 316 | } js_SetValue_t; // << 8 byte >> |
sayzyas | 2:d0a5ee4e7bb8 | 317 | |
sayzyas | 2:d0a5ee4e7bb8 | 318 | typedef struct SetValue { |
sayzyas | 2:d0a5ee4e7bb8 | 319 | winch_SetValue_t winchCtrl; |
sayzyas | 2:d0a5ee4e7bb8 | 320 | tfm_SetValue_t tfmCtrl; |
sayzyas | 2:d0a5ee4e7bb8 | 321 | crawler_SetValue_t crawlerCtrl; |
sayzyas | 2:d0a5ee4e7bb8 | 322 | js_SetValue_t jsCtrl; |
sayzyas | 2:d0a5ee4e7bb8 | 323 | } setValue_t; |
sayzyas | 2:d0a5ee4e7bb8 | 324 | |
sayzyas | 2:d0a5ee4e7bb8 | 325 | |
sayzyas | 2:d0a5ee4e7bb8 | 326 | |
sayzyas | 0:f4e2a62331ef | 327 | |
sayzyas | 2:d0a5ee4e7bb8 | 328 | #define SLOWDOWN_DISTANCE 23 // <--10 2016.06.01 |
sayzyas | 2:d0a5ee4e7bb8 | 329 | #define SLOWDOWN_NEAR_DISTANCE 3 |
sayzyas | 2:d0a5ee4e7bb8 | 330 | /* |
sayzyas | 2:d0a5ee4e7bb8 | 331 | typedef struct { |
sayzyas | 2:d0a5ee4e7bb8 | 332 | int16_t dt_WinchCntPosition; // Current winch posittion |
sayzyas | 2:d0a5ee4e7bb8 | 333 | int16_t dt_WinchRtvValue; // Winch Moving distance |
sayzyas | 2:d0a5ee4e7bb8 | 334 | int16_t dt_WinchDstPosition; // Destination Position |
sayzyas | 2:d0a5ee4e7bb8 | 335 | char operation; |
sayzyas | 2:d0a5ee4e7bb8 | 336 | int8_t dt_WinchMotorCurrent; // Winch motor current |
sayzyas | 2:d0a5ee4e7bb8 | 337 | } winchData_t; |
sayzyas | 2:d0a5ee4e7bb8 | 338 | */ |
sayzyas | 2:d0a5ee4e7bb8 | 339 | |
sayzyas | 2:d0a5ee4e7bb8 | 340 | typedef struct { |
sayzyas | 2:d0a5ee4e7bb8 | 341 | int16_t dt_WinchCntPosition; // Current winch posittion |
sayzyas | 2:d0a5ee4e7bb8 | 342 | int16_t dt_WinchRtvValue; // Winch Moving distance |
sayzyas | 2:d0a5ee4e7bb8 | 343 | int16_t dt_WinchDstPosition; // Destination Position |
sayzyas | 2:d0a5ee4e7bb8 | 344 | uint8_t operation; |
sayzyas | 2:d0a5ee4e7bb8 | 345 | uint8_t dt_WinchMotor1Current; // Winch motor 1 current |
sayzyas | 2:d0a5ee4e7bb8 | 346 | uint8_t dt_WinchMotor2Current; // Winch motor 2 current |
sayzyas | 2:d0a5ee4e7bb8 | 347 | uint8_t res; |
sayzyas | 2:d0a5ee4e7bb8 | 348 | } winchData_t; |
sayzyas | 2:d0a5ee4e7bb8 | 349 | |
sayzyas | 2:d0a5ee4e7bb8 | 350 | |
sayzyas | 2:d0a5ee4e7bb8 | 351 | #define ROTATE_PER_RESOLUTION 24 |
sayzyas | 2:d0a5ee4e7bb8 | 352 | |
sayzyas | 2:d0a5ee4e7bb8 | 353 | #define __READ_CURRENT_AT_CIF_TASK__ |
sayzyas | 2:d0a5ee4e7bb8 | 354 | |
sayzyas | 2:d0a5ee4e7bb8 | 355 | //mv_WinchMvData |