From 6916733c90d9b0468dfc573ce682ddd87b7073cf Mon Sep 17 00:00:00 2001 From: CW2 Date: Thu, 15 Sep 2016 12:07:59 +0200 Subject: [PATCH] Changed CPU_GPIO_DisablePin AltFunction parameter type to UINT32 Also added an inline wrapper for backward compatibility. This change also allows functions that were created to workaround the enum limitation to be consolidated and the code can be moved inside CPU_GPIO_DisablePin(..., UINT32 ). --- .../Stubs/Processor/stubs_gpio/stubs_functions_gpio.cpp | 2 +- .../STM32/DeviceCode/STM32_GPIO/STM32_GPIO_functions.cpp | 2 +- .../DeviceCode/STM32F4_GPIO/STM32F4_GPIO_functions.cpp | 4 ++-- DeviceCode/include/CPU_GPIO_decl.h | 8 +++++++- Solutions/Windows2/TinyCLR/GPIO.cpp | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/DeviceCode/Drivers/Stubs/Processor/stubs_gpio/stubs_functions_gpio.cpp b/DeviceCode/Drivers/Stubs/Processor/stubs_gpio/stubs_functions_gpio.cpp index d6379daf9..c7939a8c9 100644 --- a/DeviceCode/Drivers/Stubs/Processor/stubs_gpio/stubs_functions_gpio.cpp +++ b/DeviceCode/Drivers/Stubs/Processor/stubs_gpio/stubs_functions_gpio.cpp @@ -20,7 +20,7 @@ UINT32 CPU_GPIO_Attributes( GPIO_PIN Pin ) return GPIO_ATTRIBUTE_NONE; } -void CPU_GPIO_DisablePin( GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, GPIO_ALT_MODE AltFunction ) +void CPU_GPIO_DisablePin( GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, UINT32 AltFunction ) { } diff --git a/DeviceCode/Targets/Native/STM32/DeviceCode/STM32_GPIO/STM32_GPIO_functions.cpp b/DeviceCode/Targets/Native/STM32/DeviceCode/STM32_GPIO/STM32_GPIO_functions.cpp index cec57e32e..e31a15850 100755 --- a/DeviceCode/Targets/Native/STM32/DeviceCode/STM32_GPIO/STM32_GPIO_functions.cpp +++ b/DeviceCode/Targets/Native/STM32/DeviceCode/STM32_GPIO/STM32_GPIO_functions.cpp @@ -277,7 +277,7 @@ UINT32 CPU_GPIO_Attributes( GPIO_PIN pin ) } -void CPU_GPIO_DisablePin( GPIO_PIN pin, GPIO_RESISTOR resistor, UINT32 output, GPIO_ALT_MODE alternate ) +void CPU_GPIO_DisablePin( GPIO_PIN pin, GPIO_RESISTOR resistor, UINT32 output, UINT32 alternate ) { NATIVE_PROFILE_HAL_PROCESSOR_GPIO(); if (pin < STM32_Gpio_MaxPins) { diff --git a/DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_GPIO/STM32F4_GPIO_functions.cpp b/DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_GPIO/STM32F4_GPIO_functions.cpp index 21c13ba68..fe06ee675 100644 --- a/DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_GPIO/STM32F4_GPIO_functions.cpp +++ b/DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_GPIO/STM32F4_GPIO_functions.cpp @@ -342,7 +342,7 @@ UINT32 CPU_GPIO_Attributes( GPIO_PIN pin ) * GPIO_ALT_MODE_3 | AF << 4 | speed << 8: Alternate Function with open drain * speed: 0: 2MHZ, 1: 25MHz, 2: 50MHz, 3: 100MHz */ -void CPU_GPIO_DisablePin( GPIO_PIN pin, GPIO_RESISTOR resistor, UINT32 output, GPIO_ALT_MODE alternate ) +void CPU_GPIO_DisablePin( GPIO_PIN pin, GPIO_RESISTOR resistor, UINT32 output, UINT32 alternate ) { NATIVE_PROFILE_HAL_PROCESSOR_GPIO( ); if( pin < STM32F4_Gpio_MaxPins ) @@ -355,7 +355,7 @@ void CPU_GPIO_DisablePin( GPIO_PIN pin, GPIO_RESISTOR resistor, UINT32 output, G else if( altMode ) mode = 2; // alternate pin function - STM32F4_GPIO_Pin_Config( pin, mode, resistor, ( UINT32 )alternate ); + STM32F4_GPIO_Pin_Config( pin, mode, resistor, alternate ); STM32F4_GPIO_Set_Interrupt( pin, NULL, 0, GPIO_INT_NONE, FALSE ); // disable interrupt } } diff --git a/DeviceCode/include/CPU_GPIO_decl.h b/DeviceCode/include/CPU_GPIO_decl.h index 29fbd339f..178b1d891 100644 --- a/DeviceCode/include/CPU_GPIO_decl.h +++ b/DeviceCode/include/CPU_GPIO_decl.h @@ -57,7 +57,7 @@ typedef void (*GPIO_INTERRUPT_SERVICE_ROUTINE)( GPIO_PIN Pin, BOOL PinState, voi BOOL CPU_GPIO_Initialize (); BOOL CPU_GPIO_Uninitialize (); UINT32 CPU_GPIO_Attributes ( GPIO_PIN Pin ); -void CPU_GPIO_DisablePin ( GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, GPIO_ALT_MODE AltFunction ); +void CPU_GPIO_DisablePin ( GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, UINT32 AltFunction ); void CPU_GPIO_EnableOutputPin( GPIO_PIN Pin, BOOL InitialState ); BOOL CPU_GPIO_EnableInputPin ( GPIO_PIN Pin, BOOL GlitchFilterEnable, GPIO_INTERRUPT_SERVICE_ROUTINE PIN_ISR, GPIO_INT_EDGE IntEdge, GPIO_RESISTOR ResistorState ); BOOL CPU_GPIO_EnableInputPin2( GPIO_PIN Pin, BOOL GlitchFilterEnable, GPIO_INTERRUPT_SERVICE_ROUTINE PIN_ISR, void* ISR_Param, GPIO_INT_EDGE IntEdge, GPIO_RESISTOR ResistorState ); @@ -75,5 +75,11 @@ UINT8 CPU_GPIO_GetSupportedInterruptModes(GPIO_PIN pin ); UINT32 CPU_GPIO_GetPinDebounce( GPIO_PIN Pin ); BOOL CPU_GPIO_SetPinDebounce( GPIO_PIN Pin, INT64 debounceTimeMilliseconds ); +// For backward compatibility +inline void CPU_GPIO_DisablePin(GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, GPIO_ALT_MODE AltFunction) +{ + return CPU_GPIO_DisablePin(Pin, ResistorState, Direction, (UINT32)AltFunction); +} + #endif // _DRIVERS_GPIO_DECL_H_ diff --git a/Solutions/Windows2/TinyCLR/GPIO.cpp b/Solutions/Windows2/TinyCLR/GPIO.cpp index bbfc5be2d..1942e5466 100644 --- a/Solutions/Windows2/TinyCLR/GPIO.cpp +++ b/Solutions/Windows2/TinyCLR/GPIO.cpp @@ -24,7 +24,7 @@ UINT32 CPU_GPIO_Attributes( GPIO_PIN Pin ) return EmulatorNative::GetIGpioDriver()->Attributes( Pin ); } -void CPU_GPIO_DisablePin( GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, GPIO_ALT_MODE AltFunction ) +void CPU_GPIO_DisablePin( GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, UINT32 AltFunction ) { EmulatorNative::GetIGpioDriver()->DisablePin( Pin, ResistorState, Direction, AltFunction ); }