From 02b573793a1dc5c68293a39bd65a022ed253275a Mon Sep 17 00:00:00 2001 From: Joseph Duchesne Date: Mon, 14 Aug 2023 11:07:23 -0400 Subject: [PATCH] Fix crash when using FDCAN3 RX IRQ on STM32G473 (and others) --- targets/TARGET_STM/can_api.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/targets/TARGET_STM/can_api.c b/targets/TARGET_STM/can_api.c index 293dedaa0f..73bfa81f34 100644 --- a/targets/TARGET_STM/can_api.c +++ b/targets/TARGET_STM/can_api.c @@ -24,7 +24,13 @@ #include "PeripheralPins.h" #include "mbed_error.h" +// Some STM32G4 series (and others) have 3 FDCAN devices +// while others have 2 +#ifdef FDCAN3 +static uintptr_t can_irq_contexts[3] = {0}; +#else static uintptr_t can_irq_contexts[2] = {0}; +#endif static can_irq_handler irq_handler; /** Call all the init functions