__interrupt void UART1_RX_IRQHandler(void) { if(UART1_GetITStatus(UART1_IT_RXNE )!= RESET) { UART1_ReceiveData8(); } }
__interrupt void UART1_RX_IRQHandler(void) { unsigned char rxdbuft; if(UART1_GetITStatus(UART1_IT_RXNE )!= RESET) //*接收中断( { rxdbuft=UART1_ReceiveData8();//*(USART1->DR);读取接收到的数据,当读完数据后自动取消RXNE的中断标志位 comrecive1.comtime=0; switch (comrecive1.compra) { case 0: if(rxdbuft==0xfe) comrecive1.compra=1; break; case 1: if(rxdbuft>15) comrecive1.compra=0; else { comrecive1.comlong= rxdbuft-1; comrecive1.compra=2; comrecive1.cominlong=0; comrecive1.comcrc=rxdbuft; } break; case 2: comrecive1.comdata[comrecive1.cominlong]=rxdbuft; if(++comrecive1.cominlong>= comrecive1.comlong) { if(comrecive1.comcrc == comrecive1.comdata[comrecive1.cominlong-1]);//(comrecive1.comdata[comrecive1.cominlong-2]<<1)) // if( rxdbuft==0x43) { if(comrecive1.comdata[2]==1)//取传感器信息 { uart_send_cmd[0] = 0xfe; uart_send_cmd[1] = 0x07; uart_send_cmd[2] = 0x00; uart_send_cmd[3] = 0x02; uart_send_cmd[4] =0x01; uart_send_cmd[5] =23;//配置块个数 uart_send_cmd[6] =48; // 传感器检测位置点 uart_send_cmd[7] =sum_verify(&uart_send_cmd[1],6); uart_send_cmd[8] =0x45; uart_send_length_bk=9; uart_event=1; uart_busy=1; } if(comrecive1.comdata[2]==2)//接收状态 { uart_event=1; } if(comrecive1.comdata[2]==3)//接收处方 { uart_send_cmd[0] = 0xfe; uart_send_cmd[1] = 0x07; uart_send_cmd[2] = 0x00; uart_send_cmd[3] = 0x02; uart_send_cmd[4] =0x03; uart_send_cmd[5] =1;// uart_send_cmd[6] =sum_verify(&uart_send_cmd[1],5); uart_send_cmd[7] =0x45; uart_send_length_bk=8; uart_event=1; uart_busy=1; } } comrecive1.compra=0; } else comrecive1.comcrc +=rxdbuft; break; default: break; } } }