小弟写了一个串行设备驱动,初始化的时候调用ttyDevCreate ("/tyCo/1", pSioChan, 512, 512)。读数据都正常,但是发送只能发一个字节。当发送一个字符串的时候只发送了最后一个字符。
进入调试模式,startup程序用回调函数取发送数据时也只取到最后一个字符。我怀疑tty设备的环形缓冲区是不是只有1个字节?是不是哪里配置不对?板上还有另外一个串行设备tyCo/0
请达人指教!
如何验证状态字?我的程序如下:
LOCAL int uartTxStartup
(
SIO_CHAN * pSioChan /* channel to start */
)
{
UINT8 lsrValue;
UINT8 outChar;
UART_CHAN * pUartChan = (UART_CHAN *)pSioChan;
UART_LOGMSG(("uartTxStartup: startup tx a char\n"));
/* This routine should only be called while in interrupt mode */
if (pUartChan->mode == SIO_MODE_POLL)
return ENOSYS; /* Not valid for polled mode operation */
/* Disable all the interrupts */
pUartPtr->ier &= ~(UART_IER_ERBI | UART_IER_ELSI |
UART_IER_EDSSI |UART_IER_ETBEI);
/* SIU interrupt mask */
*SIMASK(pUartChan->ioBase) &= ~(SIMASK_IRM0 >> pUartChan->intVec);
lsrValue = pUartPtr->lsr;
while(((lsrValue & UART_LSR_THRE)!=0)&&
((*pUartChan->getTxChar) (pUartChan->getTxArg, &outChar) == OK));
{
pUartPtr->rbthr = outChar;
UART_LOGMSG(("uartTxStartup:pUartPtr->rbthr = 0x%x\n",outChar));
/* Get the new status of line status register */
lsrValue = pUartPtr->lsr;
}
/* SIU interrupt unmask */
*SIMASK(pUartChan->ioBase) |= SIMASK_IRM0 >> pUartChan->intVec;
/* Enable all the interrupts*/
pUartPtr->ier |= UART_IER_ERBI | UART_IER_EDSSI |UART_IER_ELSI;;
return (OK);
}
每次使用write函数的时候startup调用了一次,并且while循环中的logMsg只打印了一次,且取得字符串最后一个字符。
比如write(fd,"123",3),shell里输出:
uartTxStartup: startup tx a char
uartTxStartup: pUartPtr->rbthr = 0x33
起初我还怀疑(lsrValue & UART_LSR_THRE)!=0这个条件错误,去掉这句还是一样。
我该如何处理呢?
打赏帖 | |
---|---|
分享一种检测按键状态的方法被打赏20分 | |
周末总结一下,STM32C0系列的开发经验被打赏50分 | |
【换取手持数字示波器】MicrochipMPLABHarmony框架下定时器配置被打赏20分 | |
【换取手持数字示波器】MicrochipMPLABHarmony框架下PWM配置被打赏20分 | |
【Cortex-M】Systick Timer使用被打赏10分 | |
分享汽车防盗系统的组成与分类(一)被打赏5分 | |
VOFA+波形显示+JYD-31蓝牙发送和解析不定长数据被打赏10分 | |
【换取手持数字示波器】-STM32F4PWM控制LED灯管亮度被打赏22分 | |
【换取手持数字示波器】STM32F4驱动RPR-0521RS照度、接近一体型传感器被打赏23分 | |
宏定义和const关键字定义被打赏5分 |