Callback use of user_data is inconsistent or unavailable across SDK #71
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#71
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The use of user_data in callbacks is of importance because it can allow callback to a class method when using C++/OOP via a non capturing Lambda function, which is great.
There is an inconsistency with how the user_data is implemented or if it is implemented in some cases.
The two different schemes are the alarm scheme where user_data is passed as a second argument to the callback:
And the repeating timer scheme where the user_data is passed to the callback inside the repeating_timer_t:
Having a consistent scheme between the two would be great, with the alarm scheme being more idiomatic from what I can tell.
Also of concern is the lack of user_data on the following callbacks and types.
With the lack on IRQs my primary concern as it makes for example a Sensor class for a hall effect sensor difficult.
The reason for the repeating timer owning the callback here, is that the repeating timer can be wholly user owned state (it seemed superfluous to allocate another object on top of the alarm). It then seemed equally superfluous to extract the user data out of the structure and marshall it as an argument
yes, the hold gpio irq API should not have made it in in its current form; it needs to be replaced.
We certainly don't associate any state with IRQ handlers themselves, however that can and should be handled/provided by any abstraction which provides multiplexed routing based on the underlying IRQ, for sure.