none
[UWP] GpioPin ValueChanged not firing RRS feed

  • Question

  • Hi,

    I am trying to add a feature about Gpio via Windows.Devices.Gpio to CameraStarterKit which is released by Microsoft.

    I am able to access the GPIO and the pin status can be read correctly.

    However, the ValueChanged event is never triggered.

    The code snippet is as below:

    _gpioController = await GpioController.GetDefaultAsync(); if (_gpioController != null) { Debug.WriteLine("Succeed to get gpio controller"); _gpioPin = _gpioController.OpenPin(1); if (_gpioPin != null) { Debug.WriteLine("Succeed to get gpiopin"); _gpioPin.SetDriveMode(GpioPinDriveMode.Input); _gpioPin.ValueChanged += GpioPin_PropertyChanged; } else { Debug.WriteLine("Failed to get gpiopin"); } } else { Debug.WriteLine("Failed to get gpio controller"); }

    private void GpioPin_PropertyChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
    {
        Debug.WriteLine("GpioPin triggered");
    }

    The target version is set to Windows 10 Pro build 16299 and rhproxy is also enabled following the guidance - Enable usermode access to GPIO, I2C, and SPI.

    The UEFI code is as below:

    Device(RHPX)
    {
        Name(_HID, "MSFT8000")
        Name(_CID, "MSFT8000")
        Name(_UID, 1)
    
        Name(_CRS, ResourceTemplate()
        {
            GpioIO(Shared, PullUp, , , , "\\_SB.GPO0", , , , ) { 28 }  //GPIO_28 Volume Down
            GpioInt(Edge, ActiveBoth, Shared, PullUp, 0, "\\_SB.GPO0",) { 28 }
    
            GpioIO(Shared, PullUp, , , , "\\_SB.GPO0", , , , ) { 29 }  //GPIO_29 Volume Up
            GpioInt(Edge, ActiveBoth, Shared, PullUp, 0, "\\_SB.GPO0",) { 29 }
        })
    }
    
    Did I miss something?

    Wednesday, October 2, 2019 9:44 AM

All replies

  • Hi,

    There is an official sample about Gpio here:IoT-GPIO, I suggest you could take a look at the scenario 2 which also uses the valuechanged event to see if it works.

    Best regards,

    Roy


    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, October 3, 2019 2:41 AM
  • Hi Roy,

    I just tried the sample but the target platform is set to Windows IoT Core.

    The OS I use is Window 10 Pro 1803 so I cannot run the sample on my machine.


    • Edited by Petercoin Thursday, October 3, 2019 3:35 AM
    Thursday, October 3, 2019 3:08 AM
  • Hello Petercoin,

    Have you checked the Pin number on your device? In your code, the Pin number is Pin 1. Is it the right to use. Which device did you test your app? You might to check the datasheet of your device.

    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.

    Tuesday, October 8, 2019 2:55 AM
    Moderator
  • Hi Michael,

    I used Apollo Lake on Windows 10 Pro 1803.

    The GPIO Read(), Write() and SetDriveMode() worked fine except for pin ValueChanged event.

    Now, I used a task to periodically poll pin status and it can achieve my goal.

    However, I think the native way provided by Gpio namespace would be better than mine.


    Wednesday, October 9, 2019 7:18 AM