// yc2440test.cpp : Defines the entry point for the application.
//
#include "windows.h"
#include <ceddk.h>
#include <nled.h>
#include "resource.h"
#include "winceKBhook.h"
BOOL CALLBACK DialogProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
//------------------------------------------------------------------------------
// External Functions
//------------------------------------------------------------------------------
// External Variables
//------------------------------------------------------------------------------
// Defines
#define NLED_MAX_LED_CETK 7
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
// Global Variables
//
// Holds the open file handle to NLeddrvr driver
HANDLE g_hNLeddrvr = NULL;
HWND hDialogWnd = NULL;
//------------------------------------------------------------------------------
// Local Variables
static UINT g_cLEds = 0;
static BOOL ledThreadRunning = FALSE;
static HANDLE hLedThread = NULL;
static UINT currStyle = 0;
static UINT KBDMAP[][2]={
{IDC_K1,38},
{IDC_K2,39},
{IDC_K3,40},
{IDC_K4,37},
{IDC_K5,27},
{IDC_K6,13}
};
//------------------------------------------------------------------------------
// Local Functions
//------------------------------------------------------------------------------
//
// Function: InitializeTests
//
// This function initializes the set of tests. It maps the memory to the
// registers.
//
// Parameters:
// None.
//
// Returns:
// TRUE if the memory map succeeds; FALSE if the memory map fails.
//
//------------------------------------------------------------------------------
static BOOL InitializeTests(void)
{
UINT32 bytesWritten=0;
g_hNLeddrvr = CreateFile(TEXT("NLD1:"), // name of device
GENERIC_READ | GENERIC_WRITE, // desired access
FILE_SHARE_READ | FILE_SHARE_WRITE, // sharing mode
NULL, // security attributes (ignored)
OPEN_EXISTING, // creation disposition
FILE_FLAG_RANDOM_ACCESS, // flags/attributes
NULL); // template file (ignored)
if (g_hNLeddrvr == NULL) {
RETAILMSG(1,(TEXT("main.cpp: InitializeTests():CreateFile(NLeddrvr): Unable to open file! \r\n")));
return 0;
}
return TRUE;
}
//------------------------------------------------------------------------------
//
// Function: FinishTests
//
// This function performs the clean up after the tests have finished.
//
// Parameters:
// None.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
static VOID FinishTests(void)
{
// Close the file handle
if (g_hNLeddrvr != NULL) {
CloseHandle(g_hNLeddrvr);
RETAILMSG(1,(TEXT("main.cpp: FinishTests():CloseHandle(NLeddrvr): Closed file handle! \r\n")));
}
if(hLedThread)
{
CloseHandle(hLedThread);
hLedThread = NULL;
}
}
//------------------------------------------------------------------------------
//
// Function: NLeddrvrGetCountInfoTest
//
// Get the total number of Notification LED(s) supported in system
//
// Parameters:
// uiMsg
// [in] to determine if the shell wants to execute the test.
// tpParam
// [in] Ignored.
// lpFTE
// [in] Ignored.
//
// Returns:
// Specifies if the test passed (TPR_PASS), failed (TPR_FAIL)
//
//------------------------------------------------------------------------------
int NLeddrvrGetCountInfoTest(UINT uMsg)
{
UINT nId = NLED_COUNT_INFO_ID;
NLED_COUNT_INFO NledCountInfo = {0};
if (!DeviceIoControl(
g_hNLeddrvr, // file handle to the driver
IOCTL_NLED_GETDEVICEINFO, // I/O control code
&nId, // in buffer
sizeof(UINT), // in buffer size
&NledCountInfo, // out buffer
sizeof(NLED_COUNT_INFO), // out buffer size
0, // number of bytes returned
NULL
)) {
return -1;
}
if (!NledCountInfo.cLeds) {
return -1;
}
g_cLEds = NledCountInfo.cLeds;
return 0;
}
//------------------------------------------------------------------------------
//
// Function: NLeddrvrGetSupportsInfoTest
//
// Get Notification LED(s) supports information
//
// Parameters:
// uiMsg
// [in] to determine if the shell wants to execute the test.
// tpParam
// [in] Ignored.
// lpFTE
// [in] Ignored.
//
// Returns:
// Specifies if the test passed (TPR_PASS), failed (TPR_FAIL)
//
//------------------------------------------------------------------------------
int NLeddrvrGetSupportsInfoTest(UINT uMsg)
{
if (!g_cLEds) {
return -1;
}
UINT nId = NLED_SUPPORTS_INFO_ID;
NLED_SUPPORTS_INFO NledSupportsInfo[NLED_MAX_LED_CETK] = {0, 0, 0, 0, 0, 0, 0};
for (UINT i=0; i<g_cLEds; i++) {
NledSupportsInfo[i].LedNum = i;
if (!DeviceIoControl(
g_hNLeddrvr, // file handle to the driver
IOCTL_NLED_GETDEVICEINFO, // I/O control code
&nId, // in buffer
sizeof(UINT), // in buffer size
&NledSupportsInfo[i], // out buffer
sizeof(NLED_SUPPORTS_INFO), // out buffer size
0, // number of bytes returned
NULL
)) {
return -1;
}
}
return 0;
}
//------------------------------------------------------------------------------
//
// Function: NLeddrvrOnTest
//
// Set Notification LED(s) to 'Off' state
//
// Parameters:
// uiMsg
// [in] to determine if the shell wants to execute the test.
// tpParam
// [in] Ignored.
// lpFTE
// [in] Ignored.
//
// Returns:
// Specifies if the test passed (TPR_PASS), failed (TPR_FAIL)
//
//------------------------------------------------------------------------------
int GetLedStatus(int index)
{
NLED_SETTINGS_INFO NledGettingsInfo;
UINT nId = NLED_SETTINGS_INFO_ID;
NledGettingsInfo.LedNum = index;
if (!DeviceIoControl(
g_hNLeddrvr, // file handle to the driver
IOCTL_NLED_GETDEVICEINFO, // I/O control code
&nId, // in buffer
sizeof(UINT), // in buffer size
&NledGettingsInfo, // out buffer
sizeof(NLED_SETTINGS_INFO), // out buffer size
0, // number of bytes returned
NULL
)) {
return 0;
}
return NledGettingsInfo.OffOnBlink;
}
int NLeddrvrOnTest(UINT uMsg)
{
if (!g_cLEds) {
return -1;
}
UINT nId = NLED_SETTINGS_INFO_ID;
int RetVal = IDNO;
NLED_SETTINGS_INFO NledSettingsInfo[NLED_MAX_LED_CETK] = {0, 0, 0, 0, 0, 0, 0};
NLED_SETTINGS_INFO NledSetInfoCmp[NLED_MAX_LED_CETK] = {0, 0, 0, 0, 0, 0, 0};
/* for (UINT i=0; i<g_cLEds; i++)*/UINT i=uMsg; { // Set LED(s) to 'On'
NledSettingsInfo[i].LedNum = i;
NledSettingsInfo[i].OffOnBlink = 1;
if (!DeviceIoControl(
g_hNLeddrvr, // file handle to the driver
IOCTL_NLED_SETDEVICE, // I/O control code
&NledSettingsInfo[i], // in buffer
sizeof(NLED_SETTINGS_INFO), // in buffer size
NULL, // out buffer
0, // out buffer size
0, // number of bytes returned
NULL
)) {
return -1;
}
NledSetInfoCmp[i].LedNum = i;
if (!DeviceIoControl(
g_hNLeddrvr, // file handle to the driver
IOCTL_NLED_GETDEVICEINFO, // I/O control code
&nId, // in buffer
sizeof(UINT), // in buffer size
&NledSetInfoCmp[i], // out buffer
sizeof(NLED_SETTINGS_INFO), // out buffer size
0, // number of bytes returned
NULL
)) {
return -1;
}
if (NledSetInfoCmp[i].OffOnBlink != NledSettingsInfo[i].OffOnBlink) {
return -1;
}
}
return 0;
}
//------------------------------------------------------------------------------
//
// Function: NLeddrvrBlinkTest
//
// Set Notification LED(s) to 'Blink' state with specified 'On' and 'Off' times.
//
// Parameters:
// uiMsg
// [in] to determine if the shell wants to execute the test.
// tpParam
// [in] Ignored.
// lpFTE
// [in
评论2
最新资源