This would be an example for how to toggle GPIO110 (Card Engine MFP6 signal) in Windows CE. You can probe pin 37 on J38 on the Zoom SDK. Note,
coredll.lib and
ceddk.lib must be included when building.
The steps would be the same for any other OS.
#include <windows.h>
#include <ceddk.h>
/*
* This is a test to toggle a GPIO signal in a Windows CE application
* Platforms supported: PXA270 Card Engine
* GPIO: PXA270->GPIO110 (MFP6)
* Zoom SDK Pin: J38, pin 37
* Notes:
* - No error checking
* - No use of structures (e.g. GPIO registers)
*/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
PHYSICAL_ADDRESS phy_addr;
volatile unsigned long *pGAFR3L_reg;
volatile unsigned long *pGPDR3_reg;
volatile unsigned long *pGPCR3_reg;
volatile unsigned long *pGPSR3_reg;
volatile unsigned long *pGPLR3_reg;
/* Place the physical address of the register in the low part. */
phy_addr.LowPart = 0x40E0006C;
phy_addr.HighPart = 0;
/* Call the CEDDK MmMapIoSpace function to retrieve a pointer to a virtual address */
pGAFR3L_reg = MmMapIoSpace(phy_addr, sizeof(*pGAFR3L_reg), FALSE);
/* Place the physical address of the register in the low part. */
phy_addr.LowPart = 0x40E0010C;
phy_addr.HighPart = 0;
/* Call the CEDDK MmMapIoSpace function to retrieve a pointer to a virtual address */
pGPDR3_reg = MmMapIoSpace(phy_addr, sizeof(*pGPDR3_reg), FALSE);
/* Place the physical address of the register in the low part. */
phy_addr.LowPart = 0x40E00124;
phy_addr.HighPart = 0;
/* Call the CEDDK MmMapIoSpace function to retrieve a pointer to a virtual address */
pGPCR3_reg = MmMapIoSpace(phy_addr, sizeof(*pGPCR3_reg), FALSE);
/* Place the physical address of the register in the low part. */
phy_addr.LowPart = 0x40E00118;
phy_addr.HighPart = 0;
/* Call the CEDDK MmMapIoSpace function to retrieve a pointer to a virtual address */
pGPSR3_reg = MmMapIoSpace(phy_addr, sizeof(*pGPSR3_reg), FALSE);
/* Place the physical address of the register in the low part. */
phy_addr.LowPart = 0x40E00100;
phy_addr.HighPart = 0;
/* Call the CEDDK MmMapIoSpace function to retrieve a pointer to a virtual address */
pGPLR3_reg = MmMapIoSpace(phy_addr, sizeof(*pGPLR3_reg), FALSE);
/* Put GPIO110 as GPIO */
*pGAFR3L_reg &= 0xCFFFFFFF;
RETAILMSG(1,(TEXT("GPIO Function: %08x\r\n"),(*pGAFR3L_reg & 0x30000000))); //- only show bits 28,29
/* Put GPIO110 as Output */
*pGPDR3_reg |= 0x00004000;
RETAILMSG(1,(TEXT("GPIO Direction: %08x\r\n"),(*pGPDR3_reg & 0x00004000))); //- only show bit 14
/* Set GPIO110 Low */
*pGPCR3_reg |= 0x00004000;
RETAILMSG(1,(TEXT("GPIO status: %08x\r\n"),(*pGPLR3_reg & 0x00004000))); //- only show bit 14
/* Set GPIO110 High */
*pGPSR3_reg |= 0x00004000;
RETAILMSG(1,(TEXT("GPIO status: %08x\r\n"),(*pGPLR3_reg & 0x00004000))); //- only show bit 14
/* Cleanup memory */
MmUnmapIoSpace((void*)pGAFR3L_reg, sizeof(*pGAFR3L_reg));
MmUnmapIoSpace((void*)pGPDR3_reg, sizeof(*pGPDR3_reg));
MmUnmapIoSpace((void*)pGPCR3_reg, sizeof(*pGPCR3_reg));
MmUnmapIoSpace((void*)pGPSR3_reg, sizeof(*pGPSR3_reg));
MmUnmapIoSpace((void*)pGPLR3_reg, sizeof(*pGPLR3_reg));
return 0;
} /* end WinMain() */