代码怎么贴成这样子,再试试:
[code][///Track3 CLK eint8
dwSysIntr_Track3 = SYSINTR_NOP;
dwHwIntr[0] = -1;
dwHwIntr[1] = OAL_INTR_FORCE_STATIC;
dwHwIntr[2] = IRQ_EINT8;
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &dwHwIntr, sizeof(dwHwIntr), &dwSysIntr_Track3, sizeof(DWORD), NULL))
{
RETAILMSG(MAG_DUG,(TEXT("[MAG] Failed to request dwSysIntr_Track3!\r\n")));
dwSysIntr_Track3 = SYSINTR_UNDEFINED;
return FALSE;
}
//Track2 CLK eint9
dwSysIntr_Track2 = SYSINTR_NOP;
dwHwIntr[0] = -1;
dwHwIntr[1] = OAL_INTR_FORCE_STATIC;
dwHwIntr[2] = IRQ_EINT9;
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &dwHwIntr, sizeof(dwHwIntr), &dwSysIntr_Track2, sizeof(DWORD), NULL))
{
RETAILMSG(MAG_DUG,(TEXT("[MAG] Failed to request dwSysIntr_Track2!\r\n")));
dwSysIntr_Track2 = SYSINTR_UNDEFINED;
return FALSE ;
}
/*if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, dwHwIntr, sizeof(dwHwIntr), &dwSysIntr_DoubleTrack, sizeof(DWORD), NULL))
{
RETAILMSG(MAG_DUG,(TEXT("[MAG] Failed to request the EINT8、ENT9 sysintr for Doubletrack.\n")));
dwSysIntr_DoubleTrack = SYSINTR_UNDEFINED;
bResult = FALSE;
}*/
hEvent_DoubleTrack = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!InterruptInitialize(dwSysIntr_Track3, hEvent_DoubleTrack, NULL, 0))
{
RETAILMSG(MAG_DUG,(TEXT("[MAG] dwSysIntr_Track3 Interrupt Initialization failed!!!\n")));
bResult = FALSE;
}
if (!InterruptInitialize(dwSysIntr_Track2, hEvent_DoubleTrack, NULL, 0))
{
RETAILMSG(MAG_DUG,(TEXT("[MAG] dwSysIntr_Track2 Interrupt Initialization failed!!!\n")));
bResult = FALSE;
}
hThread_DoubleTrack = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)ThreadFor_DoubleTrack, 0, 0, (LPDWORD)&dwThreadId_DoubleTrack);
if (hThread_DoubleTrack == NULL)
{
RETAILMSG(MAG_DUG,(TEXT("[MAG] Thread of DoubleTrack creation error!!!\n")));
bResult = FALSE;
}]
IST如下:
[code][/while(1)
{
ret = WaitForSingleObject(hEvent_DoubleTrack, INFINITE);
if((ret==WAIT_OBJECT_0) && (g_KillDoubleThreadTrack==FALSE))
{
//RETAILMSG(MAG_DUG,(TEXT("ret==WAIT_OBJECT_0!!!\r\n")));
if (!(pGPIOregs->GPNDAT & IOSTAT_EINT8)) //EINT8 is active----->Track3
{
RETAILMSG(MAG_DUG,(TEXT("EINT8 is active----->Track3\r\n")));
if((!(pGPIOregs->GPKDAT & CP_LOW)) && (g_pBrushCard->primal_num_track3 < 1000))
{
g_pBrushCard->card_data_track3[g_pBrushCard->primal_num_track3++] = (char)(pGPIOregs->GPKDAT & TRACK3); //读出GPK2 bit
}
InterruptDone(dwSysIntr_Track3);
}
if (!(pGPIOregs->GPNDAT & IOSTAT_EINT9)) //EINT9 is active----->Track2
{
RETAILMSG(MAG_DUG,(TEXT("EINT9 is active----->Track2\r\n")));
if((!(pGPIOregs->GPKDAT & CP_LOW)) && (g_pBrushCard->primal_num_track2 < 300))
{
g_pBrushCard->card_data_track2[g_pBrushCard->primal_num_track2++] = (char)(pGPIOregs->GPKDAT & TRACK2); //读出GPK3 bit
}
InterruptDone(dwSysIntr_Track2);
}
}
}]
这是google代码搜索里找的一个示例,可以参考一下。
//---------------------------------------------------------------------
// WriteDiskSector: Write disk sector (512 bytes) in Windows
//---------------------------------------------------------------------
extern "C" BOOL WriteDiskSector(int drive, DWORD startinglogicalsector, int numberofsectors, BYTE *buffer)
{
HANDLE hDevice;
DWORD byteswritten;
// Creating a handle to drive a: using CreateFile () function ..
char _devicename[] = "\\\\.\\PhysicalDrive0";
_devicename[17] += drive;
hDevice = CreateFile(_devicename, // drive to open
GENERIC_READ|GENERIC_WRITE, // access type
FILE_SHARE_READ | // share mode
FILE_SHARE_WRITE,
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // do not copy file attributes
if (hDevice == INVALID_HANDLE_VALUE)
return FALSE;
DiskFileSeek(hDevice, (startinglogicalsector),FILE_BEGIN);
if (!WriteFile (hDevice, buffer, 512*numberofsectors, &byteswritten, NULL) )
return FALSE;
CloseHandle(hDevice);
return TRUE;
}
复制代码