Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 04 Apr 2012 11:08 AM by  glennj@logicpd.com
Article: PXA270 -- Example WinCE GPIO code
 0 Replies
Sort:
You are not authorized to post a reply.
Author Messages
glennj@logicpd.com
New Member
New Member
Posts:


--
04 Apr 2012 11:08 AM
    Q: Is there example WinCE GPIO code for the PXA270 to toggle a pin?

    A:
    Yes. See the example below for the pin on J38, Pin 37.
    *******************************************
    #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)
    *
    * Library needs:
    * - ceddk.lib
    * - coredll.lib
    */


    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() */

    ***********************

    Product Included:
    PXA270
    You are not authorized to post a reply.