Skip to content

Latest commit

 

History

History
130 lines (122 loc) · 3.85 KB

vs_code.md

File metadata and controls

130 lines (122 loc) · 3.85 KB

VS Code Configuration Files

Perform these steps in VS Code:

C/C++ Configuration Installation

If you are on Windows, use Ctrl, instead of CMD.

  1. CMD-Shift-P -> "C/C++" -> C/C++: Edit Configurations (JSON))
  2. Copy the content below then in VS Code CMD-a to select all of the existing c_cpp_properties.json file
  3. CMD-v to paste and CMD-s to save.

The location of libraries will be different based on how gcc was installed. If you compiled gcc yourself (Option 3 on wellys.com), then use the first json file. If you used the default installation from Bookworm, use the second JSON file. VS Code will advise if it isn't able to find the library files.

User built C (gcc 14.1)

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "AVR",
            "includePath": [
                "/usr/local/avr/avr/",
                "/usr/local/avr/include/**",
                "${workspaceFolder}/**"
            ],
            "defines": ["__AVR_ATmega328P__"],
            "compilerPath": "/usr/local/avr/bin/avr-gcc", 
            "compilerArgs": [ ],
            "cStandard": "c99",
            "cppStandard": "c++98",
            "intelliSenseMode": "${default}"
        }
    ],
    "version": 4
}

Bookworm Installed C (gcc 5.4)

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "AVR",
            "includePath": [
                "/usr/lib/avr/",
                "/usr/lib/avr/include/**",
                "${workspaceFolder}/**"
            ],
            "defines": ["__AVR_ATmega328P__"],
            "compilerPath": "/usr/bin/avr-gcc", 
            "compilerArgs": [ ],
            "cStandard": "c99",
            "cppStandard": "c++98",
            "intelliSenseMode": "${default}"
        }
    ],
    "version": 4
}

Default Task Installation

If you are on Windows, use Ctrl, instead of CMD.

  1. CMD-Shift-P -> "task" -> Tasks: Configure Default Build Task _> Create...from template -> Others Example...
  2. Copy the content below then in VS Code CMD-A to select all of the existing tasks.json file
  3. CMD-v to paste and CMD-s to save.

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "make",
            "detail": "Run make",
            "type": "shell",
            "command": "/usr/bin/make ${input:makeTarget}",
            "options": {
                "cwd": "${fileDirname}"
            },
            "presentation": {
                "reveal": "always",
                "panel": "dedicated"
              },        
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "inputs": [
        {
            "type": "pickString",
            "id": "makeTarget",
            "description": "Select a make target",
            "options": [
                {   
                    "value": "flash",
                    "label": "compile and upload code (upload)"
                },
                {   
                    "value": "compile",
                    "label": "only compile code (verify)"
                },
                {   
                    "value": "clean",
                    "label": "remove non-source files"
                },
                {   
                    "value": "complete",
                    "label": "complete re-compile with verbose upload"
                },
                {   
                    "value": "verbose",
                    "label": "verbose upload to debug serial connection"
                },
                {   
                    "value": "env",
                    "label": "print env variables being used"
                },
                {   
                    "value": "help",
                    "label": "print make commands"
                }
            ],
            "default": " flash"
        }
    ]
}