CAN: Use uintptr_t for can_irq_ids
The HAL can_api stores an array of IDs in order to dispatch interrupts
to the correct CAN object. The drivers level CAN Class casts a pointer
to itself to an uint32_t, which is stored as the ID and then cast back
to a CAN * in order to call the correct handler. This results in
compilation failure when the size of an object pointer is greater than
uint32_t, for example when building on a PC for unit testing.

In order to allow Unit Testing of the CAN Class, we replace the use of
uint32_t with uintptr_t (type capable of holding a pointer), which
allows portability and expresses intentions more clearly. In aid of this
latter goal, we also replace the use of the name "id" with "context",
to improve clarity. These are addresses of the context related to that
callback.
ls
1 parent 810adf9 commit b493a15a53e94c99dd5a718949f1000523128648
@Hari Limaye Hari Limaye authored on 13 Sep 2021
Showing 13 changed files
View
drivers/include/drivers/CAN.h
View
drivers/source/CAN.cpp
View
hal/include/hal/can_api.h
View
targets/TARGET_GigaDevice/TARGET_GD32F30X/can_api.c
View
targets/TARGET_GigaDevice/TARGET_GD32F4XX/can_api.c
View
targets/TARGET_NUVOTON/TARGET_M451/can_api.c
View
targets/TARGET_NUVOTON/TARGET_M480/can_api.c
View
targets/TARGET_NUVOTON/TARGET_NUC472/can_api.c
View
targets/TARGET_NXP/TARGET_LPC176X/can_api.c
View
targets/TARGET_RENESAS/TARGET_RZ_A1XX/can_api.c
View
targets/TARGET_RENESAS/TARGET_RZ_A2XX/can_api.c
View
targets/TARGET_STM/can_api.c
View
targets/TARGET_Silicon_Labs/TARGET_EFM32/can_api.c