Fixes #9
Adds per-peripheral interrupts. Simple list, functionality not otherwise described.
This commit is contained in:
parent
1126cf87aa
commit
38c403f205
45
parse.py
45
parse.py
@ -480,6 +480,7 @@ def parse_chips():
|
||||
package_names = expand_name(r['@RefName'])
|
||||
package_rams = r['Ram']
|
||||
package_flashs = r['Flash']
|
||||
die = r['Die']
|
||||
if type(package_rams) != list:
|
||||
package_rams = [package_rams]*len(package_names)
|
||||
if type(package_flashs) != list:
|
||||
@ -493,13 +494,17 @@ def parse_chips():
|
||||
|
||||
dma = next(filter(lambda x: x['@Name'] == 'DMA', r['IP']), None)
|
||||
bdma = next(filter(lambda x: x['@Name'] == 'BDMA', r['IP']), None)
|
||||
nvic = next(filter(lambda x: x['@Name'] == 'NVIC', r['IP']), None)
|
||||
|
||||
if nvic is None:
|
||||
nvic = next(filter(lambda x: x['@Name'] == 'NVIC1', r['IP']), None)
|
||||
|
||||
nvic = nvic['@Version']
|
||||
|
||||
if dma is not None:
|
||||
dma = dma['@Version']
|
||||
if bdma is not None:
|
||||
bdma = bdma['@Version']
|
||||
#dma = next(filter(lambda x: x['@Name'] == 'DMA', r['IP']), None)['@Version']
|
||||
#bdma = next(filter(lambda x: x['@Name'] == 'BDMA', r['IP']), None)['@Version']
|
||||
|
||||
rcc = next(filter(lambda x: x['@Name'] == 'RCC', r['IP']))['@Version']
|
||||
|
||||
@ -529,6 +534,7 @@ def parse_chips():
|
||||
'name': chip_name,
|
||||
'family': family,
|
||||
'line': r['@Line'],
|
||||
'die': die,
|
||||
'packages': [],
|
||||
'datasheet': None,
|
||||
'reference-manual': None,
|
||||
@ -541,6 +547,7 @@ def parse_chips():
|
||||
'rcc': rcc, # temporarily stashing it here
|
||||
'dma': dma, # temporarily stashing it here
|
||||
'bdma': bdma, # temporarily stashing it here
|
||||
'nvic': nvic # temporarily stashing it here
|
||||
})
|
||||
|
||||
chips[chip_name]['packages'].append(OrderedDict({
|
||||
@ -621,6 +628,9 @@ def parse_chips():
|
||||
chip_bdma = chip['bdma']
|
||||
del chip['bdma']
|
||||
|
||||
chip_nvic = chip['nvic']
|
||||
del chip['nvic']
|
||||
|
||||
h = find_header(chip_name)
|
||||
if h is None:
|
||||
raise Exception("missing header for {}".format(chip_name))
|
||||
@ -668,6 +678,11 @@ def parse_chips():
|
||||
if len(chip['pins'][pname]) > 0:
|
||||
p['pins'] = chip['pins'][pname]
|
||||
|
||||
if chip_nvic in chip_interrupts:
|
||||
if pname in chip_interrupts[chip_nvic]:
|
||||
# filter by available, because some are conditioned on <Die>
|
||||
p['interrupts'] = [ v for v in chip_interrupts[chip_nvic][pname] if v in interrupts ]
|
||||
|
||||
peris[pname] = p
|
||||
|
||||
family_extra = "data/extra/family/" + chip['family'] + ".yaml"
|
||||
@ -1050,6 +1065,32 @@ def match_peri_clock(rcc_block, peri_name):
|
||||
return match_peri_clock(rcc_block, removesuffix(peri_name, "1"))
|
||||
return None
|
||||
|
||||
chip_interrupts = {}
|
||||
|
||||
def parse_interrupts():
|
||||
print("parsing interrupts")
|
||||
for f in glob('sources/cubedb/mcu/IP/NVIC-*_Modes.xml'):
|
||||
ff = removeprefix(f, 'sources/cubedb/mcu/IP/NVIC-')
|
||||
ff = removesuffix(ff, '_Modes.xml')
|
||||
chip_irqs = {}
|
||||
r = xmltodict.parse(open(f, 'rb'))
|
||||
print(f)
|
||||
irqs = next(filter(lambda x: x['@Name'] == 'IRQn', r['IP']['RefParameter']))
|
||||
for irq in irqs['PossibleValue']:
|
||||
value = irq['@Value']
|
||||
parts = value.split(':')
|
||||
irq_name = removesuffix(parts[0], "_IRQn")
|
||||
peri_names = parts[2].split(',')
|
||||
if len(peri_names) == 1 and peri_names[0] == '':
|
||||
continue
|
||||
print(f'{peri_names} -> {irq_name}')
|
||||
for p in peri_names:
|
||||
if p not in chip_irqs:
|
||||
chip_irqs[p] = []
|
||||
chip_irqs[p].append( irq_name )
|
||||
chip_interrupts[ff] = chip_irqs
|
||||
|
||||
parse_interrupts()
|
||||
parse_rcc_regs()
|
||||
parse_documentations()
|
||||
parse_dma()
|
||||
|
Loading…
x
Reference in New Issue
Block a user