📄 test_appdriver.cpp
字号:
// Test_AppDriver.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <windows.h>
#include <ceddk.h>
#define S3C2410X_BASE_REG_PA_UART0 (0x50000000)
#define S3C2410X_BASE_REG_PA_UART1 (0x50004000)
#define S3C2410X_BASE_REG_PA_UART2 (0x50008000)
typedef struct {
UINT32 ULCON; // line control reg
UINT32 UCON; // control reg
UINT32 UFCON; // FIFO control reg
UINT32 UMCON; // modem control reg
UINT32 UTRSTAT; // tx/rx status reg
UINT32 UERSTAT; // rx error status reg
UINT32 UFSTAT; // FIFO status reg
UINT32 UMSTAT; // modem status reg
UINT32 UTXH; // tx buffer reg
UINT32 URXH; // rx buffer reg
UINT32 UBRDIV; // baud rate divisor
} S3C2410X_UART_REG, *PS3C2410X_UART_REG;
volatile S3C2410X_UART_REG *g_pUARTReg;
VOID WriteSerialByte(PCHAR string, int numberofchars)
{
for (int i=0; i<numberofchars; i++)
{
while(((g_pUARTReg->UTRSTAT) & 0x02) == 0);
g_pUARTReg->UTXH = (UINT32) string[i];
}
return;
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
DWORD dwRet = 0;
// PHYSICAL_ADDRESS PA;
CHAR string[] = "\r\n Test AppDriver :: Windows Embedded CE 6.0 !!! \r\n";
RETAILMSG(1,(TEXT("Test Application Driver :: Initialize Memory for Serial port \r\n")));
// Initialize memory for Serial port (Debug port)
/*
PA.QuadPart = S3C2410X_BASE_REG_PA_UART1;
g_pUARTReg =(volatile S3C2410X_UART_REG *) MmMapIoSpace(PA, sizeof(S3C2410X_UART_REG), FALSE);
if(!g_pUARTReg)
{
RETAILMSG(1,(TEXT("Test Application Driver :: Memory for Serial port Initialize Failed !!!\r\n")));
return dwRet;
}
*/
g_pUARTReg = (volatile S3C2410X_UART_REG *)VirtualAlloc(0, sizeof *g_pUARTReg, MEM_RESERVE, PAGE_NOACCESS);
if (g_pUARTReg == NULL)
{
RETAILMSG(1,(TEXT("Test Application Driver :: VirtualAlloc failed for Serial port !\r\n")));
}
else
{
if (!VirtualCopy((PVOID)g_pUARTReg, (PVOID)(S3C2410X_BASE_REG_PA_UART1 >> 8), sizeof *g_pUARTReg, PAGE_PHYSICAL | PAGE_READWRITE | PAGE_NOCACHE))
{
RETAILMSG(1,(TEXT("TTest Application Driver :: VirtualCopy failed for Serial port !\r\n")));
VirtualFree((PVOID)g_pUARTReg, 0, MEM_RELEASE);
g_pUARTReg = NULL;
}
}
dwRet=1;
WriteSerialByte(string, sizeof(string));
return dwRet;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -