Skip to content

Commit

Permalink
svdAddrGapThreshold config
Browse files Browse the repository at this point in the history
  • Loading branch information
thegecko committed Jan 27, 2023
1 parent 5e5b26f commit a7507fd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@
"type": "string",
"default": "device",
"description": "Debug configuration key to use to get the device"
},
"svd-viewer.svdAddrGapThreshold": {
"type": "number",
"default": 16,
"multipleOf": 1,
"minimum": -1,
"maximum": 32,
"description": "If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device. -1 means never combine registers and is very slow"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export const CONFIG_SVD_PATH = 'svdPathConfig';
export const DEFAULT_SVD_PATH = 'svdPath';
export const CONFIG_DEVICE = 'deviceConfig';
export const DEFAULT_DEVICE = 'device';
export const CONFIG_ADDRGAP = 'svdAddrGapThreshold';
export const DEFAULT_ADDRGAP = 16;
2 changes: 1 addition & 1 deletion src/svd-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ interface SvdData {
export class SVDParser {
private static enumTypeValuesMap: { [key: string]: any } = {};
private static peripheralRegisterMap: { [key: string]: any } = {};
private static gapThreshold = 16;
private static gapThreshold: number;

public static async parseSVD(
session: vscode.DebugSession, svdData: SvdData, gapThreshold: number): Promise<PeripheralNode[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/peripheralregisternode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export class PeripheralRegisterNode extends ClusterOrRegisterBaseNode {
if (!vscode.debug.activeDebugSession) {
return false;
}

await MemReadUtils.writeMemory(vscode.debug.activeDebugSession, this.parent.getAddress(this.offset), value, this.size);
await this.parent.updateData();
return true;
Expand Down
9 changes: 6 additions & 3 deletions src/views/peripheral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { DebugTracker } from '../debug-tracker';
import { SvdRegistry } from '../svd-registry';

const STATE_FILENAME = '.svd-viewer.state.json';
const SVD_THRESH_ARG = 'svdAddrGapThreshold';

const pathToUri = (path: string): vscode.Uri => {
try {
Expand Down Expand Up @@ -117,7 +116,7 @@ export class PeripheralTreeForSession extends PeripheralBaseNode {
return state;
}

private async loadSVD(svd: string, gapThreshold = 16): Promise<void> {
private async loadSVD(svd: string, gapThreshold: number): Promise<void> {
let svdData: string | undefined;

try {
Expand Down Expand Up @@ -355,7 +354,11 @@ export class PeripheralTreeProvider implements vscode.TreeDataProvider<Periphera
});

this.sessionPeripheralsMap.set(session.id, regs);
const thresh = session.configuration[SVD_THRESH_ARG];
let thresh = session.configuration[manifest.CONFIG_ADDRGAP];

if (!thresh) {
thresh = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get<number>(manifest.CONFIG_ADDRGAP) || manifest.DEFAULT_ADDRGAP;
}

try {
await regs.sessionStarted(svd, thresh); // Should never reject
Expand Down

0 comments on commit a7507fd

Please sign in to comment.