Skip to content

Commit 953f914

Browse files
committed
check only when in same peripheral
1 parent da15115 commit 953f914

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/patch/device.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,11 @@ impl DeviceExt for Device {
297297
} else {
298298
return Err(anyhow!("derive: incorrect syntax for {}", pname));
299299
};
300-
self.get_peripheral(pderive)
301-
.ok_or_else(|| anyhow!("peripheral {} not found", pderive))?;
300+
301+
if !pderive.contains('.') {
302+
self.get_peripheral(pderive)
303+
.ok_or_else(|| anyhow!("peripheral {} not found", pderive))?;
304+
}
302305

303306
match self.get_mut_peripheral(pname) {
304307
Some(peripheral) => peripheral.modify_from(info, VAL_LVL)?,

src/patch/peripheral.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ impl PeripheralExt for Peripheral {
377377
} else {
378378
return Err(anyhow!("derive: incorrect syntax for {}", rname));
379379
};
380+
380381
self.get_register(rderive)
381382
.ok_or_else(|| anyhow!("register {} not found", rderive))?;
382383

svdtools/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def derive_peripheral(self, pname, pmod):
526526
raise SvdPatchError("derive: incorrect syntax for {}".format(pname))
527527
ptag = parent.find("./peripheral[name='{}']".format(pname))
528528
derived = parent.find("./peripheral[name='{}']".format(pderive))
529-
if derived is None:
529+
if (not ("." in pderive)) and (derived is None):
530530
raise SvdPatchError("peripheral {} not found".format(pderive))
531531
if ptag is None:
532532
ptag = ET.SubElement(parent, "register")

0 commit comments

Comments
 (0)