236 void IRQ_uart2(void)
237 {
238 char *ptemp;
239 const char gprs_ok[6] ={0x0D,0x0A,0x4F,0x4B,0x0D,0x0A};//OK
240 const char gprs_error[9] = {0x0D,0x0A,0x45,0x52,0x52,0x4F,0x52,0x0D,0x0A};
241 OS_ENTER_CRITICAL();
242 //rINTMSK |= BIT_UART2;//MASK
243 rSUBSRCPND |= BIT_SUB_RXD2;//清除二级中断UART2->Rx2
244 rSRCPND |= BIT_UART2;//清除中断请求
245 rINTPND |= BIT_UART2;
246 OS_EXIT_CRITICAL();
247
248 while(rUFSTAT2 & 0x000F)
249 {
250 ptemp = &UART_ReceiveBuff[0] + uart2_recv_num;
251 if(uart2_recv_num >= UART_BUFFSIZE)
252 { //uart2_recv_num = 0;
253 UART_Int_Close();//退出中断,缓冲区满
254 return;
255 }
256 *ptemp = rURXH2; ?
257 uart2_recv_num++; ?
258
259 //ptemp = UART_ReceiveBuff + uart2_recv_num; ?
260 //temp = (char)memcmp(&UART_ReceiveBuff[0] + (uart2_recv_num - 6),&gprs_ok[0],6);
261 //UART_ReceiveBuff[UART_BUFFSIZE - uart2_recv_num] = temp; ?
262 //if(memcmp(&UART_ReceiveBuff[0] + (uart2_recv_num - 6),"\0x0D\0x0A\0x4F\0x4B\0x0D\0x0A",6)==0)
263 //*(ptemp + UART_BUFFSIZE/2) = (char) memcmp(ptemp - 5,&gprs_ok[0],6);
264 if(memcmp(ptemp - 5,&gprs_ok[0],6)==0)
265 { ?
266 UART_Int_Close();//退出中断,已收到有用信息
267 OSMboxPost(Mbox_gprs_uart2,(void*)GPRS_UART_OK);
268 return;
269 }
270 else //if(memcmp(&UART_ReceiveBuff[0] + (uart2_recv_num - 9),&gprs_error[0],9)==0)
271 if(memcmp(ptemp - 8,&gprs_error[0],9)==0)
272 {
273 OSMboxPost(Mbox_gprs_uart2,(void*)GPRS_UART_ERR);
274 UART_Int_Close();//退出中断,已收到有用信息
275 return;
276 }
277
278 }
279 }
这是串口2的中断函数,本来是puart = OSMboxPend(Mbox_gprs_uart2,0x2000,&err);但是PUART返回的总是超时,所以我想着是不是上面的Mbox_gprs_uart2邮箱没有发送到的原因呢?? |