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_pc.cpp
00001 #include "data_pc.h" 00002 #include "data_command.h" 00003 00004 Serial pc(PA_2, PA_3); // tx, rx U2 min 00005 00006 00007 int pc_control = 0; // 命令帧标志位 00008 unsigned int flag_A = 0, flag_B = 0; 00009 unsigned int pc_num = 0; 00010 00011 uint16_t mode_flag_get[1] = {0}; 00012 uint16_t mode_flag_use[1] = {0}; 00013 unsigned int mode_flag = 3; 00014 00015 void pc_decode(){ 00016 mode_flag = mode_flag_use[0]; 00017 } 00018 00019 void pc_clear(){ 00020 mode_flag_use[0] = 0; 00021 } 00022 00023 void serial_pc_isr(){ 00024 while(pc.readable()){ 00025 uint16_t c=pc.getc(); 00026 if(c == 'A'){ 00027 flag_A = 1; 00028 flag_B = 0; 00029 pc_num = 0; 00030 mode_flag_get[0] = 0; 00031 break; 00032 } 00033 if(c == 'B'){ 00034 flag_B = 1; 00035 } 00036 if(flag_A == 1){ 00037 if((flag_B != 1) && (pc_num < 1)) 00038 { 00039 mode_flag_get[pc_num] = c; 00040 } 00041 pc_num++; 00042 00043 if((flag_B == 1) && (pc_num != 2)) 00044 { 00045 flag_A = 0; 00046 flag_B = 0; 00047 pc_num = 0; 00048 } 00049 if((flag_B == 1) && (pc_num == 2)) 00050 { 00051 flag_A = 0; 00052 flag_B = 0; 00053 pc_num = 0; 00054 00055 mode_flag_use[0] = mode_flag_get[0] - '0'; 00056 pc_decode(); 00057 00058 command.printf("%d", mode_flag); // 命令帧接收成功 00059 00060 pc_clear(); 00061 00062 } 00063 pc_control = 1; 00064 } 00065 } 00066 }
Generated on Wed Jul 13 2022 08:32:47 by
