Merge pull request #55 from bobmcwhirter/dma-muckings

Dma muckings
This commit is contained in:
Dario Nieuwenhuis 2021-06-29 17:24:24 +02:00 committed by GitHub
commit 59e7d459e1
2 changed files with 22 additions and 4 deletions

View File

@ -1797,7 +1797,7 @@ fieldset/APB1RSTR:
- bit_offset: 17
bit_size: 1
description: USART 2 reset
name: UART2RST
name: USART2RST
- bit_offset: 21
bit_size: 1
description: I2C 1 reset

View File

@ -838,7 +838,7 @@ def parse_dma():
ff = removeprefix(f, 'sources/cubedb/mcu/IP/DMA-')
ff = removesuffix(ff, '_Modes.xml')
r = xmltodict.parse(open(f, 'rb'), force_list={'Mode'})
r = xmltodict.parse(open(f, 'rb'), force_list={'Mode', 'RefMode'})
chip_dma = {
'channels': {},
@ -886,6 +886,18 @@ def parse_dma():
'channel': i,
})
else:
# see if we can scrape out requests
requests = {}
request_blocks = filter(lambda x: x['@BaseMode'] == 'DMA_Request', r['IP']['RefMode'])
for block in request_blocks:
name = block['@Name']
request_num = next(filter(lambda x: x['@Name'] == 'Channel', block['Parameter']), None)
if request_num is not None:
request_num = request_num['PossibleValue']
request_num = removeprefix(request_num, "DMA_CHANNEL_")
requests[name] = int(request_num)
for channel in channels:
channel_name = channel['@Name']
channel_name = removeprefix(channel_name, dma_peri_name + '_')
@ -897,6 +909,7 @@ def parse_dma():
})
for target in channel['ModeLogicOperator']['Mode']:
target_name = target['@Name']
original_target_name = target_name
parts = target_name.split(':')
target_name = parts[0]
parts = target_name.split('_')
@ -914,10 +927,15 @@ def parse_dma():
event = event.split(':')[0]
if 'channels' not in peri_dma:
peri_dma['channels'] = {}
if event not in peri_dma:
if event not in peri_dma['channels']:
peri_dma['channels'][event] = []
event_dma = peri_dma['channels'][event]
event_dma.append(dma_peri_name + '_' + channel_name)
entry = OrderedDict({
'channel': dma_peri_name + '_' + channel_name,
} )
if original_target_name in requests:
entry['request'] = requests[original_target_name]
event_dma.append( entry )
dma_channels[ff] = chip_dma