2018.07.26
Dependencies: EthernetInterface TextLCD USBDevice USBHost3 mbed
Fork of USBHostHub_HelloWorld by
com_func.cpp@16:1adb3f1e867d, 2018-07-26 (annotated)
- Committer:
- sayzyas
- Date:
- Thu Jul 26 04:21:06 2018 +0000
- Revision:
- 16:1adb3f1e867d
- Parent:
- 14:3a5ae61ab1f4
2018.07.26
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sayzyas | 10:a2bd7d07c7f8 | 1 | #include "mbed.h" |
sayzyas | 10:a2bd7d07c7f8 | 2 | #include "rtos.h" |
sayzyas | 10:a2bd7d07c7f8 | 3 | #include "common.h" |
sayzyas | 10:a2bd7d07c7f8 | 4 | #include "com_func.h" |
sayzyas | 10:a2bd7d07c7f8 | 5 | |
sayzyas | 10:a2bd7d07c7f8 | 6 | |
sayzyas | 10:a2bd7d07c7f8 | 7 | void cf_led_onoff( |
sayzyas | 10:a2bd7d07c7f8 | 8 | DigitalOut *led1, |
sayzyas | 10:a2bd7d07c7f8 | 9 | DigitalOut *led2, |
sayzyas | 10:a2bd7d07c7f8 | 10 | DigitalOut *led3, |
sayzyas | 10:a2bd7d07c7f8 | 11 | DigitalOut *led4, |
sayzyas | 10:a2bd7d07c7f8 | 12 | bool led1_onoff, |
sayzyas | 10:a2bd7d07c7f8 | 13 | bool led2_onoff, |
sayzyas | 10:a2bd7d07c7f8 | 14 | bool led3_onoff, |
sayzyas | 10:a2bd7d07c7f8 | 15 | bool led4_onoff |
sayzyas | 10:a2bd7d07c7f8 | 16 | ){ |
sayzyas | 10:a2bd7d07c7f8 | 17 | if (led1_onoff == true ) *led1 = 1; |
sayzyas | 10:a2bd7d07c7f8 | 18 | else *led1 = 0; |
sayzyas | 10:a2bd7d07c7f8 | 19 | if (led2_onoff == true ) *led2 = 1; |
sayzyas | 10:a2bd7d07c7f8 | 20 | else *led2 = 0; |
sayzyas | 10:a2bd7d07c7f8 | 21 | if (led3_onoff == true ) *led3 = 1; |
sayzyas | 10:a2bd7d07c7f8 | 22 | else *led3 = 0; |
sayzyas | 10:a2bd7d07c7f8 | 23 | if (led4_onoff == true ) *led4 = 1; |
sayzyas | 10:a2bd7d07c7f8 | 24 | else *led4 = 0; |
sayzyas | 10:a2bd7d07c7f8 | 25 | } |
sayzyas | 10:a2bd7d07c7f8 | 26 | |
sayzyas | 10:a2bd7d07c7f8 | 27 | // LED demo |
sayzyas | 10:a2bd7d07c7f8 | 28 | void cf_led_demo( |
sayzyas | 10:a2bd7d07c7f8 | 29 | DigitalOut *led1, |
sayzyas | 10:a2bd7d07c7f8 | 30 | DigitalOut *led2, |
sayzyas | 10:a2bd7d07c7f8 | 31 | DigitalOut *led3, |
sayzyas | 10:a2bd7d07c7f8 | 32 | DigitalOut *led4, |
sayzyas | 10:a2bd7d07c7f8 | 33 | int cnt, |
sayzyas | 10:a2bd7d07c7f8 | 34 | int wait |
sayzyas | 10:a2bd7d07c7f8 | 35 | ){ |
sayzyas | 10:a2bd7d07c7f8 | 36 | for( int i = 0; i < cnt; i++ ) { |
sayzyas | 10:a2bd7d07c7f8 | 37 | *led1 = 1; // on |
sayzyas | 10:a2bd7d07c7f8 | 38 | *led2 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 39 | *led3 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 40 | *led4 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 41 | Thread::wait(wait); |
sayzyas | 10:a2bd7d07c7f8 | 42 | *led1 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 43 | *led2 = 1; // on |
sayzyas | 10:a2bd7d07c7f8 | 44 | *led3 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 45 | *led4 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 46 | Thread::wait(wait); |
sayzyas | 10:a2bd7d07c7f8 | 47 | *led1 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 48 | *led2 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 49 | *led3 = 1; // on |
sayzyas | 10:a2bd7d07c7f8 | 50 | *led4 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 51 | Thread::wait(wait); |
sayzyas | 10:a2bd7d07c7f8 | 52 | *led1 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 53 | *led2 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 54 | *led3 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 55 | *led4 = 1; // on |
sayzyas | 10:a2bd7d07c7f8 | 56 | Thread::wait(wait); |
sayzyas | 10:a2bd7d07c7f8 | 57 | *led1 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 58 | *led2 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 59 | *led3 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 60 | *led4 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 61 | } |
sayzyas | 10:a2bd7d07c7f8 | 62 | } |
sayzyas | 10:a2bd7d07c7f8 | 63 | |
sayzyas | 10:a2bd7d07c7f8 | 64 | void cf_led_error( |
sayzyas | 10:a2bd7d07c7f8 | 65 | DigitalOut *led1, |
sayzyas | 10:a2bd7d07c7f8 | 66 | DigitalOut *led2, |
sayzyas | 10:a2bd7d07c7f8 | 67 | DigitalOut *led3, |
sayzyas | 10:a2bd7d07c7f8 | 68 | DigitalOut *led4 |
sayzyas | 10:a2bd7d07c7f8 | 69 | ){ |
sayzyas | 10:a2bd7d07c7f8 | 70 | for( int i = 0; i < 16; i++ ) { |
sayzyas | 10:a2bd7d07c7f8 | 71 | *led1 = 1; // on |
sayzyas | 10:a2bd7d07c7f8 | 72 | *led2 = 1; // off |
sayzyas | 10:a2bd7d07c7f8 | 73 | *led3 = 1; // off |
sayzyas | 10:a2bd7d07c7f8 | 74 | *led4 = 1; // off |
sayzyas | 10:a2bd7d07c7f8 | 75 | Thread::wait(30); |
sayzyas | 10:a2bd7d07c7f8 | 76 | *led1 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 77 | *led2 = 0; // on |
sayzyas | 10:a2bd7d07c7f8 | 78 | *led3 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 79 | *led4 = 0; // off |
sayzyas | 10:a2bd7d07c7f8 | 80 | Thread::wait(30); |
sayzyas | 10:a2bd7d07c7f8 | 81 | } |
sayzyas | 10:a2bd7d07c7f8 | 82 | } |
sayzyas | 10:a2bd7d07c7f8 | 83 | |
sayzyas | 10:a2bd7d07c7f8 | 84 | void dspSetValue2Console(Serial* pc, setValue_t * setValue){ |
sayzyas | 14:3a5ae61ab1f4 | 85 | pc->printf("WinchDram motor Fwd rote current th: %04d %\r\n", setValue->winchCtrl.sv_WDM_ith_F); |
sayzyas | 14:3a5ae61ab1f4 | 86 | pc->printf("WinchDram motor Rvs rote current th: %04d %\r\n", setValue->winchCtrl.sv_WDM_ith_R); |
sayzyas | 14:3a5ae61ab1f4 | 87 | pc->printf("WinchM2 motor Fwd rote current th: %04d %\r\n", setValue->winchCtrl.sv_WRM_ith_F); |
sayzyas | 14:3a5ae61ab1f4 | 88 | pc->printf("WinchM2 motor Rvs rote current th: %04d %\r\n", setValue->winchCtrl.sv_WRM_ith_R); |
sayzyas | 14:3a5ae61ab1f4 | 89 | pc->printf("WinchDram motor Fwd HighSpeed ratio: %03d %\r\n", setValue->winchCtrl.sv_WDM_hsrto_F); |
sayzyas | 14:3a5ae61ab1f4 | 90 | pc->printf("WinchDram motor Rvs HighSpeed ratio: %03d %\r\n", setValue->winchCtrl.sv_WDM_hsrto_R); |
sayzyas | 14:3a5ae61ab1f4 | 91 | pc->printf("WinchDram motor Fwd LowSpeed ratio: %03d %\r\n", setValue->winchCtrl.sv_WDM_lsrto_F); |
sayzyas | 14:3a5ae61ab1f4 | 92 | pc->printf("WinchDram motor Rvs LowSpeed ratio: %03d %\r\n", setValue->winchCtrl.sv_WDM_lsrto_R); |
sayzyas | 14:3a5ae61ab1f4 | 93 | pc->printf("WinchM2 motor Fwd HighSpeed ratio: %03d %\r\n", setValue->winchCtrl.sv_WRM_hsrto_F); |
sayzyas | 14:3a5ae61ab1f4 | 94 | pc->printf("WinchM2 motor Rvs HighSpeed ratio: %03d %\r\n", setValue->winchCtrl.sv_WRM_hsrto_R); |
sayzyas | 14:3a5ae61ab1f4 | 95 | pc->printf("WinchM2 motor Fwd LowSpeed ratio: %03d %\r\n", setValue->winchCtrl.sv_WRM_lsrto_F); |
sayzyas | 14:3a5ae61ab1f4 | 96 | pc->printf("WinchM2 motor Rvs LowSpeed ratio: %03d %\r\n", setValue->winchCtrl.sv_WRM_lsrto_R); |
sayzyas | 14:3a5ae61ab1f4 | 97 | pc->printf("Winch Dram diameter x 100: %04d \r\n", setValue->winchCtrl.sv_WRS_DramDmrx100); |
sayzyas | 14:3a5ae61ab1f4 | 98 | pc->printf("Winch C-Cable diamter x 100: %04d \r\n", setValue->winchCtrl.sv_WRS_CCableDmrx100); |
sayzyas | 14:3a5ae61ab1f4 | 99 | pc->printf("Winch Resolver resolution: %03d bit\r\n", setValue->winchCtrl.sv_WRS_RResolution); |
sayzyas | 10:a2bd7d07c7f8 | 100 | |
sayzyas | 14:3a5ae61ab1f4 | 101 | pc->printf("RF tfm motor Fwd rote current th: %04d %\r\n", setValue->tfmCtrl.sv_RFTM_ith_F); |
sayzyas | 14:3a5ae61ab1f4 | 102 | pc->printf("RF tfm motor RVS rote current th: %04d %\r\n", setValue->tfmCtrl.sv_RFTM_ith_R); |
sayzyas | 14:3a5ae61ab1f4 | 103 | pc->printf("LB tfm motor FWD rote current th: %04d %\r\n", setValue->tfmCtrl.sv_LBTM_ith_F); |
sayzyas | 14:3a5ae61ab1f4 | 104 | pc->printf("LB tfm motor RVS rote current th: %04d %\r\n", setValue->tfmCtrl.sv_LBTM_ith_R); |
sayzyas | 14:3a5ae61ab1f4 | 105 | pc->printf("RF tfm motor FWD Speed ratio: %03d %\r\n", setValue->tfmCtrl.sv_RFTM_srto_F); |
sayzyas | 14:3a5ae61ab1f4 | 106 | pc->printf("RF tfm motor RVS Speed ratio: %03d %\r\n", setValue->tfmCtrl.sv_RFTM_srto_R); |
sayzyas | 14:3a5ae61ab1f4 | 107 | pc->printf("LB tfm motor FWD Speed ratio: %03d %\r\n", setValue->tfmCtrl.sv_LBTM_srto_F); |
sayzyas | 14:3a5ae61ab1f4 | 108 | pc->printf("LB tfm motor RVS Speed ratio: %03d %\r\n", setValue->tfmCtrl.sv_LBTM_srto_R); |
sayzyas | 10:a2bd7d07c7f8 | 109 | |
sayzyas | 14:3a5ae61ab1f4 | 110 | pc->printf("R-Crawler Fwd rotation current th: %04d %\r\n", setValue->crawlerCtrl.sv_RFCM_ith_F); |
sayzyas | 14:3a5ae61ab1f4 | 111 | pc->printf("R-Crawler Rvs rotation current th: %04d %\r\n", setValue->crawlerCtrl.sv_RFCM_ith_R); |
sayzyas | 14:3a5ae61ab1f4 | 112 | pc->printf("L-Crawler Fwd rotation current th: %04d %\r\n", setValue->crawlerCtrl.sv_LBCM_ith_F); |
sayzyas | 14:3a5ae61ab1f4 | 113 | pc->printf("L-Crawler Rvs rotation current th: %04d %\r\n", setValue->crawlerCtrl.sv_LBCM_ith_R); |
sayzyas | 14:3a5ae61ab1f4 | 114 | pc->printf("R-Crawler Fwd rotation Speed ratio: %03d %\r\n", setValue->crawlerCtrl.sv_RFCM_srto_F); |
sayzyas | 14:3a5ae61ab1f4 | 115 | pc->printf("R-Crawler Rvs rotation Speed ratio: %03d %\r\n", setValue->crawlerCtrl.sv_RFCM_srto_R); |
sayzyas | 14:3a5ae61ab1f4 | 116 | pc->printf("L-Crawler Fwd rotation Speed ratio: %03d\r\n", setValue->crawlerCtrl.sv_LBCM_srto_F); |
sayzyas | 14:3a5ae61ab1f4 | 117 | pc->printf("L-Crawler Rvs rotation Speed ratio: %03d\r\n", setValue->crawlerCtrl.sv_LBCM_srto_R); |
sayzyas | 14:3a5ae61ab1f4 | 118 | |
sayzyas | 14:3a5ae61ab1f4 | 119 | pc->printf("R-JS UpperDeadZone: %03d\r\n", setValue->crawlerCtrl.sv_RFCM_dzu); |
sayzyas | 14:3a5ae61ab1f4 | 120 | pc->printf("R-JS CenterValue: %03d\r\n", setValue->crawlerCtrl.sv_RFCM_dzc); |
sayzyas | 14:3a5ae61ab1f4 | 121 | pc->printf("R-JS LowerDeadZone: %03d\r\n", setValue->crawlerCtrl.sv_RFCM_dzl); |
sayzyas | 14:3a5ae61ab1f4 | 122 | pc->printf("L-JS UpperDeadZone: %03d\r\n", setValue->crawlerCtrl.sv_LBCM_dzu); |
sayzyas | 14:3a5ae61ab1f4 | 123 | pc->printf("L-JS CenterValue: %03d\r\n", setValue->crawlerCtrl.sv_LBCM_dzc); |
sayzyas | 14:3a5ae61ab1f4 | 124 | pc->printf("L-JS LowerDeadZone: %03d\r\n", setValue->crawlerCtrl.sv_LBCM_dzl); |
sayzyas | 14:3a5ae61ab1f4 | 125 | |
sayzyas | 14:3a5ae61ab1f4 | 126 | pc->printf("Reserved1: %03d\r\n", setValue->crawlerCtrl.reserved1); |
sayzyas | 14:3a5ae61ab1f4 | 127 | pc->printf("Reserved2: %03d\r\n", setValue->crawlerCtrl.reserved2); |
sayzyas | 14:3a5ae61ab1f4 | 128 | |
sayzyas | 13:2c70c772fe24 | 129 | pc->printf( "\r\n" ); |
sayzyas | 10:a2bd7d07c7f8 | 130 | } |