主要功能是为了实现与外部设备串口的通信,并对约定好的协议进行实时接收处理。但是外部设备的串口有点特殊,是只用一根线进行发送和接受数据,类似:
------------- TxD1
|-------- |------------
S3C2440 | RxD1 |--------------| 外部设备
|-------- |------------
-------------
所以在S3C2440这边,发送时就得把 RxD1 关闭,接收时就得把TxD1关闭
按照大侠们的意见,有点想改PDD这部分代码,但是不知是不是在这里修改:
- ULONG CPdd2440Uart::ReceiveInterruptHandler(PUCHAR pRxBuffer,ULONG *pBufflen)
- {
- DEBUGMSG(ZONE_THREAD|ZONE_READ,(TEXT("+CPdd2440Uart::ReceiveInterruptHandler
- pRxBuffer=%x,*pBufflen=%x\r\n"),pRxBuffer,pBufflen!=NULL?*pBufflen:0));
-
- DWORD dwBytesDropped = 0;
- if (pRxBuffer && pBufflen )
- {
- DWORD dwBytesStored = 0 ;
- DWORD dwRoomLeft = *pBufflen;
- m_bReceivedCanceled = FALSE;
- m_HardwareLock.Lock();
-
- while (dwRoomLeft && !m_bReceivedCanceled)
- {
- ULONG ulUFSTATE = m_pReg2440Uart->Read_UFSTAT();
- DWORD dwNumRxInFifo = (ulUFSTATE & (0x3f<<0));
- if ((ulUFSTATE & (1<<6))!=0) // Overflow. Use FIFO depth (16);
- dwNumRxInFifo = SER2440_FIFO_DEPTH_RX;
- DEBUGMSG(ZONE_THREAD|ZONE_READ,(TEXT
- ("CPdd2440Uart::ReceiveInterruptHandler ulUFSTATE=%x,
- UTRSTAT=%x, dwNumRxInFifo=%X\r\n"),ulUFSTATE,
- m_pReg2440Uart->Read_UTRSTAT(), dwNumRxInFifo));
- if (dwNumRxInFifo)
- {
- ASSERT((m_pReg2440Uart->Read_UTRSTAT () & (1<<0))!=0);
- while (dwNumRxInFifo && dwRoomLeft)
- {
- UCHAR uLineStatus = GetLineStatus();
- UCHAR uData = m_pReg2440Uart->Read_URXH();
- if(DataReplaced(&uData,(uLineStatus&UERSTATE_PARITY_ERROR)!=0))
- {
- [color=#FF0000]*pRxBuffer++ = uData;
- dwRoomLeft--;
- dwBytesStored++; [/color]
- }
- dwNumRxInFifo --;
- }
- }
- else
- break;
- }
- if (m_bReceivedCanceled)
- dwBytesStored = 0;
-
- m_HardwareLock.Unlock();
- *pBufflen = dwBytesStored;
- }
- else
- {
- ASSERT(FALSE);
- }
- DEBUGMSG(ZONE_THREAD|ZONE_READ,(TEXT("-CPdd2440Uart::ReceiveInterruptHandler
- pRxBuffer=%x,*pBufflen=%x,dwBytesDropped=%x\r\n"),
- pRxBuffer,pBufflen!=NULL?*pBufflen:0,dwBytesDropped));
- return dwBytesDropped;
- }
在红色字体那里增加数据协议分析及保存到缓存区的操作吗?这是3个串口共用的程序,如何判断是UART1的呢?如何把接收到的数据发送给MDD层呢,pRxBuffer吗?
多谢各位大侠指点!!!!