Skip to content

Commit

Permalink
Add GPIO ChangeCounter (nanoframework#1421)
Browse files Browse the repository at this point in the history
(cherry picked from commit c5b419a)
  • Loading branch information
MateuszKlatecki authored and Jeremi Jasiński committed Aug 6, 2019
1 parent adcfa81 commit 254c8bf
Show file tree
Hide file tree
Showing 14 changed files with 705 additions and 274 deletions.
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();
}

This file was deleted.

Loading

0 comments on commit 254c8bf

Please sign in to comment.