diff --git a/src/PAL/Include/CPU_GPIO_decl.h b/src/PAL/Include/CPU_GPIO_decl.h index 4983574324..8d485ce2b6 100644 --- a/src/PAL/Include/CPU_GPIO_decl.h +++ b/src/PAL/Include/CPU_GPIO_decl.h @@ -21,31 +21,25 @@ typedef unsigned __int64 CLR_UINT64; #define GPIO_ATTRIBUTE_ALTERNATE_B 0x08 -/////////////////////////////////////////////////////////////////////////////////////// -// !!! KEEP IN SYNC WITH Windows.Devices.Gpio.GpioPinDriveMode (in managed code) !!! // -/////////////////////////////////////////////////////////////////////////////////////// - -enum GpioPinDriveMode +// from declaration at src\Windows.Devices.Gpio\win_dev_gpio_native.h +typedef enum __nfpack GpioPinDriveMode { GpioPinDriveMode_Input = 0, - GpioPinDriveMode_InputPullDown, - GpioPinDriveMode_InputPullUp, - GpioPinDriveMode_Output, - GpioPinDriveMode_OutputOpenDrain, - GpioPinDriveMode_OutputOpenDrainPullUp, - GpioPinDriveMode_OutputOpenSource, - GpioPinDriveMode_OutputOpenSourcePullDown -}; - -/////////////////////////////////////////////////////////////////////////////////// -// !!! KEEP IN SYNC WITH Windows.Devices.Gpio.GpioPinValue (in managed code) !!! // -/////////////////////////////////////////////////////////////////////////////////// - -enum GpioPinValue + GpioPinDriveMode_InputPullDown = 1, + GpioPinDriveMode_InputPullUp = 2, + GpioPinDriveMode_Output = 3, + GpioPinDriveMode_OutputOpenDrain = 4, + GpioPinDriveMode_OutputOpenDrainPullUp = 5, + GpioPinDriveMode_OutputOpenSource = 6, + GpioPinDriveMode_OutputOpenSourcePullDown = 7, +} GpioPinDriveMode; + +// from declaration at src\Windows.Devices.Gpio\win_dev_gpio_native.h +typedef enum __nfpack GpioPinValue { - GpioPinValue_Low = 0, - GpioPinValue_High, -}; + GpioPinValue_Low = 0, + GpioPinValue_High = 1, +} GpioPinValue; enum GPIO_INT_EDGE { diff --git a/src/Windows.Devices.Gpio/win_dev_gpio_native.h b/src/Windows.Devices.Gpio/win_dev_gpio_native.h index 23e68cd65f..c184cefc01 100644 --- a/src/Windows.Devices.Gpio/win_dev_gpio_native.h +++ b/src/Windows.Devices.Gpio/win_dev_gpio_native.h @@ -12,20 +12,32 @@ #include #include -/////////////////////////////////////////////////////////////////////////////////// -// !!! KEEP IN SYNC WITH Windows.Devices.Gpio.GpioChangePolarity (in managed code) !!! // -/////////////////////////////////////////////////////////////////////////////////// - -enum GpioChangePolarity +typedef enum __nfpack GpioChangePolarity { - Both = 0, - Falling, - Rising -}; - - -/////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////// + GpioChangePolarity_Both = 0, + GpioChangePolarity_Falling = 1, + GpioChangePolarity_Rising = 2, +} GpioChangePolarity; + +// moved to src\PAL\Include\CPU_GPIO_decl.h for convinience +// typedef enum __nfpack GpioPinDriveMode +// { +// GpioPinDriveMode_Input = 0, +// GpioPinDriveMode_InputPullDown = 1, +// GpioPinDriveMode_InputPullUp = 2, +// GpioPinDriveMode_Output = 3, +// GpioPinDriveMode_OutputOpenDrain = 4, +// GpioPinDriveMode_OutputOpenDrainPullUp = 5, +// GpioPinDriveMode_OutputOpenSource = 6, +// GpioPinDriveMode_OutputOpenSourcePullDown = 7, +// } GpioPinDriveMode; + +// moved to src\PAL\Include\CPU_GPIO_decl.h for convinience +// typedef enum __nfpack GpioPinValue +// { +// GpioPinValue_Low = 0, +// GpioPinValue_High = 1, +// } GpioPinValue; struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCount { @@ -55,14 +67,6 @@ struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter }; -struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPinValueChangedEventArgs -{ - static const int FIELD___edge = 1; - - //--// - -}; - struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin { static const int FIELD_STATIC__s_eventListener = 0; @@ -102,23 +106,6 @@ struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioController }; -struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPinEvent -{ - static const int FIELD__PinNumber = 1; - static const int FIELD__Edge = 2; - - //--// - -}; - -struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPinEventListener -{ - static const int FIELD___pinMap = 1; - - //--// - -}; - extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Devices_Gpio; #endif //_WIN_DEV_GPIO_NATIVE_TARGET_H_ diff --git a/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Devices.Gpio/cpu_gpio.cpp b/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Devices.Gpio/cpu_gpio.cpp index 009e314a4e..40a3ae17ea 100644 --- a/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Devices.Gpio/cpu_gpio.cpp +++ b/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Devices.Gpio/cpu_gpio.cpp @@ -417,11 +417,13 @@ bool CPU_GPIO_DriveModeSupported(GPIO_PIN pinNumber, GpioPinDriveMode driveMode) // Output & input pins any valid drivemode if (GPIO_IS_VALID_OUTPUT_GPIO(pinNumber)) { - return (driveMode >= GpioPinDriveMode_Input && driveMode <= GpioPinDriveMode_OutputOpenSourcePullDown); + return ( + driveMode >= GpioPinDriveMode_Output && + driveMode <= GpioPinDriveMode_OutputOpenSourcePullDown); } // Input only pins only input drive modes - return (driveMode >= GpioPinDriveMode_Input && driveMode <= GpioPinDriveMode_InputPullUp); + return (driveMode <= GpioPinDriveMode_InputPullUp); } uint32_t CPU_GPIO_GetPinDebounce(GPIO_PIN pinNumber) diff --git a/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Devices.Gpio/win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter.cpp b/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Devices.Gpio/win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter.cpp index 037db2b078..febcb9307f 100644 --- a/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Devices.Gpio/win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter.cpp +++ b/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Devices.Gpio/win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter.cpp @@ -241,9 +241,18 @@ HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::Nati switch (polarity) { - case Both: countRising = true; countFalling = true; break; - case Rising: countRising = true; break; - case Falling: countFalling = true; break; + case GpioChangePolarity_Both: + countRising = true; + countFalling = true; + break; + + case GpioChangePolarity_Rising: + countRising = true; + break; + + case GpioChangePolarity_Falling: + countFalling = true; + break; } if (!InitialiseCounter(counterIndex, pinNumber, countRising, countFalling))