diff --git a/APP/peripheral_main.c b/APP/peripheral_main.c index abdee94..fd0ce50 100644 --- a/APP/peripheral_main.c +++ b/APP/peripheral_main.c @@ -59,6 +59,7 @@ void Main_Circulation() TMOS_SystemProcess(); KEY_ProcessLoop(); MultiTimerYield(); + BSP_UART3_TxLoop(); } } diff --git a/bsp/inc/bsp_uart.h b/bsp/inc/bsp_uart.h index 7616859..943e41e 100644 --- a/bsp/inc/bsp_uart.h +++ b/bsp/inc/bsp_uart.h @@ -19,6 +19,7 @@ void BSP_UART3_Init(void); unsigned int BSP_Uart3_Receive_Data(void *buf, unsigned int len); unsigned int BSP_Uart3_Send_Data(const void *buf, unsigned int len); void BSP_Shell_Loop(void); +void BSP_UART3_TxLoop(void); #endif diff --git a/bsp/src/bsp_ml307r.c b/bsp/src/bsp_ml307r.c index a3702bd..61dbd5d 100644 --- a/bsp/src/bsp_ml307r.c +++ b/bsp/src/bsp_ml307r.c @@ -519,7 +519,7 @@ static int BSP_Module_Connect_CtWing_Handle(at_env_t *e) { case 0: logDebug("create device...\r\n"); - e->println(e, "AT+MIPOPEN=0,\"TCP\",\"112.125.89.8\",44679,,1"); // 8.135.10.183,32994 + e->println(e, "AT+MIPOPEN=0,\"TCP\",\"112.125.89.8\",47766,,1"); // 8.135.10.183,32994 e->reset_timer(e); e->state++; break; diff --git a/bsp/src/bsp_uart.c b/bsp/src/bsp_uart.c index 93ce8fd..eeaacb7 100644 --- a/bsp/src/bsp_uart.c +++ b/bsp/src/bsp_uart.c @@ -55,9 +55,36 @@ unsigned int BSP_Uart3_Send_Data(const void *buf, unsigned int len) unsigned int ret; ret = lwrb_write(&uart3_tx_t, buf, len); - UART3_INTCfg(ENABLE, RB_IER_THR_EMPTY); + // UART3_INTCfg(ENABLE, RB_IER_THR_EMPTY); + // BSP_BlockSleep(); + BSP_UART3_TxLoop(); + // BSP_RequestSleep(); return ret; } + + +// https://www.cnblogs.com/iot-fan/p/13439293.html +// tx process +// 本查询函数需要扔到主循环不断调用 +void BSP_UART3_TxLoop(void) +{ + uint8_t data; + while (R8_UART3_TFC < UART_FIFO_SIZE) + { + // 判断发送软件缓冲区,是否空,如果不空,就一个一个读出来,填到硬件fifo里 + if (lwrb_get_full(&uart3_tx_t)) + { + lwrb_read(&uart3_tx_t, &data, 1); + // 把软件缓冲区的数据填到uart的硬件发送fifo里 + UART3_SendByte(data); + } + else + { + break; + } + } +} + /** * \brief Buffer event function */ @@ -255,15 +282,15 @@ void UART3_IRQHandler(void) } break; case UART_II_THR_EMPTY: // 发送缓存区空,可继续发送 - if(lwrb_get_full(&uart3_tx_t)) - { - lwrb_read(&uart3_tx_t, &data, 1); - UART3_SendByte(data); - } - else - { - UART3_INTCfg(DISABLE, RB_IER_THR_EMPTY); - } + // if(lwrb_get_full(&uart3_tx_t)) + // { + // lwrb_read(&uart3_tx_t, &data, 1); + // UART3_SendByte(data); + // } + // else + // { + // UART3_INTCfg(DISABLE, RB_IER_THR_EMPTY); + // } break;