diff options
author | Ayke van Laethem <[email protected]> | 2018-10-05 14:14:32 +0200 |
---|---|---|
committer | Ayke van Laethem <[email protected]> | 2018-10-06 13:04:14 +0200 |
commit | bc9210b6740dc7ff9146238ccb5b4014965a92cd (patch) | |
tree | 4bc7f0bf265100197129d74f19e7ae90ae0d9113 /tools | |
parent | e4fa1a8288f7f0d539cbf0df26d554cac89ab8a6 (diff) | |
download | tinygo-bc9210b6740dc7ff9146238ccb5b4014965a92cd.tar.gz tinygo-bc9210b6740dc7ff9146238ccb5b4014965a92cd.zip |
nrf: add micro:bit board
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/gen-device-svd.py | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/tools/gen-device-svd.py b/tools/gen-device-svd.py index ab361d139..0fd1ecf47 100755 --- a/tools/gen-device-svd.py +++ b/tools/gen-device-svd.py @@ -54,19 +54,16 @@ def readSVD(path, sourceURL): if groupNameTags: groupName = getText(groupNameTags[0]) - for interrupt in periphEl.findall('interrupt'): + interruptEls = periphEl.findall('interrupt') + for interrupt in interruptEls: intrName = getText(interrupt.find('name')) intrIndex = int(getText(interrupt.find('value'))) - if intrName in interrupts: - if interrupts[intrName]['index'] != intrIndex: - raise ValueError('interrupt with the same name has different indexes: ' + intrName) - interrupts[intrName]['description'] += ' // ' + description - else: - interrupts[intrName] = { - 'name': intrName, - 'index': intrIndex, - 'description': description, - } + addInterrupt(interrupts, intrName, intrIndex, description) + # As a convenience, also use the peripheral name as the interrupt + # name. Only do that for the nrf for now, as the stm32 .svd files + # don't always put interrupts in the correct peripheral... + if len(interruptEls) == 1 and deviceName.startswith('nrf'): + addInterrupt(interrupts, name, intrIndex, description) if periphEl.get('derivedFrom') or groupName in groups: if periphEl.get('derivedFrom'): @@ -150,6 +147,20 @@ def readSVD(path, sourceURL): return device +def addInterrupt(interrupts, intrName, intrIndex, description): + if intrName in interrupts: + if interrupts[intrName]['index'] != intrIndex: + raise ValueError('interrupt with the same name has different indexes: %s (%d vs %d)' + % (intrName, interrupts[intrName]['index'], intrIndex)) + if description not in interrupts[intrName]['description'].split(' // '): + interrupts[intrName]['description'] += ' // ' + description + else: + interrupts[intrName] = { + 'name': intrName, + 'index': intrIndex, + 'description': description, + } + def parseRegister(groupName, regEl, baseAddress, bitfieldPrefix=''): regName = getText(regEl.find('name')) regDescription = getText(regEl.find('description')) @@ -400,8 +411,10 @@ Default_Handler: '''.format(**device.metadata)) num = 0 for intr in device.interrupts: + if intr['index'] == num - 1: + continue if intr['index'] < num: - raise ValueError('interrupt numbers are not sorted or contain a duplicate') + raise ValueError('interrupt numbers are not sorted') while intr['index'] > num: out.write(' .long 0\n') num += 1 |