GPIO working on Ixora with Apalis IMX6D with Wince

I have Ixora Board V1.3A with me connected with Apalis IMX6D 1GB V1.1C module with WinCE7.

I want to make the GPIOs of the Ixora Board work for my application, for which I am trying to test with LED4_RED on Ixora board connected to Pin no.178.

I am using vs2008 and TdxAllLibrariesDll.dll file for CE600(ARMv4l) for making it work using DLLImport.

But somehow, I am not able to achieve the same.

Following is the code snippet for the same.

Can somebody please guide on the same, why is it not working

namespace ASA_DemoToradex
{
public partial class Form1 : CcForm
{
public static class IoHelper
{
public static uIo APALIS_PIN(ushort number)
{
return new uIo
{
Number = number,
Type = tIoType.ioApalisPin
};
}
}

    [DllImport("TdxAllLibrariesDll.dll",CharSet = CharSet.Auto)]    ///< Importing DLL
    public static extern IntPtr Imx6Gpio_Init(string registryPath);   ///< External function declaration

    [DllImport("TdxAllLibrariesDll.dll", CharSet = CharSet.Auto)]
    public static extern void Imx6Gpio_SetDir(IntPtr hGpio, uIo io, tIoDirection dir);

    [DllImport("TdxAllLibrariesDll.dll", CharSet = CharSet.Auto)]
    public static extern void Imx6Gpio_SetLevel(IntPtr hGpio, uIo io, tIoLevel val);

    [DllImport("TdxAllLibrariesDll.dll", CharSet = CharSet.Auto)]
    public static extern void Imx6Gpio_ConfigureAsGpio(IntPtr hGpio, uIo io);

    [DllImport("TdxAllLibrariesDll.dll")]
    public static extern bool Imx6Gpio_Open(IntPtr hGpio);

        IntPtr hGpio = Gpio_Init(null);

        // For Ixora Board Test LEDs

        uIo LED4_RED = IoHelper.APALIS_PIN(178);
            
	 Imx6Gpio_Open(hGpio);
            System.Threading.Thread.Sleep(1000);
            Imx6Gpio_ConfigureAsGpio(hGpio, LED4_RED);
            Imx6Gpio_SetDir(hGpio, LED4_RED, tIoDirection.ioOutput);

            System.Threading.Thread.Sleep(1000);
            Imx6Gpio_SetLevel(hGpio, LED4_RED, tIoLevel.ioHigh);
            System.Threading.Thread.Sleep(1000);
            Imx6Gpio_SetLevel(hGpio, LED4_RED, tIoLevel.ioLow);
}

}

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for your question regarding the use of GPIOs on the Ixora V1.3A carrier board with an Apalis iMX6D running Windows CE 7.

Let’s go through your setup and code for controlling the LED4_RED (Ixora pin 178):

Key Points to Check

1. Using the Correct Library Functions

In your code, you declare and use Imx6Gpio_* functions from TdxAllLibrariesDll.dll, but then you call Gpio_Init(null). This is likely a typo or leftover from older libraries. You should only use Imx6Gpio_Init like this:

IntPtr hGpio = Imx6Gpio_Init(null);

Make sure to replace Gpio_Init(null) with Imx6Gpio_Init(null) in your code.

2. Initialization and Library Usage Order

To control a GPIO pin, the general sequence is:

  1. Initialize the library (Imx6Gpio_Init).
  2. Optionally open the GPIO driver (Imx6Gpio_Open(hGpio)).
  3. Configure the pin as GPIO (Imx6Gpio_ConfigureAsGpio(hGpio, LED4_RED)).
  4. Set its direction (Imx6Gpio_SetDir(hGpio, LED4_RED, tIoDirection.ioOutput)).
  5. Set or clear the pin (Imx6Gpio_SetLevel).

3. Check the Pin Number

For Ixora V1.3A, LED4_RED is indeed connected to Apalis pin 178. You can cross-reference this with the Ixora V1.3 datasheet.

4. Pinmux Settings

Make sure the pin isn’t already used by another peripheral, which might override its function as a GPIO. Pinmuxing configuration can be done via registry settings in Windows CE.

5. Correct Use of Structures and Enums

Make sure you have the definitions for uIo, tIoType, tIoDirection, and tIoLevel—these usually come from the Toradex CE Libraries. Here is an example:

public enum tIoType { ioApalisPin = 0, /* ...other types...*/ }
public enum tIoDirection { ioInput = 0, ioOutput = 1 }
public enum tIoLevel { ioLow = 0, ioHigh = 1 }
[StructLayout(LayoutKind.Sequential)]
public struct uIo {
    public ushort Number;
    public tIoType Type;
}

And your helper:

public static uIo APALIS_PIN(ushort number) {
    return new uIo { Number = number, Type = tIoType.ioApalisPin };
}

6. DllImport Settings

Verify the function names in TdxAllLibrariesDll.dll and their signatures in your code match the latest manual from Toradex:
Toradex CE Libraries on GitHub

7. Copy All Required Files

Ensure that both TdxAllLibrariesDll.dll and TdxAllLibraries.cs are included in your project output and deployed to your device (Copy to Output Directory set to Copy always).

Example Working Sequence

Here’s how the code block might look:

IntPtr hGpio = Imx6Gpio_Init(null);

if (Imx6Gpio_Open(hGpio)) {
    uIo LED4_RED = IoHelper.APALIS_PIN(178);

    Imx6Gpio_ConfigureAsGpio(hGpio, LED4_RED);
    Imx6Gpio_SetDir(hGpio, LED4_RED, tIoDirection.ioOutput);

    // Turn LED on
    Imx6Gpio_SetLevel(hGpio, LED4_RED, tIoLevel.ioHigh);
    System.Threading.Thread.Sleep(1000);

    // Turn LED off
    Imx6Gpio_SetLevel(hGpio, LED4_RED, tIoLevel.ioLow);
} else {
    // Handle error opening GPIO
}

If you’re still not seeing the LED, double-check your pin assignments and dependencies (see the Ixora V1.3 datasheet), and verify there’s no other process or device tree conflicting with that GPIO.


For more details:

Let me know if you need help with any specific error message or further troubleshooting!

Best regards,
Toradex AI Assistant.

Hi @niranjandharap,

As already updated on email,
C & CSharp demos for WinCE are already available in WinCE library and Code samples SDK.
For GPIO CSharp demo , navigate to libdemos->dotNet->Gpio demo.