-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Description
I've encountered a problem using the CAN peripheral on the STM32 bluepill_f103c8
board. The following code does not compile when the target is set to bluepill_f103c8
, but it does compile when the target is set to nucleo_f103rb
:
#include <mbed.h>
#include <CAN.h>
CAN can(PB_8, PB_9);
int main() {
while (true) {}
return 0;
}
I'm using the PlatformIO toolchain to compile the code, with the following platformio.ini
file:
[env:stm32]
platform = ststm32
board = bluepill_f103c8
;board = genericSTM32F103C8
;board = nucleo_f103rb
framework = mbed
lib_ignore = mbed-LWIP, mbed-mbedtls
build_flags =
-D PIO_FRAMEWORK_MBED_RTOS_PRESENT
There should not be a difference between the two targets, the only difference between the STM32F103RB and the STM32F103C8 is that the former has more flash memory.
Some digging revealed that FEATURE_CAN
is not defined on bluepill_f103c8
, hence why the CAN class is not defined. I managed to get the target to build by making the following modifications:
platformio.ini:
[env:stm32]
platform = ststm32
board = bluepill_f103c8
;board = genericSTM32F103C8
;board = nucleo_f103rb
framework = mbed
lib_ignore = mbed-LWIP, mbed-mbedtls
build_flags =
-D PIO_FRAMEWORK_MBED_RTOS_PRESENT
-D FEATURE_CAN=1
variants/BLUEPILL_F103C8/BLUEPILL_F103C8.json, line 1377:
Added "DEVICE_CAN=1"
.
"symbols": [
"DEVICE_SLEEP=1",
"DEVICE_PWMOUT=1",
"TRANSACTION_QUEUE_SIZE_SPI=2",
...
"DEVICE_INTERRUPTIN=1",
"TARGET_LIKE_MBED",
"DEVICE_CAN=1"
],
targets/targets.json, line 3680:
Copied the device_has_add
key from the NUCLEO_F103RB
target.
"BLUEPILL_F103C8": {
"inherits": ["FAMILY_STM32"],
"core": "Cortex-M3",
"default_toolchain": "GCC_ARM",
"extra_labels_add": ["STM32F1", "STM32F103C8"],
"supported_toolchains": ["GCC_ARM"],
"device_has_add": ["CAN", "SERIAL_FC", "SERIAL_ASYNCH", "FLASH"],
"device_has_remove": ["RTC", "STDIO_MESSAGES"]
},
Issue request type
[ ] Question
[ ] Enhancement
[X] Bug