S3C2410的WINCE BSP添加串口支持
pRegBase = (PUCHAR)pHWHead->s2410SerReg;
本文引用地址:http://m.butianyuan.cn/article/201610/305888.htm#else
pRegBase = (PUCHAR)UART2_BASE;
pHWHead->s2410SerReg = (S2410_UART_REG *)pRegBase;
#endif
}
else
{
把這其中的代碼修改為以下代碼
}
if(pHWHead1->dwIOBase == 0x50004000)
{
pHWHead->bINT = BIT_UART1;
pHWHead->bTxINT = INTSUB_TXD1;
pHWHead->bRxINT = INTSUB_RXD1;
pHWHead->bErrINT = INTSUB_ERR1;
#if USEVIRTUAL
pHWHead->s2410SerReg = (S2410_UART_REG *)v_pUART1regs;
pRegBase = (PUCHAR)pHWHead->s2410SerReg;
#else
pRegBase = (PUCHAR)UART1_BASE;
pHWHead->s2410SerReg = (S2410_UART_REG *)pRegBase;
#endif
}
else if(pHWHead1->dwIOBase == 0x50008000)
{
pHWHead->bINT = BIT_UART2;
pHWHead->bTxINT = INTSUB_TXD2;
pHWHead->bRxINT = INTSUB_RXD2;
pHWHead->bErrINT = INTSUB_ERR2;
#if USEVIRTUAL
pHWHead->s2410SerReg = (S2410_UART_REG *)v_pUART2regs;
pRegBase = (PUCHAR)pHWHead->s2410SerReg;
#else
pRegBase = (PUCHAR)UART2_BASE;
pHWHead->s2410SerReg = (S2410_UART_REG *)pRegBase;
#endif
}
else
{
pHWHead->bINT = BIT_UART0;
pHWHead->bTxINT = INTSUB_TXD0;
pHWHead->bRxINT = INTSUB_RXD0;
pHWHead->bErrINT = INTSUB_ERR0;
#if USEVIRTUAL
pHWHead->s2410SerReg = (S2410_UART_REG *)v_pUART0regs;
pRegBase = (PUCHAR)pHWHead->s2410SerReg;
#else
pRegBase = (PUCHAR)UART0_BASE;
pHWHead->s2410SerReg = (S2410_UART_REG *)pRegBase;
#endif
}
再搜索:
if ( pHWHead->UseIrDA )
{
pHWHead->pUFTXH = (volatile unsigned char *)(v_pUART2regs->rUTXH);
pHWHead->pUFRXH = (volatile unsigned char *)(v_pUART2regs->rURXH);
}
else
{
把這其中的代碼修改為以下代碼
}
if(pHWHead1->dwIOBase == 0x50004000)
{
pHWHead->pUFTXH = (volatile unsigned char *)(v_pUART1regs->rUTXH);
pHWHead->pUFRXH = (volatile unsigned char *)(v_pUART1regs->rURXH);
}
else if(pHWHead1->dwIOBase == 0x50008000)
{
pHWHead->pUFTXH = (volatile unsigned char *)(v_pUART2regs->rUTXH);
pHWHead->pUFRXH = (volatile unsigned char *)(v_pUART2regs->rURXH);
}
else
{
pHWHead->pUFTXH = (volatile unsigned char *)(v_pUART0regs->rUTXH);
pHWHead->pUFRXH = (volatile unsigned char *)(v_pUART0regs->rURXH);
}
4、打開ser2410_ser.c文件。
搜索:
const HWOBJ IoObj = {
THREAD_AT_INIT,
SYSINTR_SERIAL,
(PHW_VTBL) IoVTbl
};
在其后面添加:
const HWOBJ Io1Obj = {
THREAD_AT_INIT,
SYSINTR_SERIAL1,
(PHW_VTBL) IoVTbl
};
const HWOBJ Io2Obj = {
THREAD_AT_INIT,
SYSINTR_IR,
(PHW_VTBL) IoVTbl
};
接著搜索:
const PCHWOBJ HWObjects[] = {
IoObj,
IrObj
};
將其修改為:
const PCHWOBJ HWObjects[] = {
IoObj,
Io1Obj,
Io2Obj
};
再搜索:
GetSerialObject(
DWORD DeviceArrayIndex
)
將其函數(shù)改為:
{
PHWOBJ pSerObj;
DEBUGMSG(DEBUGMODE,(TEXT(GetSerialObject : DeviceArrayIndex = %d ), DeviceArrayIndex));
// Now return this structure to the MDD.
if ( DeviceArrayIndex == 2 )
{
RETAILMSG(1,(TEXT(GetSerialObject Io2Obj )));
pSerObj = (PHWOBJ)(Io2Obj);
}
else if(DeviceArrayIndex == 1)
pSerObj = (PHWOBJ)(Io1Obj);
else
pSerObj = (PHWOBJ)(IoObj);
return (pSerObj);
}
5、打開cfw.c文件,這就是中斷處理。
搜索:
BOOL
OEMInterruptEnable(DWORD idInt, // @parm Interrupt ID to be enabled. See
LPVOID pvData, // @parm ptr to data passed in in the
DWORD cbData) // @parm Size of data pointed to be
找到這一句:case SYSINTR_SERIAL:
在其后面添加:
case SYSINTR_SERIAL1: // Serial port1.
s2410INT->rSUBSRCPND = (INTSUB_RXD1 | INTSUB_TXD1 | INTSUB_ERR1);
s2410INT->rINTSUBMSK = ~INTSUB_RXD1;
s2410INT->rINTSUBMSK = ~INTSUB_TXD1;
s2410INT->rINTSUBMSK = ~INTSUB_ERR1;
s2410INT->rSRCPND = BIT_UART1;
// S3C2410X Developer Notice (page 4) warns against writing a 1 to a 0 bit in the INTPND register.
if (s2410INT->rINTPND BIT_UART1) s2410INT->rINTPND = BIT_UART1;
評(píng)論