none
Reading GPIO in bootloader RRS feed

  • Question

  • I am really new to Windows CE so please bear with me.

    I am running Windows CE on an IMx6 chip. I am trying to read button states during the bootloader stages to set the device to a different state.

    Is there a gpio library that I can generally call anywhere during bootloader? I have been trying to call the functions in common_ddk.h (DDK = Device Driver kit) but I am getting errors.

    Sorry if my question is a bit vague.

    Sunday, September 2, 2018 7:19 PM

Answers

  • Thanks for responding.

    So do I just call the 3 functions (step 1)?

    In iMX6 pins are mux'ed: the same pin can be configured to do different things.

    You need to get iMX6 manual, find your pin there and configure it for GPIO using above OAL macros.

    Then you can read your pin as a GPIO.

    I would recommend searching your BSP for code examples.

    Wednesday, September 5, 2018 11:13 AM
  • DDK library don't work in bootloader.

    1. You need OAL macros to configure your PAD correctly (assuming the state is unknown/not yet configured).

    OAL_IOMUX_SET_MUX

    OAL_IOMUX_SET_PAD

    OAL_IOMUX_SELECT_INPUT

    2. Then you need to configure GPIO for reading (once) and read. Use direct register access for that.

    An example of reading pin 8 from GPIO5 (assumes PAD, INPUT, MUX were configured before):

    PCSP_GPIO_REGS  pGPIO5; // Address to GPIO registers

    UINT32 myData;

    pGPIO5 = (PCSP_GPIO_REGS) OALPAtoUA(CSP_BASE_REG_PA_GPIO5); // Get UA for GPIO5 using PA

    CLRREG32(&pGPIO5->GDIR, GPIO_PIN_MASK(8)); //  Configure input register for reading

    myData = (INREG32(&pGPIO5->DR) & GPIO_PIN_MASK(8)); // Read data register and mask all except bit 8

    Hope this help.

    Monday, September 3, 2018 9:53 AM

All replies

  • DDK library don't work in bootloader.

    1. You need OAL macros to configure your PAD correctly (assuming the state is unknown/not yet configured).

    OAL_IOMUX_SET_MUX

    OAL_IOMUX_SET_PAD

    OAL_IOMUX_SELECT_INPUT

    2. Then you need to configure GPIO for reading (once) and read. Use direct register access for that.

    An example of reading pin 8 from GPIO5 (assumes PAD, INPUT, MUX were configured before):

    PCSP_GPIO_REGS  pGPIO5; // Address to GPIO registers

    UINT32 myData;

    pGPIO5 = (PCSP_GPIO_REGS) OALPAtoUA(CSP_BASE_REG_PA_GPIO5); // Get UA for GPIO5 using PA

    CLRREG32(&pGPIO5->GDIR, GPIO_PIN_MASK(8)); //  Configure input register for reading

    myData = (INREG32(&pGPIO5->DR) & GPIO_PIN_MASK(8)); // Read data register and mask all except bit 8

    Hope this help.

    Monday, September 3, 2018 9:53 AM
  • Thanks for responding.

    So do I just call the 3 functions (step 1)?

    Tuesday, September 4, 2018 3:33 PM
  • Thanks for responding.

    So do I just call the 3 functions (step 1)?

    In iMX6 pins are mux'ed: the same pin can be configured to do different things.

    You need to get iMX6 manual, find your pin there and configure it for GPIO using above OAL macros.

    Then you can read your pin as a GPIO.

    I would recommend searching your BSP for code examples.

    Wednesday, September 5, 2018 11:13 AM