;=============== UART1 (physical COM2 connector P1) (Serial) ===============
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial1]
"DeviceArrayIndex"=dword:1
"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_COM1
"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
;=============== UART2 (physical COM3 connector P1) (Serial) ===============
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial2]
"DeviceArrayIndex"=dword:2
"Irq"=dword:f
"MemBase"=dword:50008000
"MemLen"=dword:2C
"InterruptBitsShift"=dword:6 ; UART 1 Interrupt Sub Register shift bit.
"ISTTimeouts"=dword:200 ; every 512 ticks checking Modem status.
"Prefix"="COM"
"Index"=dword:3
"Dll"="serial_smdk2440.dll"
"Order"=dword:0
"Priority"=dword:0
"Port"="COM3:"
"DeviceType"=dword:0
"FriendlyName"=LOC_DISPLAYNAME_COM1
"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
2.修改程序,加入串口二和串口三。
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name:
Abstract:
Serial PDD for SamSang 2440 Development Board.
Notes:
--*/
#include
#include
#include
#include
#include
#include
#include
#include
// CPdd2440Serial1 is only use for UART 0 which
// RTS & CTS is use GPH0 GPH1
// DTR & DSR is USE GPD0 GPD1
class CPdd2440Serial1 : public CPdd2440Uart {
public:
CPdd2440Serial1(LPTSTR lpActivePath, PVOID pMdd, PHWOBJ pHwObj)
: CPdd2440Uart(lpActivePath, pMdd, pHwObj)
{
m_pIOPregs = NULL;
m_fIsDSRSet = FALSE;
}
~CPdd2440Serial1() {
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_pDTRPort = (volatile ULONG *)&(m_pIOPregs->GPDDAT);
m_pDSRPort = (volatile ULONG *)&(m_pIOPregs->GPDDAT);
m_dwDTRPortNum = 0;
m_dwDSRPortNum = 1;
m_pIOPregs->GPHCON &= ~(0x3<<0 | 0x3<<2 | 0x3<<4 | 0x3<<6 );//tx,rx,rts,cts
m_pIOPregs->GPHCON |= (0x2<<0 | 0x2<<2 | 0x2<<4 | 0x2<<6 );
m_pIOPregs->GPHCON |= (0x2<<0 | 0x2<<2);
m_pIOPregs->GPHUP |= 0xf;
#if 0
m_pIOPregs->GPDCON &= ~(0x3<<0 | 0x3<<2);//dtr,dsr
m_pIOPregs->GPDCON |= (0x1<<0 | 0x0<<2);
m_pIOPregs->GPDUP |= 0x3;
#endif
return CPdd2440Uart::Init();
}
return FALSE;
};
virtual void SetDefaultConfiguration() {
CPdd2440Uart::SetDefaultConfiguration();
}
virtual BOOL InitModem(BOOL bInit) {
SetDTR(bInit);
return CPdd2440Uart::InitModem(bInit);
}
virtual ULONG GetModemStatus() {
ULONG ulReturn = CPdd2440Uart::GetModemStatus();
ULONG ulEvent = 0;
m_HardwareLock.Lock();
BOOL fIsDSRSet = (((*m_pDSRPort) & (1<
if (fIsDSRSet != m_fIsDSRSet) {
ulEvent |= EV_DSR | EV_RLSD;
}
ulReturn |= (fIsDSRSet?(MS_DSR_ON|MS_RLSD_ON):0);
m_fIsDSRSet = fIsDSRSet;
m_HardwareLock.Unlock();
if (ulEvent!=0)
EventCallback(ulEvent,ulReturn);
return ulReturn;
}
virtual void SetDTR(BOOL bSet) {
if (bSet)
*m_pDTRPort &= ~(1<
else
*m_pDTRPort |= (1<
};
private:
volatile S3C2440A_IOPORT_REG * m_pIOPregs;
volatile ULONG * m_pDTRPort;
DWORD m_dwDTRPortNum;
volatile ULONG * m_pDSRPort;
DWORD m_dwDSRPortNum;
BOOL m_fIsDSRSet;
};
// CPdd2440Serial2 is only use for UART 2 which
// nIrDATXDEN use GPB1
class CPdd2440Serial2 : public CPdd2440Uart {
public:
CPdd2440Serial2(LPTSTR lpActivePath, PVOID pMdd, PHWOBJ pHwObj)
: CPdd2440Uart(lpActivePath, pMdd, pHwObj)
{
m_pIOPregs = NULL;
}
~CPdd2440Serial2() {
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<<8 | 0x3<<10); // uart 2 - rx, tx
m_pIOPregs->GPHCON |= (0x2<<8 | 0x2<<10);
m_pIOPregs->GPHUP |= 0x30;
//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;
};
// CPdd2440Serial2 is only use for UART 2 which
// nIrDATXDEN use GPB1
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->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;
};
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;
}
第三步:测试串口。--ok。
阅读(2494) | 评论(1) | 转发(0) |