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.
data_board.cpp
00001 #include "mbed.h" 00002 #include "data_board.h" 00003 #include "data_pc.h" 00004 00005 Serial foot(PC_10, PC_11); // tx, rx U3 00006 00007 00008 unsigned int flag_485_A = 0, flag_485_B = 0; 00009 unsigned int S485num = 0; 00010 00011 uint16_t S485get[10] = {0}; 00012 uint16_t S485use[10] = {0}; 00013 00014 //////////////////////////////////////////////////////////////////////////////// 00015 // Gait_now 当前相位 Gait_per_now 当前步态时刻 Gait_change 步态改变标志位 00016 // Gait_num_valid 步数统计 time_portion_now 当前相位时间段 00017 //////////////////////////////////////////////////////////////////////////////// 00018 00019 unsigned int Gait_num_valid = 0, Gait_now = 0, Gait_per_now = 0, Gait_cycle_now = 0, time_portion_now=0; 00020 uint16_t Gait_per_now_int = 0, COP_Y_int = 0, COP_X_int = 0, Gait_cycle_now_int = 0, time_portion_now_int=0; 00021 float COP_Y = 0.0f, COP_X = 0.0f; 00022 00023 unsigned int Gait_num_valid_0before = 0, Gait_now_0before = 0; 00024 float Gait_per_now_0before = 0.0f, COP_Y_0before = 0.0f, COP_X_0before = 0.0f, Gait_cycle_now_0before = 0.0f; 00025 00026 unsigned int Gait_num_valid_real = 0, Gait_now_real = 0, Gait_per_now_real = 0, Gait_cycle_now_real = 0.0f, time_portion_now_real=0.0f; 00027 float COP_Y_real = 0.0f, COP_X_real = 0.0f; 00028 00029 00030 void gait_decode() 00031 { 00032 Gait_now = S485use[0]; 00033 Gait_per_now = S485use[1]*100 + S485use[2]*10 + S485use[3]; 00034 time_portion_now = S485use[4]*100000 + S485use[5]*10000 + S485use[6]*1000 + S485use[7]*100 + S485use[8]*10 + S485use[9]; 00035 00036 00037 Gait_num_valid_real = Gait_num_valid; 00038 Gait_now_real = Gait_now; 00039 Gait_per_now_real = Gait_per_now; 00040 COP_Y_real = COP_Y; 00041 COP_X_real = COP_X; 00042 Gait_cycle_now_real = Gait_cycle_now; 00043 time_portion_now_real=time_portion_now; 00044 00045 pc.printf("%01d---%03d---%06d\n",Gait_now_real,Gait_per_now_real,time_portion_now_real); 00046 } 00047 00048 void gait_clear() 00049 { 00050 for(int i = 0; i < 10; i++){ 00051 S485use[i] = 0; 00052 } 00053 } 00054 00055 00056 void serial_board_isr(void) 00057 { 00058 // pc.printf("begin\n"); 00059 while(foot.readable()) 00060 { 00061 uint16_t c = foot.getc(); 00062 if(c == 'A') 00063 { 00064 flag_485_A = 1; 00065 00066 flag_485_B = 0; 00067 S485num = 0; 00068 for(unsigned int i = 0; i < 10; i++) 00069 { 00070 S485get[i] = 0; 00071 } 00072 00073 break; 00074 } 00075 if(c == 'B') 00076 { 00077 flag_485_B = 1; 00078 } 00079 00080 if(flag_485_A == 1) 00081 { 00082 if((flag_485_B != 1) && (S485num < 10)) 00083 { 00084 S485get[S485num] = c; 00085 } 00086 00087 S485num++; 00088 00089 if((flag_485_B == 1) && (S485num != 11)) 00090 { 00091 flag_485_A = 0; 00092 flag_485_B = 0; 00093 S485num = 0; 00094 } 00095 00096 if((flag_485_B == 1) && (S485num == 11)) 00097 { 00098 flag_485_A = 0; 00099 flag_485_B = 0; 00100 S485num = 0; 00101 00102 for(unsigned int i = 0; i < 10; i++) 00103 { 00104 S485use[i] = S485get[i] - '0'; 00105 } 00106 00107 gait_decode(); 00108 pc.printf("OK\n"); 00109 gait_clear(); 00110 } 00111 } 00112 } 00113 }
Generated on Thu Jul 28 2022 13:35:42 by
