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

Rework CPU GPIO #2144

Merged
merged 1 commit into from
Nov 5, 2021
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
9 changes: 2 additions & 7 deletions src/PAL/Include/CPU_GPIO_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
#ifndef DRIVERS_GPIO_DECL_H
#define DRIVERS_GPIO_DECL_H

#if defined(__GNUC__)
#define __int64 long long
#endif
typedef unsigned __int64 CLR_UINT64;

#define GPIO_PIN_NONE 0xFFFFFFFF

#define GPIO_ATTRIBUTE_NONE 0x00
Expand Down Expand Up @@ -117,7 +112,7 @@ bool CPU_GPIO_EnableOutputPin(GPIO_PIN Pin, GpioPinValue InitialState, GpioPinDr
//
bool CPU_GPIO_EnableInputPin(
GPIO_PIN pinNumber,
CLR_UINT64 debounceTimeMilliseconds,
uint32_t debounceTimeMilliseconds,
GPIO_INTERRUPT_SERVICE_ROUTINE pin_ISR,
void *isr_Param,
GPIO_INT_EDGE intEdge,
Expand Down Expand Up @@ -154,7 +149,7 @@ int32_t CPU_GPIO_GetPinCount();

// Get / Set the pin debounce time in millisecs
uint32_t CPU_GPIO_GetPinDebounce(GPIO_PIN Pin);
bool CPU_GPIO_SetPinDebounce(GPIO_PIN pinNumber, CLR_UINT64 debounceTimeMilliseconds);
bool CPU_GPIO_SetPinDebounce(GPIO_PIN pinNumber, uint32_t debounceTimeMilliseconds);

// Validate pin and set drive mode
// return true if pin ok
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::NativeSetDebounc
// developer note:
// the following call will FAIL if the pin hasn't been previously setup as input
// that's OK because the debounce timeout will be eventually set when the pin is configured
CPU_GPIO_SetPinDebounce(pinNumber, debounceTimeoutMilsec);
CPU_GPIO_SetPinDebounce(pinNumber, (uint32_t)debounceTimeoutMilsec);
}
NANOCLR_NOCLEANUP();
}
Expand Down Expand Up @@ -239,7 +239,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::ExtractDebounceT
CLR_INT64 *debounceValue = Library_corlib_native_System_TimeSpan::GetValuePtr(timeSpanValue);
FAULT_ON_NULL(debounceValue);

value = *(CLR_UINT64 *)debounceValue / TIME_CONVERSION__TO_MILLISECONDS;
value = (CLR_UINT64)(*debounceValue / TIME_CONVERSION__TO_MILLISECONDS);
}
NANOCLR_NOCLEANUP();
}
Expand Down Expand Up @@ -270,7 +270,7 @@ HRESULT Library_sys_dev_gpio_native_System_Device_Gpio_GpioPin::SetPinMode(

validPin = CPU_GPIO_EnableInputPin(
pinNumber,
debounceTimeoutMilsec,
(uint32_t)debounceTimeoutMilsec,
callbacksRegistered ? Gpio_Interupt_ISR : NULL,
NULL,
GPIO_INT_EDGE_BOTH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::

validPin = CPU_GPIO_EnableInputPin(
pinNumber,
debounceTimeoutMilsec,
(uint32_t)debounceTimeoutMilsec,
callbacksRegistered ? Gpio_Interupt_ISR : NULL,
NULL,
GPIO_INT_EDGE_BOTH,
Expand Down Expand Up @@ -195,7 +195,7 @@ HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeSetDebou
// developer note:
// the following call will FAIL if the pin hasn't been previously setup as input
// that's OK because the debounce timeout will be eventually set when the pin is configured
CPU_GPIO_SetPinDebounce(pinNumber, debounceTimeoutMilsec);
CPU_GPIO_SetPinDebounce(pinNumber, (uint32_t)debounceTimeoutMilsec);
}
NANOCLR_NOCLEANUP();
}
Expand Down Expand Up @@ -273,7 +273,7 @@ HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::ExtractDebounc
CLR_INT64 *debounceValue = Library_corlib_native_System_TimeSpan::GetValuePtr(timeSpanValue);
FAULT_ON_NULL(debounceValue);

value = *(CLR_UINT64 *)debounceValue / TIME_CONVERSION__TO_MILLISECONDS;
value = (CLR_UINT64)(*debounceValue / TIME_CONVERSION__TO_MILLISECONDS);
}
NANOCLR_NOCLEANUP();
}
8 changes: 4 additions & 4 deletions targets/ChibiOS/_nanoCLR/Windows.Devices.Gpio/cpu_gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void CPU_GPIO_TogglePinState(GPIO_PIN pinNumber)

bool CPU_GPIO_EnableInputPin(
GPIO_PIN pinNumber,
CLR_UINT64 debounceTimeMilliseconds,
uint32_t debounceTimeMilliseconds,
GPIO_INTERRUPT_SERVICE_ROUTINE pinISR,
void *isrParam,
GPIO_INT_EDGE intEdge,
Expand Down Expand Up @@ -291,7 +291,7 @@ bool CPU_GPIO_EnableInputPin(
pState->isrPtr = pinISR;
pState->mode = intEdge;
pState->param = (void *)isrParam;
pState->debounceMs = (uint32_t)(debounceTimeMilliseconds);
pState->debounceMs = debounceTimeMilliseconds;

switch (intEdge)
{
Expand Down Expand Up @@ -437,12 +437,12 @@ uint32_t CPU_GPIO_GetPinDebounce(GPIO_PIN pinNumber)
return 0;
}

bool CPU_GPIO_SetPinDebounce(GPIO_PIN pinNumber, CLR_UINT64 debounceTimeMilliseconds)
bool CPU_GPIO_SetPinDebounce(GPIO_PIN pinNumber, uint32_t debounceTimeMilliseconds)
{
gpio_input_state *ptr = GetInputState(pinNumber);
if (ptr)
{
ptr->debounceMs = (uint32_t)(debounceTimeMilliseconds);
ptr->debounceMs = debounceTimeMilliseconds;
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion targets/ESP32/_IDF/sdkconfig.default
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=5
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
Expand Down
2 changes: 1 addition & 1 deletion targets/ESP32/_IDF/sdkconfig.default.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=5
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
Expand Down
2 changes: 1 addition & 1 deletion targets/ESP32/_IDF/sdkconfig.default.esp32s2
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=5
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
Expand Down
2 changes: 1 addition & 1 deletion targets/ESP32/_IDF/sdkconfig.default_ble _rev3.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=5
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
Expand Down
2 changes: 1 addition & 1 deletion targets/ESP32/_IDF/sdkconfig.default_ble.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=5
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
Expand Down
2 changes: 1 addition & 1 deletion targets/ESP32/_IDF/sdkconfig.default_nopsram.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=5
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
Expand Down
2 changes: 1 addition & 1 deletion targets/ESP32/_IDF/sdkconfig.default_nopsram_rev3.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=5
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
Expand Down
2 changes: 1 addition & 1 deletion targets/ESP32/_IDF/sdkconfig.default_pico
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=5
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
Expand Down
2 changes: 1 addition & 1 deletion targets/ESP32/_IDF/sdkconfig.default_rev3.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=5
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
Expand Down
Loading