Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit 1b47f66

Browse files
committed
- Fixed typo in name of CPU_GPIO_SetPinDebounce
- Added stub implementation of the CPU_GPIO_XXXPinDebounce functions for STM32F4 (Will fill in implementation in a future commit) - Updated Windows.Devices.* GPIO interop code to call new CPU apis to use per pin debounce support
1 parent 46795d5 commit 1b47f66

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

CLR/Libraries/Windows_Devices/windows_devices_native_Windows_Devices_Gpio_GpioPin.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ HRESULT Library_windows_devices_native_Windows_Devices_Gpio_GpioPin::get_Debounc
4848
{
4949
TINYCLR_HEADER();
5050

51+
GPIO_PIN pin;
5152
CLR_INT64 value;
5253
CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis);
5354

@@ -56,7 +57,8 @@ HRESULT Library_windows_devices_native_Windows_Devices_Gpio_GpioPin::get_Debounc
5657
TINYCLR_SET_AND_LEAVE(CLR_E_OBJECT_DISPOSED);
5758
}
5859

59-
value = (CLR_INT64)::CPU_GPIO_GetDebounce() * TIME_CONVERSION__TO_MILLISECONDS;
60+
pin = (GPIO_PIN)( pThis[ FIELD__m_pinNumber ].NumericByRefConst().u4 );
61+
value = (CLR_INT64)::CPU_GPIO_GetPinDebounce( pin ) * TIME_CONVERSION__TO_MILLISECONDS;
6062
stack.SetResult_I8( value );
6163
stack.TopValue().ChangeDataType( DATATYPE_TIMESPAN );
6264

@@ -67,6 +69,7 @@ HRESULT Library_windows_devices_native_Windows_Devices_Gpio_GpioPin::set_Debounc
6769
{
6870
TINYCLR_HEADER();
6971

72+
GPIO_PIN pin;
7073
CLR_INT64 value;
7174
CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis);
7275

@@ -76,12 +79,11 @@ HRESULT Library_windows_devices_native_Windows_Devices_Gpio_GpioPin::set_Debounc
7679
}
7780

7881
value = (CLR_INT64_TEMP_CAST) stack.Arg1().NumericByRef().s8 / TIME_CONVERSION__TO_MILLISECONDS;
79-
80-
// TODO: Issue #101 Set debounce individually per pin once the HAL has that capability.
81-
//if (!::CPU_GPIO_SetDebounce( value ))
82-
//{
83-
// TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER);
84-
//}
82+
pin = (GPIO_PIN)( pThis[ FIELD__m_pinNumber ].NumericByRefConst().u4 );
83+
if (!::CPU_GPIO_SetPinDebounce( pin, value ))
84+
{
85+
TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER);
86+
}
8587
TINYCLR_SET_AND_LEAVE(stack.NotImplementedStub());
8688

8789
TINYCLR_NOCLEANUP();

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_GPIO/STM32F4_GPIO_functions.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,3 +494,14 @@ UINT8 CPU_GPIO_GetSupportedInterruptModes( GPIO_PIN pin )
494494
return ( 1 << GPIO_INT_EDGE_LOW ) | ( 1 << GPIO_INT_EDGE_HIGH ) | ( 1 << GPIO_INT_EDGE_BOTH )
495495
| ( 1 << GPIO_INT_LEVEL_LOW ) | ( 1 << GPIO_INT_LEVEL_HIGH );
496496
}
497+
498+
UINT32 CPU_GPIO_GetPinDebounce( GPIO_PIN Pin )
499+
{
500+
return 0;
501+
}
502+
503+
BOOL CPU_GPIO_SetPinDebounce( GPIO_PIN Pin, INT64 debounceTimeMilliseconds )
504+
{
505+
return FALSE;
506+
}
507+

DeviceCode/include/CPU_GPIO_decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ UINT8 CPU_GPIO_GetSupportedResistorModes(GPIO_PIN pin );
7373
UINT8 CPU_GPIO_GetSupportedInterruptModes(GPIO_PIN pin );
7474

7575
UINT32 CPU_GPIO_GetPinDebounce( GPIO_PIN Pin );
76-
BOOL CPU_GPIO_SePinDebounce( GPIO_PIN Pin, INT64 debounceTimeMilliseconds );
76+
BOOL CPU_GPIO_SetPinDebounce( GPIO_PIN Pin, INT64 debounceTimeMilliseconds );
7777

7878
#endif // _DRIVERS_GPIO_DECL_H_
7979

0 commit comments

Comments
 (0)