diff --git a/Gambal/APP/usart1.c b/Gambal/APP/usart1.c index eac2a23..20dab26 100644 --- a/Gambal/APP/usart1.c +++ b/Gambal/APP/usart1.c @@ -40,9 +40,9 @@ unsigned short USART_RX_STA=0; // //} u32 RX_CNT = 0; -u8 f; -u8 x[12]; -u8 y[12]; +u8 Y_index; +u8 G_RX_Xerror[12]; +u8 G_RX_Yerror[12]; void USART1_IRQHandler(void) { unsigned char res; @@ -53,15 +53,15 @@ void USART1_IRQHandler(void) if(res != 0x0d) { USART_RX_BUF[RX_CNT] = res; - if(res == 'y') f = RX_CNT; + if(res == 'y') Y_index = Y_index; USART_RX_STA = 1; RX_CNT++; } else { - memcpy(x,USART_RX_BUF,f+1); - memcpy(y,USART_RX_BUF+f+1,30-f-1); + memcpy(G_RX_Xerror,USART_RX_BUF,Y_index+1); + memcpy(G_RX_Yerror,USART_RX_BUF+Y_index+1,30-Y_index-1); memset(USART_RX_BUF,0,30); RX_CNT = 0; } diff --git a/Gambal/APP/usart1.h b/Gambal/APP/usart1.h index a07ab19..f0d412c 100644 --- a/Gambal/APP/usart1.h +++ b/Gambal/APP/usart1.h @@ -7,13 +7,11 @@ #define RX_485 GPIO_ResetBits(GPIOA,GPIO_Pin_8); #define TX_485 GPIO_SetBits(GPIOA,GPIO_Pin_8); - -extern float error; extern u8 USART_RX_BUF[30]; //接收到的数据长度 extern unsigned short USART_RX_STA; //接收状态标志 -extern u8 x[12]; -extern u8 y[12]; +extern u8 G_RX_Xerror[12]; +extern u8 G_RX_Yerror[12]; void usart1_Init(u32 bound); diff --git a/Gambal/User/main.c b/Gambal/User/main.c index e48a661..9ad8765 100644 --- a/Gambal/User/main.c +++ b/Gambal/User/main.c @@ -129,9 +129,9 @@ int main() PID_ZT(target); -// target =atof((const char *)(x)); +// target =atof((const char *)(G_RX_Xerror)); - target = 0 - atof((const char *)(y)); + target = 0 - atof((const char *)(G_RX_Yerror)); // target =LPF_ZT(target); // angle_close_loop(3.8); // close_loop(target);