Skip to content

Commit

Permalink
Add getChipUppercase command, for use in launch.json
Browse files Browse the repository at this point in the history
Fixes #58
  • Loading branch information
will-v-pi committed Aug 26, 2024
1 parent ccc0697 commit 35a78cc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.getChipUppercase",
"title": "Get Chip Uppercase",
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.getTarget",
"title": "Get OpenOCD Target",
Expand Down
10 changes: 5 additions & 5 deletions scripts/pico_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,12 +785,12 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
"servertype": "openocd",\
{f'{server_path}: "{openocd_path}",' if openocd_path else ""}
"gdbPath": "${{command:raspberry-pi-pico.getGDBPath}}",
"device": "${{command:raspberry-pi-pico.getChip}}",
"device": "${{command:raspberry-pi-pico.getChipUppercase}}",
"configFiles": [
"{debugger}",
"target/${{command:raspberry-pi-pico.getTarget}}.cfg"
],
"svdFile": "{codeSdkPath(sdkVersion)}/src/${{command:raspberry-pi-pico.getChip}}/hardware_regs/${{command:raspberry-pi-pico.getChip}}.svd",
"svdFile": "{codeSdkPath(sdkVersion)}/src/${{command:raspberry-pi-pico.getChip}}/hardware_regs/${{command:raspberry-pi-pico.getChipUppercase}}.svd",
"runToEntryPoint": "main",
// Fix for no_flash binaries, where monitor reset halt doesn't do what is expected
// Also works fine for flash binaries
Expand All @@ -811,8 +811,8 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
"servertype": "external",
"gdbTarget": "localhost:3333",
"gdbPath": "${{command:raspberry-pi-pico.getGDBPath}}",
"device": "${{command:raspberry-pi-pico.getChip}}",
"svdFile": "{codeSdkPath(sdkVersion)}/src/${{command:raspberry-pi-pico.getChip}}/hardware_regs/${{command:raspberry-pi-pico.getChip}}.svd",
"device": "${{command:raspberry-pi-pico.getChipUppercase}}",
"svdFile": "{codeSdkPath(sdkVersion)}/src/${{command:raspberry-pi-pico.getChip}}/hardware_regs/${{command:raspberry-pi-pico.getChipUppercase}}.svd"
"runToEntryPoint": "main",
// Give restart the same functionality as runToEntryPoint - main
"postRestartCommands": [
Expand All @@ -838,7 +838,7 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
"limit": 4
}},
"preLaunchTask": "Flash",
"svdPath": "{codeSdkPath(sdkVersion)}/src/${{command:raspberry-pi-pico.getChip}}/hardware_regs/${{command:raspberry-pi-pico.getChip}}.svd"
"svdPath": "{codeSdkPath(sdkVersion)}/src/${{command:raspberry-pi-pico.getChip}}/hardware_regs/${{command:raspberry-pi-pico.getChipUppercase}}.svd"
}},
]
}}
Expand Down
13 changes: 13 additions & 0 deletions src/commands/getPaths.mts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ export class GetChipCommand extends CommandWithResult<string> {
}
}

export class GetChipUppercaseCommand extends CommandWithResult<string> {
constructor() {
super("getChipUppercase");
}

async execute(): Promise<string> {
const cmd = new GetChipCommand();
const chip = await cmd.execute();

return chip.toUpperCase();
}
}

export class GetTargetCommand extends CommandWithResult<string> {
constructor() {
super("getTarget");
Expand Down
2 changes: 2 additions & 0 deletions src/extension.mts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
GetGDBPathCommand,
GetChipCommand,
GetTargetCommand,
GetChipUppercaseCommand,
} from "./commands/getPaths.mjs";
import {
downloadAndInstallCmake,
Expand Down Expand Up @@ -103,6 +104,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
new GetEnvPathCommand(),
new GetGDBPathCommand(),
new GetChipCommand(),
new GetChipUppercaseCommand(),
new GetTargetCommand(),
new CompileProjectCommand(),
new RunProjectCommand(),
Expand Down

0 comments on commit 35a78cc

Please sign in to comment.