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: EthernetInterface TextLCD USBDevice USBHost2 mbed
common.h
00001 /* 00002 DEBUG PRINT MACRO 00003 http://qiita.com/saltheads/items/e1b0ab54d3d6029c9593 00004 http://tricky-code.net/nicecode/code10.php 00005 */ 00006 /* Information */ 00007 #define LatestUpDate "2016.11.04" 00008 #define ProgramRevision "Rev 2.40" 00009 #define Author "ZisNotRevast" 00010 #define Company "Revast Co.,Ltd." 00011 00012 //#define __CREATE_SETTING_FILE__ 00013 //#define __TARGET_BOARD_CHECK__ 00014 00015 00016 //#define __WInchDebug__ // For debugging 00017 00018 00019 // Comment out if net setting is FIX. 00020 // #define __NET_SETTING_FROM_LFS__ 00021 00022 00023 // Read motor current 00024 #define __READ_TFM_MOTOR_CURRENT__ 00025 00026 #define __IIC_COMAMND_SEND__ 00027 00028 #define __SET_WINCH_MOTOR_SPEED_BY_VOLUME__ 00029 00030 // ====================================================================== 00031 // For Debugging 00032 // ====================================================================== 00033 #define __DEBUG_PRINT_SW__ // Display SW Status to console 00034 //#define __DEBUG_L0__ 00035 //#define __DEBUG_L1__ 00036 //#define __DEBUG_L2__ 00037 //#define __DEBUG_L3__ 00038 //#define __DEBUG_L4__ 00039 #define __DEBUG_L5__ 00040 00041 #define __DEBUG_WINCH_DATA__ 00042 00043 00044 #ifdef __DEBUG_WINCH_DATA__ 00045 #define DEBUG_PRINT_WINCH_DATA(...) pc.printf(__VA_ARGS__) 00046 #else 00047 #define DEBUG_PRINT_WINCH_DATA(...) 00048 #endif 00049 00050 #ifdef __DEBUG_PRINT_SW__ 00051 #define DEBUG_PRINT_SW(...) pc.printf(__VA_ARGS__) 00052 #else 00053 #define DEBUG_PRINT_SW(...) 00054 #endif 00055 00056 #ifdef __DEBUG_L0__ 00057 #define DEBUG_PRINT_L0(...) pc.printf(__VA_ARGS__) 00058 #else 00059 #define DEBUG_PRINT_L0(...) 00060 #endif 00061 #ifdef __DEBUG_L1__ 00062 #define DEBUG_PRINT_L1(...) pc.printf(__VA_ARGS__) 00063 #else 00064 #define DEBUG_PRINT_L1(...) 00065 #endif 00066 #ifdef __DEBUG_L2__ 00067 #define DEBUG_PRINT_L2(...) pc.printf(__VA_ARGS__) 00068 #else 00069 #define DEBUG_PRINT_L2(...) 00070 #endif 00071 #ifdef __DEBUG_L3__ 00072 #define DEBUG_PRINT_L3(...) pc.printf(__VA_ARGS__) 00073 #else 00074 #define DEBUG_PRINT_L3(...) 00075 #endif 00076 #ifdef __DEBUG_L4__ 00077 #define DEBUG_PRINT_L4(...) pc.printf(__VA_ARGS__) 00078 #else 00079 #define DEBUG_PRINT_L4(...) 00080 #endif 00081 #ifdef __DEBUG_L5__ 00082 #define DEBUG_PRINT_L5(...) pc.printf(__VA_ARGS__) 00083 #else 00084 #define DEBUG_PRINT_L5(...) 00085 #endif 00086 00087 // Motor Controller RoboCAN ID definition 00088 #define MCTR_CANID_PANTILTWCH 2 // Pan/Tilt or Winch motor's ID 00089 #define MCTR_CANID_TFM 3 // Trabsform motor's ID 00090 #define MCTR_CANID_CRW 1 // Crawler motor's ID 00091 00092 #define NUMBER_OF_MCCMD 7 00093 #define WINCH_OFFSET_VALUE 20 00094 00095 #define LED_IND_BLINK_PERIOD 15 00096 #define LED_IND_BLINK_PERIOD2 2 00097 #define LED_IND_BLINK_PERIOD8 18 00098 00099 /* 00100 B1/B2 demo machine controller control command list 00101 */ 00102 enum{ 00103 XX_WICH, // Winch 00104 XX_CLRF, // R Crawler 00105 XX_CLLB, // L Crawler 00106 XX_TFRF, // R Transform 00107 XX_TFLB, // R Transform 00108 ZTRF_I_1, // RF-I Transform ON 00109 ZTRF_I_0, // RF-I Transform OFF 00110 ZTRF_K_1, // RF-K Transform ON 00111 ZTRF_K_0, // RF-K Transform OFF 00112 ZTLB_I_1, // LB-I Transform ON 00113 ZTLB_I_0, // LB-I Transform OFF 00114 ZTLB_K_1, // LB-K Transform ON 00115 ZTLB_K_0, // LB-K Transform OFF 00116 ZCP_FW_1, // Camera PAN Forward ON 00117 ZCP_FW_0, // Camera PAN Forward OFF 00118 ZCP_RS_1, // Camera PAN Reverse ON 00119 ZCP_RS_0, // Camera PAN Reverse OFF 00120 ZCT_FW_1, // Camera TILT Forward ON 00121 ZCT_FW_0, // Camera TILT Forward OFF 00122 ZCT_RS_1, // Camera TILT Reverse ON 00123 ZCT_RS_0, // Camera TILT Reverse OFF 00124 ZESHAPE_I, // Shape I : Switch ON 00125 ZESHAPE_K, // Shape K : Switch OFF 00126 ZTFCWP_VD, // TFM,CRW Part valid : Switch ON 00127 ZWICHP_VD // Winch Part valid : Switch OFF 00128 }; 00129 00130 00131 enum{ 00132 MOTOR_NO0, 00133 MOTOR_NO1, 00134 MOTOR_NO2, 00135 MOTOR_NO3 00136 }; 00137 00138 enum{ 00139 MOTOR_FORWARD, 00140 MOTOR_REVERSE, 00141 MOTOR_STOP 00142 }; 00143 00144 #define MC_LOCK_COUNT 5 00145 00146 #define DEAD_ZONE_BAND_WIDTH 10 00147 #define CALIBRATION_COUNT 300 00148 00149 /* ********************************************* */ 00150 00151 #define MOTOR_1 '1' 00152 #define MOTOR_2 '2' 00153 00154 #define MOTOR_ 00155 00156 /* Above is still under construction ..... */ 00157 00158 #define __DISP_GAMAPAD_STATUS_ALL__ 00159 #define __DISP_WRITE_VALUE__ 00160 00161 #define I2C_ADDRESS_HANDY 0x20 00162 #define I2C_ADDRESS_WINCH 0x10 00163 #define I2C_ADDRESS_TRANSFORM 0x08 00164 #define I2C_ADDRESS_CRAWLER 0x04 00165 #define I2C_ADDRESS_RESOLVER 0x02 00166 00167 00168 #define _OK_ 1 00169 #define _NG_ 0 00170 #define _FAIL_ 0 00171 00172 #define ON 1 00173 #define OFF 0 00174 00175 #define LFS_READ_COUNT 3 00176 #define TARGET_CHECK_COUNT 10 00177 00178 //#define __DSP_MOTOR_CURRENT_ 00179 00180 /* Usually this should be comment out */ 00181 //#define _COMMUNCATE_PC_BY_SERIAL_ 00182 00183 // Should validate this definition when you use DHCP. 00184 //#define __ETERNET_DHCP__ 00185 00186 #define NumberOfPcCommand 11 00187 #define NumberOfI2CCommand 14 00188 00189 /* Winch Operating mode */ 00190 enum{ 00191 WINCH_POSITION_CLEAR, 00192 WINCH_PRESET_BASEDATA, 00193 WINCH_MMODE_RELATIVE, 00194 WINCH_MMODE_ABSOLUTE, 00195 WINCH_STEPDOWN_BTN_ON, 00196 WINCH_STEPDOWN_BTN_OFF, 00197 WINCH_STEPUP_BTN_ON, 00198 WINCH_STEPUP_BTN_OFF, 00199 WINCH_U_STEPDOWN_BTN_ON, 00200 WINCH_U_STEPDOWN_BTN_OFF, 00201 WINCH_U_STEPUP_BTN_ON, 00202 WINCH_U_STEPUP_BTN_OFF, 00203 WINCH_PRESET_POSITION, 00204 }; 00205 00206 /* Game Pad defnition */ 00207 #define GAMEPAD_VID_LOGICOOL 0x046d 00208 #define GAMEPAD_PID_LOGICOOL_F710 0xc219 00209 #define GAMEPAD_PID_LOGICOOL_F310 0xc216 00210 00211 #define GAMEPAD_VID_SANWA 0x12bd 00212 #define GAMEPAD_PID_SANWA_JYP70US 0xc003 00213 00214 #define GAMEPAD_VID_ELECOM 0x056e 00215 #define GAMEPAD_PID_ELECOM_JCU3613M 0x2003 00216 00217 #define GAMEPAD_VID_RSTHANDY 0x1234 00218 #define GAMEPAD_PID_RSTHANDY 0x0006 00219 00220 00221 /* Ether net */ 00222 #define TCP_SERVER_PORT 10002 00223 #define UDP_SERVER_PORT 10000 00224 //#define ECHO_SERVER_PORT 7 00225 00226 #define MOTOR_FWD 'F' /* Forward Rotation */ 00227 #define MOTOR_RVS 'R' /* Reverse Rotation */ 00228 #define MOTOR_STP 'S' /* Stop */ 00229 00230 // ========================================================= 00231 // Setting Values 00232 // ========================================================= 00233 typedef struct { 00234 int8_t sv_JS_ShapeMode; // JS Shape: 0=I, 1=KO 00235 int8_t sv_JS_OpeMode; // JS Operation: 0=single, 1=dual 00236 int8_t sv_WinchValid; // Winch function valid or not: 0=Tfm, Crawler valid, 1=Winch valid 00237 int8_t res; 00238 } basic_operation_t; 00239 00240 typedef struct { 00241 uint8_t rjs_upper_dzone; // 1 R Joystick upper dead zone width 00242 uint8_t rjs_lower_dzone; // 1 R Joystick lower dead zone width 00243 uint8_t rjs_right_dzone; // 1 R Joystick lower dead zone width 00244 uint8_t rjs_left_dzone; // 1 R Joystick lower dead zone width 00245 uint8_t reserved_1; // 1 reserved for future use 00246 uint8_t reserved_2; // 1 reserved for future use 00247 uint8_t reserved_3; // 1 reserved for future use 00248 uint8_t reserved_4; // 1 reserved for future use 00249 } js_SetValue_t; 00250 00251 typedef struct SetValue { 00252 js_SetValue_t jsCtrl; 00253 } setValue_t; 00254 00255 00256 00257 00258 #define SLOWDOWN_DISTANCE 23 // <--10 2016.06.01 00259 #define SLOWDOWN_NEAR_DISTANCE 3 00260 /* 00261 typedef struct { 00262 int16_t dt_WinchCntPosition; // Current winch posittion 00263 int16_t dt_WinchRtvValue; // Winch Moving distance 00264 int16_t dt_WinchDstPosition; // Destination Position 00265 char operation; 00266 int8_t dt_WinchMotorCurrent; // Winch motor current 00267 } winchData_t; 00268 */ 00269 00270 typedef struct { 00271 int16_t dt_WinchCntPosition; // Current winch posittion 00272 int16_t dt_WinchRtvValue; // Winch Moving distance 00273 int16_t dt_WinchDstPosition; // Destination Position 00274 uint8_t operation; 00275 uint8_t dt_WinchMotor1Current; // Winch motor 1 current 00276 uint8_t dt_WinchMotor2Current; // Winch motor 2 current 00277 uint8_t res; 00278 } winchData_t; 00279 00280 00281 #define ROTATE_PER_RESOLUTION 24 00282 00283 #define __READ_CURRENT_AT_CIF_TASK__ 00284 00285 //mv_WinchMvData
Generated on Thu Jul 14 2022 22:19:04 by
1.7.2