Actions

EmSys

Difference between revisions of "Using Visual Studio Code for ARM Development – Defines"

From EdWiki

(Created page with "__NOTOC__ == Using Visual Studio Code for ARM Development – Defines == center These errors are caused since the code I’m using, includi...")
 
m (Using Visual Studio Code for ARM Development – Defines)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
== Using Visual Studio Code for ARM Development – Defines ==
 
== Using Visual Studio Code for ARM Development – Defines ==
[[image:vscode_defines_error.png|center]]
+
<!-- [[image:vscode_defines_error.png|center]] -->
  
These errors are caused since the code I’m using, including the STM32 libraries standard ARM libraries, depend on macros that are not defined within the code itself. In this post, I will describe how to determine and pass the defines to Visual Studio Code so it will properly parse your code.
+
It is common to pass defines to the compiler using flags at compile time.
  
First, it is common to pass defines to the compiler using flags at compile time. In my case, I am using CMSIS and the new STM32 Low-Level library and that is included with the STM32Cube software, and I am targeting the 1bitsy development board, which uses an STM32F415 chip. In order for the library to use the right options, I need to pass these to the compiler, without them, many references to the library are not properly defined in the scope of my code.
+
  -D_DEBUG
 
+
  -DPART_TM4C123GH6PM
  -DUSE_FULL_LL_DRIVER
+
  -DSTM32F415xx
+
  
 
Setting these for VSCode is simple: just add them to the “defines” section of c_cpp_properties.json, without the -D flag prefix:
 
Setting these for VSCode is simple: just add them to the “defines” section of c_cpp_properties.json, without the -D flag prefix:
Line 14: Line 12:
 
<pre>
 
<pre>
 
     "defines": [
 
     "defines": [
         "STM32F415xx",
+
         "DEBUG",
         "USE_FULL_LL_DRIVER"
+
         "PART_TM4C123GH6PM"
 
     ],
 
     ],
 
</pre>
 
</pre>

Revision as of 15:07, 21 March 2022

Using Visual Studio Code for ARM Development – Defines

It is common to pass defines to the compiler using flags at compile time.

-D_DEBUG
-DPART_TM4C123GH6PM

Setting these for VSCode is simple: just add them to the “defines” section of c_cpp_properties.json, without the -D flag prefix:

    "defines": [
        "DEBUG",
        "PART_TM4C123GH6PM"
    ],

This fixes all of the errors related to things defined in the libraries!

If the include paths and defines are properly set up in Visual Studio Code, the C/C++ plugin should be able to properly parse your code, identify syntax errors, and will provide Intellisense code completion to improve the speed and accuracy of your writing!