wulianwei 3 meses atrás
pai
commit
57f43e9905
1 arquivos alterados com 22 adições e 12 exclusões
  1. 22 12
      code/hal/nim_uart.c

+ 22 - 12
code/hal/nim_uart.c

@@ -42,7 +42,8 @@
 #define PINMUX4_UART2_RXD_ENABLE    (SYSCFG_PINMUX4_PINMUX4_19_16_UART2_RXD << \
                                      SYSCFG_PINMUX4_PINMUX4_19_16_SHIFT)
 
-extern void UARTPinMuxSetup(unsigned int instanceNum, unsigned int modemCtrlChoice);
+extern void UARTPinMuxSetup(unsigned int instanceNum,
+                            unsigned int modemCtrlChoice);
 static void UART1InterruptInit(void);
 static void UART1Isr();
 static void UART2InterruptInit(void);
@@ -185,7 +186,6 @@ void UART2Init()
 //
 //    }
 //}
-
 /****************************************************************************/
 /*                                                                          */
 /*              UART1 中断初始化                                             */
@@ -265,7 +265,8 @@ static void UART1Isr()
         rxData = UARTCharGetNonBlocking(SOC_UART_1_REGS);
         if (UART_CONSOLE_BASE == SOC_UART_1_REGS)
         {
-            ConsoleRecvFill(rxData);
+            //ConsoleRecvFill(rxData);
+            enqueueFromUart(rxData); // 添加到队列
         }
         else
         {
@@ -307,34 +308,43 @@ static void UART2Isr()
     IntEventClear(SYS_INT_UART2_INT);
 
     // 发送中断
-    if(UART_INTID_TX_EMPTY == int_id)
+    if (UART_INTID_TX_EMPTY == int_id)
     {
-        if(0 < length)
+        if (0 < length)
         {
             // 写一个字节到 THR
             UARTCharPutNonBlocking(SOC_UART_2_REGS, txArray[count]);
             length--;
             count++;
         }
-        if(0 == length)
+        if (0 == length)
         {
             // 禁用发送中断
             UARTIntDisable(SOC_UART_2_REGS, UART_INT_TX_EMPTY);
         }
-     }
+    }
 
     // 接收中断
-    if(UART_INTID_RX_DATA == int_id)
+    if (UART_INTID_RX_DATA == int_id)
     {
         rxData = UARTCharGetNonBlocking(SOC_UART_2_REGS);
-        UARTCharPutNonBlocking(SOC_UART_2_REGS, rxData);
-        enqueueFromUart(rxData); // 添加到队列
+        if (UART_CONSOLE_BASE == SOC_UART_2_REGS)
+        {
+            //ConsoleRecvFill(rxData);
+            enqueueFromUart(rxData); // 添加到队列
+        }
+        else
+        {
+            UARTCharPutNonBlocking(SOC_UART_2_REGS, rxData);
+
+        }
+
     }
 
     // 接收错误
-    if(UART_INTID_RX_LINE_STAT == int_id)
+    if (UART_INTID_RX_LINE_STAT == int_id)
     {
-        while(UARTRxErrorGet(SOC_UART_2_REGS))
+        while (UARTRxErrorGet(SOC_UART_2_REGS))
         {
             // 从 RBR 读一个字节
             UARTCharGetNonBlocking(SOC_UART_2_REGS);