Zstack双串口使用问题
TY您好,根据此帖在Z-Stack Mesh 1.0.0中GenericApp例程中修改双串口工作,在编译选项中定义
HAL_UART=TRUE
HAL_UART_ISR=1
HAL_UART_DMA=2
代码中串口初始化
void Uart_Init(uint8 port)
{
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE; // 2x30 don't care - see uart driver.
uartConfig.baudRate = HAL_UART_BR_9600;
uartConfig.flowControl = FALSE;
uartConfig.flowControlThreshold = 64; // 2x30 don't care - see uart driver.
uartConfig.rx.maxBufSize = 128; // 2x30 don't care - see uart driver.
uartConfig.tx.maxBufSize = 128; // 2x30 don't care - see uart driver.
uartConfig.idleTimeout = 6; // 2x30 don't care - see uart driver.
uartConfig.intEnable = TRUE; // 2x30 don't care - see uart driver.
uartConfig.callBackFunc = UART_CallBack;
HalUARTOpen (port, &uartConfig);
}
static void UART_CallBack(uint8 port, uint8 event)
{
uint16 len=0;
if(port == HAL_UART_PORT_0)
{
len=HalUARTRead(HAL_UART_PORT_0,RxBuf,128);
if(len > 0)
{
HalUARTWrite( HAL_UART_PORT_0, RxBuf, len );
len=0;
}
}
if(port == HAL_UART_PORT_1)
{
len=HalUARTRead(HAL_UART_PORT_1,RxBuf,128);
if(len > 0)
{
HalUARTWrite( HAL_UART_PORT_1, RxBuf, len );
len=0;
}
}
}
UART0工作正常,UART1(P1_6和P1_7)发送并接收数据,但是测试发现UART1口的回调函数一旦触发就一直在运行,现象就是往UART1发送一串数据,接收到再打印出来,发一次后,UART1就不停的重复输出之前接收到的数据,而且时间不定,请给予修改的建议和意见,谢谢!
是同时使用的时候才会有问题吗?
P1.6和P1.7上面有没有其他地方有定义