{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        // Launch configuration for `app`
        // - debug
        // - semihosting
        // - run to main
        {
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "openocd",
            "name": "app (debug)",
            "preLaunchTask": "cargo build",
            "executable": "./target/thumbv7em-none-eabihf/debug/app",
            "configFiles": [
                "interface/stlink.cfg",
                // "interface/stlink-v2-1.cfg", // deprecated setup script
                "target/stm32f4x.cfg"
            ],
            "postLaunchCommands": [
                "monitor arm semihosting enable"
            ],
            "runToMain": true,
            "cwd": "${workspaceRoot}"
        },
        // Launch configuration for `examples`
        // - debug
        // - semihosting
        // - internal ITM/SWO tracing 
        // - run to main 
        {
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "openocd",
            "name": "itm internal (debug)",
            "preLaunchTask": "cargo build --examples",
            "executable": "./target/thumbv7em-none-eabihf/debug/examples/${fileBasenameNoExtension}",
            "configFiles": [
                "interface/stlink.cfg",
                // "interface/stlink-v2-1.cfg", // deprecated setup script
                "target/stm32f4x.cfg"
            ],
            "postLaunchCommands": [
                "monitor arm semihosting enable",
            ],
            "swoConfig": {
                "enabled": true,
                "cpuFrequency": 16000000,
                "swoFrequency": 2000000,
                "source": "probe",
                "decoders": [
                    {
                        "type": "console",
                        "label": "ITM",
                        "port": 0
                    }
                ]
            },
            "runToMain": true,
            "cwd": "${workspaceRoot}"
        },
        // Launch configuration for `examples`
        // - debug
        // - semihosting
        // - ITM/SWO tracing to file/fifo `/tmp/itm.fifo`
        // - run to main   
        {
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "openocd",
            "name": "itm fifo (debug)",
            "preLaunchTask": "cargo build --examples",
            "executable": "./target/thumbv7em-none-eabihf/debug/examples/${fileBasenameNoExtension}",
            "configFiles": [
                "interface/stlink.cfg",
                // "interface/stlink-v2-1.cfg", // deprecated setup script
                "target/stm32f4x.cfg"
            ],
            "postLaunchCommands": [
                "monitor arm semihosting enable",
                "monitor tpiu config internal /tmp/itm.fifo uart off 16000000",
                "monitor itm port 0 on"
            ],
            "runToMain": true,
            "cwd": "${workspaceRoot}"
        },
        // Launch configuration for `examples`
        // - release
        // - semihosting
        // - ITM/SWO tracing to file/fifo `/tmp/itm.fifo`
        // - run to main  
        {
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "openocd",
            "name": "itm fifo (release)",
            "preLaunchTask": "cargo build --examples --release",
            "executable": "./target/thumbv7em-none-eabihf/release/examples/${fileBasenameNoExtension}",
            "configFiles": [
                "interface/stlink.cfg",
                // "interface/stlink-v2-1.cfg", // deprecated setup script
                "target/stm32f4x.cfg"
            ],
            "postLaunchCommands": [
                "monitor arm semihosting enable",
                "monitor tpiu config internal /tmp/itm.fifo uart off 16000000",
                "monitor itm port 0 on"
            ],
            "runToMain": true,
            "cwd": "${workspaceRoot}"
        },
        // Launch configuration for `examples`
        // - release
        // - semihosting
        // - ITM/SWO tracing to file/fifo `/tmp/itm.fifo`
        // - run to main  
        {
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "openocd",
            "name": "itm fifo 64MHz (release)",
            "preLaunchTask": "cargo build --examples --release",
            "executable": "./target/thumbv7em-none-eabihf/release/examples/${fileBasenameNoExtension}",
            "configFiles": [
                "interface/stlink.cfg",
                // "interface/stlink-v2-1.cfg", // deprecated setup script
                "target/stm32f4x.cfg"
            ],
            "postLaunchCommands": [
                "monitor reset init", // sets the MCU to 64MHz
                "monitor arm semihosting enable",
                "monitor tpiu config internal /tmp/itm.fifo uart off 64000000",
                "monitor itm port 0 on"
            ],
            "runToMain": true,
            "cwd": "${workspaceRoot}"
        },
    ],
}