GPIO Just blink once

Options
PAWI
PAWI New Member Posts: 2
Hi,

I'm trying to light up a led for 10 seconds with this code
But the led only blink once very fast.

Is there a way to keep the GPIO on for several seconds

This is my code

UInt32 err = EAPI.EApiLibInitialize();
                    if (err != EAPI.EAPI_STATUS_INITIALIZED)
                    {
                        Console.WriteLine("Can't initialize the application: " + err.ToString());
                        Environment.Exit(0);
                    }
                    UInt32 nPinCount = 0;
                    UInt32 bDioDisable = 0;

                    EAPI.EApiGPIOGetCaps(EAPI.EAPI_GPIO_GPIO_ID((UInt32)relayNumber), ref nPinCount, ref bDioDisable);
                    if (bDioDisable != 0x01)
                    {
                        err = EAPI.EApiGPIOSetDirection(EAPI.EAPI_GPIO_GPIO_ID((UInt32)relayNumber), 0xFFFFFFFF, EAPI.EAPI_GPIO_OUTPUT);
                        err = EAPI.EApiGPIOSetLevel(EAPI.EAPI_GPIO_GPIO_ID((UInt32)relayNumber), 0xFFFFFFFF, EAPI.EAPI_GPIO_HIGH);
                        Console.WriteLine("Pull relay for {0} seconds.", 10);
                        System.Threading.Thread.Sleep(10000);
                        err = EAPI.EApiGPIOSetDirection(EAPI.EAPI_GPIO_GPIO_ID((UInt32)relayNumber), 0xFFFFFFFF, EAPI.EAPI_GPIO_OUTPUT);
                        err = EAPI.EApiGPIOSetLevel(EAPI.EAPI_GPIO_GPIO_ID((UInt32)relayNumber), 0xFFFFFFFF, EAPI.EAPI_GPIO_LOW);
                        Console.WriteLine("###############  COMPLETED  ##################");
                    } else
                    {
                        Console.WriteLine("###############  GPIO Disabled  ##################");
                    }

Comments

  • PAWI
    PAWI New Member Posts: 2
    edited January 2017
    Options
    I found the error!

    The UP pinout spec is incorrect.
    Use the zero based pin location instead.
    Eg if you want to use GPIO3 then you should use EAPI_GPIO_GPIO_ID(10)
    GPIO4 = 12
    GPIO5 = 14
    GPIO18 = 15
    etc.
  • Aling
    Aling Guest Posts: 561 admin
    Options
    We just got feedback from our SW team.
    *******
    In our Windows EAPI, GPIO0 should be related to EAPI_GPIO_GPIO_ID(0), GPIO1 = EAPI_GPIO_GPIO_ID(1), etc…
    I can’t figure out why the user need to use GPIO with such strange order.
    *******

    Can you specify the problem and where the error is ?