none
How to interact with GPIO on custom board? RRS feed

  • Question

  • Hi, I have a custom SBC that is running Windows 10 IoT (https://www.rtd.com/PC104/CM/CMA34CR/CMA34CR.htm). I am looking to access the GPIO that comes on the board (or either of the COM ports, etc). I have tried the Windows.Devices.Gpio library with the following code:

    GpioStatus = "Initializing...";
    var gpio = GpioController.GetDefault();
    if (gpio == null)
    {
        GpioStatus = "There is no GPIO controller on this device.";
    }
    else
    {
        GpioStatus = msg.ToString();
    }

    GpioStatus is the text in my UWP application. 

    gpio always comes back as null and therefore I am not sure how else to connect to the GPIO on my board. Any other ideas or things I can do? the RTD board comes with a library/drivers but I don't think they are compatible with .NET Core therefore I am not sure what to do.

    Any help would be amazing.

    Wednesday, September 11, 2019 7:01 PM

Answers

  • Hello bwhelan,

    Which driver did you use, inbox driver or DMA driver?If you use the DMA driver which offers better performances, you need to activate/declare it to the API before querying the GpioControleler.

    if (LightningProvider.IsLightningEnabled)
    {
        LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
    }
    
    var gpioController = GpioController.GetDefault();

    Best Regards,

    Micahel


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 16, 2019 3:11 AM
    Moderator

All replies

  • Hello bwhelan,

    Could you please check the Package.appxmanifest if it includes the capability for Low Level Devices? This capability is required to use APIs to access GPIO, I2C, SPI and PWM devices.

    Best Regards,

    Michael


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, September 12, 2019 1:53 AM
    Moderator
  • Just to follow-up from your previous, post does the SBC's firmware support RHPROXY?

    Sean Liming - Book Author: Starter Guide Windows 10 IoT Enterprise - www.annabooks.com / www.seanliming.com

    Thursday, September 12, 2019 3:41 AM
  • Is there a way I can check that on my own? Or should I refer to the board documentation/technical support?
    Thursday, September 12, 2019 11:10 AM
  • It didn't before, but I just enabled in and ran my code again and still says there is no GPIO controller.
    Thursday, September 12, 2019 2:54 PM
  • From my article I linked in the previous post, if you can install Windwos 10 Enterprise on the board, RHPROXY will appear in device manager. Also there are a couple of tools that can help: IASL tools (https://www.acpica.org/) or R/W Everything (http://rweverything.com/) to read the ACPI tables. 

    Going back to the manufacturer to see if they have support in the firmware might be easier.


    Sean Liming - Book Author: Starter Guide Windows 10 IoT Enterprise - www.annabooks.com / www.seanliming.com

    Thursday, September 12, 2019 4:50 PM
  • Is that present with only Enterprise? Currently using W10Iot Core. Will Enterprise open up all the access to my IO and other boards that I don't seem to be able to get right now?
    Thursday, September 12, 2019 5:13 PM
  • No. IoT Core and IoT Enterprise both have the RHPROXY device driver. The firmware has to have RHPOXY built in for the IO access to work.

    Via IoT Dashboard, you can remote into Device and see it is there. 


    Sean Liming - Book Author: Starter Guide Windows 10 IoT Enterprise - www.annabooks.com / www.seanliming.com


    Friday, September 13, 2019 2:34 AM
  • Hello bwhelan,

    Which driver did you use, inbox driver or DMA driver?If you use the DMA driver which offers better performances, you need to activate/declare it to the API before querying the GpioControleler.

    if (LightningProvider.IsLightningEnabled)
    {
        LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
    }
    
    var gpioController = GpioController.GetDefault();

    Best Regards,

    Micahel


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 16, 2019 3:11 AM
    Moderator
  • Is there a way I can check that? I have not installed any drivers. Only used whatever is on the board by default. The GPIO are part of the CPU board so I believe the drivers would be pre-installed.


    • Edited by bwhelan Monday, September 16, 2019 12:37 PM
    Monday, September 16, 2019 12:27 PM
  • I try to remote in from the IoT Dashboard like I have in the past but it keeps telling me my password is wrong, even though it doesn't ask me to put in the password. I know what it is because its just the default one for W10IOT devices. So thats very confusing. Is there another way to remote connect?
    Monday, September 16, 2019 12:28 PM
  • After getting the LightningProvider library, I was able to use

                var t = LightningGpioProvider.GetGpioProvider().GetControllers();
                var GPIOController = t[0];
    GpioStatus = GPIOController.PinCount.ToString();
    

    This picks up one GPIO controller and detects a pin count of 26. Which is exactly what I have.

    About to test setting the pins to low/high

    Monday, September 16, 2019 12:53 PM
  • was able to get gpioController to not be null and recognize how was accessible pins I have and read them. I am not able to write to them though because the LightningProvider is not enabled and I don't know how to enable it. I have tried the things outlined in my new post https://social.msdn.microsoft.com/Forums/en-US/66455b31-4d0c-4708-9a17-bcfcaeb96849/controller-driver-does-not-show-up-in-windows-10-iot-device-portal?forum=WindowsIoT#66455b31-4d0c-4708-9a17-bcfcaeb96849

    Not sure what else to do to enable them.

    Monday, September 16, 2019 7:50 PM