Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Devices.Gpio declaration #1638

Merged
merged 1 commit into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions src/PAL/Include/CPU_GPIO_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
63 changes: 25 additions & 38 deletions src/Windows.Devices.Gpio/win_dev_gpio_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,32 @@
#include <nanoCLR_Checks.h>
#include <nf_rt_events_native.h>

///////////////////////////////////////////////////////////////////////////////////
// !!! 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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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_
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down