Skip to content

Commit a954974

Browse files
microbit-sammicrobit-carlos
authored andcommitted
WebUSB: Remove chip info magic numbers (#248)
1 parent cf80219 commit a954974

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

partial-flashing.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ let PartialFlashingUtils = {
5454
PC: 15
5555
},
5656

57+
// FICR Registers
58+
FICR: {
59+
CODEPAGESIZE: 0x10000000 | 0x10,
60+
CODESIZE: 0x10000000 | 0x14,
61+
},
62+
5763
read32FromUInt8Array: function(data, i) {
5864
return (data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | (data[i + 3] << 24)) >>> 0;
5965
},
@@ -643,6 +649,17 @@ let PartialFlashing = {
643649
.then(w => {
644650
window.dapwrapper = w;
645651
PartialFlashingUtils.log("Connection Complete");
652+
})
653+
.then(() => {
654+
return dapwrapper.cortexM.readMem32(PartialFlashingUtils.FICR.CODEPAGESIZE);
655+
})
656+
.then((pageSize) => {
657+
PartialFlashingUtils.pageSize = pageSize;
658+
659+
return dapwrapper.cortexM.readMem32(PartialFlashingUtils.FICR.CODESIZE);
660+
})
661+
.then((numPages) => {
662+
PartialFlashingUtils.numPages = numPages;
646663
});
647664
},
648665

0 commit comments

Comments
 (0)