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 29 Mar 2006 01:40 PM by  mikea@logicpd.com
GPIO
 5 Replies
Sort:
You are not authorized to post a reply.
Author Messages
mmcclure@keydevices.com
New Member
New Member
Posts:


--
19 Oct 2005 04:12 PM
    Is there any sample code available for reading/writing to GPIO's using this dev board? PWM?

    We are looking to try to bit bang some low speed SPI devices.


    Regards
    Anonymous
    Posts:


    --
    19 Oct 2005 06:48 PM
    Hello,

    Logic has a sample application posted here:

    http://www.logicpd.com/do...pplication_2_0_3.zip

    This application will blink the LED on the SDK Baseboard on GPIO1.

    Please post back here with any issues that you might encounter.

    Thank you,
    mmcclure@keydevices.com
    New Member
    New Member
    Posts:


    --
    20 Oct 2005 01:16 PM
    That is helpful, thanks. Would you happen to have any examples available for Windows CE/mobile using embedded C++ or .NET?
    Anonymous
    Posts:


    --
    21 Oct 2005 05:41 PM
    Hi Mcclmark,

    The closest thing available to your request would be the example Foo Driver:

    http://www.logicpd.com/do...FOO_tag_50_1_1_0.zip

    Regards,
    mikea@logicpd.com
    New Member
    New Member
    Posts:


    --
    24 Mar 2006 07:42 AM
    Check out the sample application on our download site, which is a Windows CE app: http://www.logicpd.com/downloads/637/

    If you want to blink the LED (GPIO1) on the PXA270 Zoom SDK board, try this:

    #include <windows.h>
    #include <ceddk.h>


    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
    {
    int i;
    PHYSICAL_ADDRESS phy_addr;
    volatile unsigned short *cpld_gpio_reg;

    /* Place the physical address of the register in the low part. */
    phy_addr.LowPart = 0x08000030; //PXA270 Card Engine CPLD GPIO Register
    phy_addr.HighPart = 0;

    /* Call the CEDDK MmMapIoSpace function to retrieve a virtual address */
    cpld_gpio_reg = (volatile unsigned short *)MmMapIoSpace(phy_addr, sizeof(*cpld_gpio_reg), FALSE);

    /* verify that the physical address was successfully mapped to a virtual address */
    if(NULL == cpld_gpio_reg)
    RETAILMSG(1,(TEXT("Error, couldn't map cpld_gpio_reg.\r\n")));
    else
    RETAILMSG(1,(TEXT("Mapped cpld_gpio_reg at 0x%x to 0x%x.\r\n"), phy_addr.LowPart, cpld_gpio_reg));

    *cpld_gpio_reg &= 0xFFBF; //Put GPIO as output

    /* Blink LED 10 times */
    i=0;
    while(i<10)
    {
    *cpld_gpio_reg &= 0xFFEF; //Put GPIO low - LED on
    Sleep(100);
    *cpld_gpio_reg |= 0x0010; //Put GPIO high - LED off
    Sleep(100);
    i++;
    }

    MmUnmapIoSpace((void*)cpld_gpio_reg, sizeof(*cpld_gpio_reg));

    return 0;

    } /* end WinMain() */


    Be sure to include the followings libraries:
      coredll.lib
      ceddk.lib
    mikea@logicpd.com
    New Member
    New Member
    Posts:


    --
    29 Mar 2006 01:40 PM
    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() */
    You are not authorized to post a reply.