11
DATA_BOARD/data_board.cpp
- Committer:
- yezhong
- Date:
- 2021-08-06
- Revision:
- 2:9418258519ea
- Parent:
- 0:dd5d4837292c
File content as of revision 2:9418258519ea:
#include "data_board.h" Serial foot(PA_9, PA_10); // tx, rx U1 unsigned int flag_foot_A = 0, flag_foot_B = 0; unsigned int Sfootnum = 0; uint8_t Sfootget[30] = {0}; uint8_t Sfootuse[30] = {0}; uint16_t shou[15]={0}; float shou1[15]={0}; void gait_decode() { for(int i = 0; i < 15; i++) { shou[i]=(Sfootuse[2*i]<<8)|Sfootuse[2*i+1]; } for(int i = 0; i < 15; i++) { shou1[i]=(float)shou[i]/4096*3.3; } pc.printf("%2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f\r\n",shou1[6],shou1[7],shou1[8],shou1[9],shou1[10],shou1[11],shou1[12],shou1[13],shou1[14]); } void gait_clear() { for(int i = 0; i < 30; i++){ Sfootuse[i] = 0; } } void serial_board_isr(void) { // pc.printf("begin\n"); while(foot.readable()) { uint8_t c = foot.getc(); if(c ==0x0A) { flag_foot_A = 1; flag_foot_B = 0; Sfootnum = 0; for(unsigned int i = 0; i < 30; i++) { Sfootget[i] = 0; } break; } if(c ==0x0B) { flag_foot_B = 1; } if(flag_foot_A == 1) { if((flag_foot_B != 1) && (Sfootnum < 30)) { Sfootget[Sfootnum] = c; } Sfootnum++; if((flag_foot_B == 1) && (Sfootnum != 31)) { flag_foot_A = 0; flag_foot_B = 0; Sfootnum = 0; } if((flag_foot_B == 1) && (Sfootnum == 31)) { flag_foot_A = 0; flag_foot_B = 0; Sfootnum = 0; for(unsigned int i = 0; i < 30; i++) { // Sfootuse[i] = Sfootget[i] - '0'; Sfootuse[i] = Sfootget[i] ; } gait_decode(); gait_clear(); } } } }