Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## [Unreleased]
- Fix peripheral inheriting size, accessType and resetValue from device

## [v1.6.0] - 2025-08-30
- PR[#11](https://github.com/mcu-debug/peripheral-viewer/issues/11): An alternative way to load peripherals information (see [extending-peripheral-viewer.md](https://github.com/mcu-debug/peripheral-viewer/blob/main/docs/extending-peripheral-viewer.md))

Expand Down
10 changes: 7 additions & 3 deletions src/svd-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,16 @@ export class SVDParser {
name: p.name[0],
baseAddress: parseInteger(p.baseAddress ? p.baseAddress[0] : '0'),
description: this.cleanupDescription(p.description ? p.description[0] : ''),
totalLength: totalLength
totalLength: totalLength,
// initialize from device-level defaults
accessType: _defaults.accessType,
size: _defaults.size,
resetValue: _defaults.resetValue
};

if (p.access) { options.accessType = accessTypeFromString(p.access[0]); }
if (p.size) { options.size = parseInteger(p.size[0]); }
if (p.resetValue) { options.resetValue = parseInteger(p.resetValue[0]); }
if (p.size) { options.size = parseInteger(p.size[0]) ?? options.size; }
if (p.resetValue) { options.resetValue = parseInteger(p.resetValue[0]) ?? options.resetValue; }
if (p.groupName) { options.groupName = p.groupName[0]; }

const peripheral = new PeripheralNode(this.gapThreshold, options);
Expand Down
3 changes: 2 additions & 1 deletion src/views/nodes/peripheralnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class PeripheralNode extends PeripheralBaseNode {
public readonly description: string;
public readonly groupName: string;
public readonly totalLength: number;
public readonly accessType = AccessType.ReadOnly;
public readonly accessType: AccessType;
public readonly size: number;
public readonly resetValue: number;
protected addrRanges: AddrRange[];
Expand All @@ -65,6 +65,7 @@ export class PeripheralNode extends PeripheralBaseNode {
this.description = options.description;
this.groupName = options.groupName || '';
this.resetValue = options.resetValue || 0;
this.accessType = options.accessType || AccessType.ReadOnly;
this.size = options.size || 32;
this.children = [];
this.addrRanges = [];
Expand Down