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

Add GPIO ChangeCounter #1421

Merged
merged 8 commits into from
Jul 26, 2019
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
1 change: 1 addition & 0 deletions CMake/Modules/FindWindows.Devices.Gpio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(Windows.Devices.Gpio_SRCS
# class library source files
win_dev_gpio_native_Windows_Devices_Gpio_GpioController.cpp
win_dev_gpio_native_Windows_Devices_Gpio_GpioPin.cpp
win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter.cpp
win_dev_gpio_native.cpp

# core source files
Expand Down
152 changes: 85 additions & 67 deletions src/Windows.Devices.Gpio/win_dev_gpio_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,75 +10,93 @@

static const CLR_RT_MethodHandler method_lookup[] =
{
NULL,
NULL,
NULL,
NULL,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioController::get_PinCount___I4,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::Read___WindowsDevicesGpioGpioPinValue,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::Toggle___VOID,
NULL,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::DisposeNative___VOID,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeIsDriveModeSupported___BOOLEAN__WindowsDevicesGpioGpioPinDriveMode,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeSetDriveMode___VOID__WindowsDevicesGpioGpioPinDriveMode,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeInit___BOOLEAN__I4,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeSetDebounceTimeout___VOID,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::WriteNative___VOID__WindowsDevicesGpioGpioPinValue,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeSetAlternateFunction___VOID__I4,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeInit___VOID,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeRead___U8__BOOLEAN,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeStart___VOID,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeStop___VOID,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeDispose___VOID,
NULL,
NULL,
NULL,
NULL,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioController::get_PinCount___I4,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::Read___WindowsDevicesGpioGpioPinValue,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::Toggle___VOID,
NULL,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::DisposeNative___VOID,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeIsDriveModeSupported___BOOLEAN__WindowsDevicesGpioGpioPinDriveMode,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeSetDriveMode___VOID__WindowsDevicesGpioGpioPinDriveMode,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeInit___BOOLEAN__I4,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeSetDebounceTimeout___VOID,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::WriteNative___VOID__WindowsDevicesGpioGpioPinValue,
Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeSetAlternateFunction___VOID__I4,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_Windows_Devices_Gpio =
{
"Windows.Devices.Gpio",
0xF3FBAE36,
method_lookup,
{ 100, 1, 0, 0 }
"Windows.Devices.Gpio",
0xD7F65BB7,
method_lookup,
{ 100, 1, 1, 0 }
};
43 changes: 43 additions & 0 deletions src/Windows.Devices.Gpio/win_dev_gpio_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,51 @@ enum GpioPinValue
};

///////////////////////////////////////////////////////////////////////////////////
// !!! KEEP IN SYNC WITH Windows.Devices.Gpio.GpioChangePolarity (in managed code) !!! //
///////////////////////////////////////////////////////////////////////////////////

enum GpioChangePolarity
{
Both = 0,
Falling,
Rising
};


///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCount
{
static const int FIELD__Count = 1;
static const int FIELD__RelativeTime = 2;


//--//

};

struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter
{
static const int FIELD___pinNumber = 1;
static const int FIELD___inputMode = 2;
static const int FIELD___polarity = 3;
static const int FIELD___CountActive = 4;
static const int FIELD___readTime = 5;
static const int FIELD___syncLock = 6;
static const int FIELD___disposedValue = 7;

NANOCLR_NATIVE_DECLARE(NativeInit___VOID);
NANOCLR_NATIVE_DECLARE(NativeRead___U8__BOOLEAN);
NANOCLR_NATIVE_DECLARE(NativeStart___VOID);
NANOCLR_NATIVE_DECLARE(NativeStop___VOID);
NANOCLR_NATIVE_DECLARE(NativeDispose___VOID);

//--//

};


struct Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioController
{
static const int FIELD_STATIC___syncLock = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// Copyright (c) 2019 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.
//

#include "win_dev_gpio_native.h"

HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeInit___VOID( CLR_RT_StackFrame& stack )
{
(void)stack;

NANOCLR_HEADER();
{
//CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis);

//int16_t pinNumber = pThis[ FIELD___pinNumber ].NumericByRefConst().s4;
//bool InputMode = (bool)pThis[FIELD___inputMode].NumericByRefConst().u1;

NANOCLR_SET_AND_LEAVE(CLR_E_NOT_SUPPORTED);
}
NANOCLR_NOCLEANUP();
}

HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeRead___U8__BOOLEAN( CLR_RT_StackFrame& stack )
{
(void)stack;

NANOCLR_HEADER();
{
NANOCLR_SET_AND_LEAVE(CLR_E_NOT_SUPPORTED);

}
NANOCLR_NOCLEANUP();
}

HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeStart___VOID( CLR_RT_StackFrame& stack )
{
(void)stack;

NANOCLR_HEADER();
{
//CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis);

//int pinNumber = pThis[ FIELD___pinNumber ].NumericByRefConst().s4;

//GpioChangePolarity polarity = (GpioChangePolarity)pThis[ FIELD___Polarity ].NumericByRefConst().s4;


// TODO
NANOCLR_SET_AND_LEAVE(CLR_E_NOT_SUPPORTED);


}
NANOCLR_NOCLEANUP();
}

HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeStop___VOID( CLR_RT_StackFrame& stack )
{
(void)stack;

NANOCLR_HEADER();
{
//CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis);

//int pinNumber = pThis[ FIELD___pinNumber ].NumericByRefConst().s4;
NANOCLR_SET_AND_LEAVE(CLR_E_NOT_SUPPORTED);

}
NANOCLR_NOCLEANUP();
}

HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioChangeCounter::NativeDispose___VOID( CLR_RT_StackFrame& stack )
{
(void)stack;

NANOCLR_HEADER();
{
//CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis);

//int pinNumber = pThis[ FIELD___pinNumber ].NumericByRefConst().s4;
NANOCLR_SET_AND_LEAVE(CLR_E_NOT_SUPPORTED);

}
NANOCLR_NOCLEANUP();
}
1 change: 1 addition & 0 deletions targets/FreeRTOS_ESP32/ESP32_WROOM_32/Include/esp32_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "dac.h"
#include "timer.h"
#include "esp_spiffs.h"
#include "pcnt.h"

// Uncomment to support Ethernet
//#define ESP32_ETHERNET_SUPPORT 1
Expand Down
Loading