Search code examples
c#uwpwindows-10-iot-core

How to enable LightningProviders for GPIO?


I am trying to access the GPIO on my custom SBC using Windows 10 IoT Core. I have discovered that I must use LightningProviders to accomplish this . So I tried to follow this guide to use lightning providers properly.

I used very simple code:

            if (LightningProvider.IsLightningEnabled)
            {
                LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
            }
            GpioStatus = "Initializing...";
            var gpio = GpioController.GetDefault();
            if (gpio == null)
            {
                GpioStatus = "There is no GPIO controller on this device.";
            }
            else
            {
                gpio.OpenPin(1).Write(GpioPinValue.High);
                GpioStatus = gpio.OpenPin(1).Read().ToString();
            }

Where GpioStatus is output text on a UI.

I discovered that if I run the LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider(); line outside of the enabled check, it picks up the GPIO controller and lets me detect how many pins I have and read them (All low). However I can't change the DriveMode or write to the pins without error. The error I get just says to Make sure the LightningProviders are enabled.

This brings me back to the guide I linked at the start. It suggests to enable DMAP drivers using the Device Portal for W10IoT or DMAPUtil.exe. I have tried both. In the Device Portal the area where it should be is just blank. And in the command line trying to use the DMAPUtil.exe only returns that dmaputil.exe is not available on this system.

Therefore I am asking if there is any other way to enable the LightningProviders or if there a way to know if they are incompatible with my board?

Thanks!

UPDATE

Also tried using the devcon.exe commands in the W10IoT Command line. I am able to locate the Direct memory access controller but when i do devcon.exe enable *PNP0200 it says it is enabled but remains disabled when checked with devcon.exe status *PNP0200


Solution

  • Please confirm if you have added the IOT_DMAP_DRIVER feature in your OEMInput.xml, this feature will add the DMAP driver in the image. If IOT_DMAP_DRIVER is removed from the OEMInput.xml, the Default Driver Controller will be blank in device protal, and dmaputil will be not available on Windows IoT Core. Please see the IoT Core feature list.

    Update:

    You can download the source of Lighting Provider, and then deploy and debug in your custom image.