I have an odd problem. My code compiles and works fine, but PlatformIO IDE in VS Code doesn’t believe that rtos::Thread exists in Mbed. Note that my platformio.ini includes “build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT” (and again everything builds OK). However, I still get the following Intellisense error:
identifier “Thread” is undefined
When I actually open Thread.h (funny enough right-clicking and say go to definition on Thread works without issue), I see that the following preprocessor statement returns false which omits Thread from the rtos namespace:
#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST)
For some reason it doesn’t seem to be using my mbed_config.h.
Any ideas?
Try to rebuild the Intellisense and make sure that the .vscode/c_cpp_properties.json
includes the macro MBED_CONF_RTOS_PRESENT
.
Thanks for the response. I’ve tried rebuilding intellisense many times (including just now at your recommendation).
.vscode/c_pp_properties.json does not include “MBED_CONF_RTOS_PRESENT” anywhere, but it does have
"defines": [
"PLATFORMIO=40305",
"STM32L432xx",
"PIO_FRAMEWORK_MBED_RTOS_PRESENT",
...
Seems like when creating the defines for the project, it doesn’t automatically expand PIO_FRAMEWORK_MBED_RTOS_PRESENT
to MBED_CONF_RTOS_PRESENT
although it does so during compile time.
As a work around, does explicitly writing
build_flags =
-D PIO_FRAMEWORK_MBED_RTOS_PRESENT
-D MBED_CONF_RTOS_PRESENT
and rebuilding the Intellisense fix the problem?
That works, but it doesn’t solve the underlying issue. mbed_config.h is not being used. I now am trying to change the default uart pins for stdio by setting
...
"target.stdio_uart_tx": "PA_2",
"target.stdio_uart_rx": "PA_3"
...
in mbed_app.json (the rx pin is PA_15 by default). Now mbed_config.h shows
#define MBED_CONF_TARGET_STDIO_UART_RX PA_3
#define MBED_CONF_TARGET_STDIO_UART_TX PA_2
but after some debugging, I find that the platform is still using PA_15 as the rx pin. In my PinNames.h file (a custom target), I see that the MBED_CONF_TARGET_STDIO_UART_RX and MBED_CONF_TARGET_STDIO_UART_TX preprocessor macros are undefined so the uart pins are not being overridden.
Thoughts on what I’ve done incorrectly? Any way I could have screwed this up with my custom_targets.json?