发新话题
打印

【原创】关于ARMSYS2440_wince5.0上做三串口的修改方法

【原创】关于ARMSYS2440_wince5.0上做三串口的修改方法

关于ARMSYS2440_wince5.0上做三串口的修改方法


 


由于好多客户在实际项目应用中遇到了需要3个串口的问题,我们立宇泰的ARMSYS2440开发板本身就带有3串口,但由于在wince5.0中UART1是作为调试口被占用了,所以无法直接当串口应用。现将其修改为普通串口用方法贴出来,方便大家应用!


1,首先修改下串口驱动:
E:\platform\SMDK2440A_3UART\Src\Drivers\Serial\ser_smdk2440.cpp
下加串口3的驱动,(当然要保留原来两个串口的驱动哦)^o^

class CPdd2440Serial3 : public CPdd2440Uart {
public:
    CPdd2440Serial3(LPTSTR lpActivePath, PVOID pMdd, PHWOBJ pHwObj)
        : CPdd2440Uart(lpActivePath, pMdd, pHwObj)
        {
        m_pIOPregs = NULL;
    }
    ~CPdd2440Serial3() {
        if (m_pIOPregs!=NULL)
            MmUnmapIoSpace((PVOID)m_pIOPregs,0);
    }
    virtual BOOL Init() {
        PHYSICAL_ADDRESS    ioPhysicalBase = { S3C2440A_BASE_REG_PA_IOPORT, 0};
        ULONG               inIoSpace = 0;
        if (TranslateBusAddr(m_hParent,Internal,0, ioPhysicalBase,&inIoSpace,&ioPhysicalBase)) {
            // Map it if it is Memeory Mapped IO.
            m_pIOPregs =(S3C2440A_IOPORT_REG *) MmMapIoSpace(ioPhysicalBase, sizeof(S3C2440A_IOPORT_REG),FALSE);
        }
        if (m_pIOPregs) {
            DDKISRINFO ddi;
            if (GetIsrInfo(&ddi)== ERROR_SUCCESS &&
                    KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &ddi.dwIrq, sizeof(UINT32), &ddi.dwSysintr, sizeof(UINT32), NULL))
            {  
                RegSetValueEx(DEVLOAD_SYSINTR_VALNAME,REG_DWORD,(PBYTE)&ddi.dwSysintr, sizeof(UINT32));
            }
            else
                return FALSE;

         //m_pIOPregs->GPHCON &= ~(0x3<<12 | 0x3<<14); // uart 2 - rx, tx
         //m_pIOPregs->GPHCON |= (0x2<<12 | 0x2<<14);
   m_pIOPregs->GPHCON &= ~(0x3<<0 | 0x3<<2 | 0x3<<4 | 0x3<<6 | 0x3<<8 | 0x3<<10);//tx,rx,rts,cts
   m_pIOPregs->GPHCON |=  (0x2<<0 | 0x2<<2 | 0x2<<4 | 0x2<<6 | 0x2<<8 | 0x2<<10);
         m_pIOPregs->GPHUP |= 0xc0;
       
//         m_pIOPregs->GPBCON &= ~(0x3<<2); //GPB1 -> nIrDATXDEN
//         m_pIOPregs->GPBCON |=  (0x1<<2);
//         m_pIOPregs->GPBUP  |=  (0x1<<1);
//         m_pIOPregs->GPBDAT &= ~(0x1<<1);

            return CPdd2440Uart::Init();
        }
        return FALSE;
    };
    virtual void    SetDefaultConfiguration() {
        CPdd2440Uart::SetDefaultConfiguration();
    }
//    virtual ULONG   GetModemStatus() {
//        return (CPdd2440Uart::GetModemStatus() | MS_CTS_ON);
//    }
//    virtual void    Rx_Pause(BOOL bSet) {
//     if(bSet)
//      m_pIOPregs->GPHCON = (m_pIOPregs->GPHCON & ~(0x3<<14)) | 0x0<<14;
//     else 
//      m_pIOPregs->GPHCON = (m_pIOPregs->GPHCON & ~(0x3<<14)) | 0x2<<14;
//    }

    volatile S3C2440A_IOPORT_REG * m_pIOPregs;
};

然后再在后面的switch语句中加入串口3
整段程序如下:
CSerialPDD * CreateSerialObject(LPTSTR lpActivePath, PVOID pMdd,PHWOBJ pHwObj, DWORD DeviceArrayIndex)
{
    CSerialPDD * pSerialPDD = NULL;
    switch (DeviceArrayIndex) {
      case 0:
        pSerialPDD = new CPdd2440Serial1(lpActivePath,pMdd, pHwObj);
        break;
      case 1:
        pSerialPDD = new CPdd2440Serial2(lpActivePath,pMdd, pHwObj);
        break;
      case 2:
        pSerialPDD = new CPdd2440Serial3(lpActivePath,pMdd, pHwObj);
        break;
    }
    if (pSerialPDD && !pSerialPDD->Init()) {
        delete pSerialPDD;
        pSerialPDD = NULL;
    }   
    return pSerialPDD;
}
void DeleteSerialObject(CSerialPDD * pSerialPDD)
{
    if (pSerialPDD)
        delete pSerialPDD;
}



2,接着下面就是要屏蔽UART1的调试信息:


找到\Src\Kernel\Oal\debug.c这个文件,里面屏蔽//OUTREG32(&g_pUARTReg->UTXH, ch);这句

 

3,然后再在注册表里添加UART1。
IF BSP_NOUART1 !
IF BSP_KITL != SERIAL_UART1
=============== UART1 (physical COM2 connector P1) (Serial) ===============
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial1]
"DeviceArrayIndex"=dword:2
"Irq"=dword:17
"MemBase"=dword:50004000
"MemLen"=dword:2C
"InterruptBitsShift"=dword:3 ; UART 1 Interrupt Sub Register shift bit.
"ISTTimeouts"=dword:200 ; every 512 ticks checking Modem status.
"Prefix"="COM"
"Index"=dword:2
"Dll"="serial_smdk2440.dll"
"Order"=dword:0
"Priority"=dword:0
"Port"="COM2:"
"DeviceType"=dword:0
"FriendlyName"=LOC_DISPLAYNAME_COM2
"Tsp"="unimodem.dll"
"IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
"DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00
ENDIF
ENDIF
然后就大功告成,只要重新做个NK,3个串口就可以用了。
[ 本帖最后由 lyt_sport 于 2009-3-9 10:22 编辑 ]

TOP

顶一下

TOP

好,路过学习!

TOP

按方法试过了,不但不能实现三个串口都使用,而且出现三个串口都不能用的情况,怒知道是什么情况!

TOP

我汗,我的加入这个串口
桌面都不会进入了。
不停的打印
EvaluateEventFlag (eventMask = 0x80) - device was closed
EvaluateEventFlag (eventMask = 0x40) - device was closed
EvaluateEventFlag (eventMask = 0x2) - device was closed
EvaluateEventFlag (eventMask = 0x80) - device was closed
EvaluateEventFlag (eventMask = 0x40) - device was closed
EvaluateEventFlag (eventMask = 0x2) - device was closed
EvaluateEventFlag (eventMask = 0x80) - device was closed
EvaluateEventFlag (eventMask = 0x40) - device was closed

TOP

发新话题