modm_data.cubemx.peripherals

  1# Copyright 2017, Niklas Hauser
  2# SPDX-License-Identifier: MPL-2.0
  3
  4stm_peripherals = \
  5{
  6    'adc': [{
  7        'instances': '*',
  8        'groups': [
  9            {
 10                'hardware': 'stm32-f0',
 11                'features': [],
 12                'protocols': ['analog-in'],
 13                'devices': [{'family': ['f0']}]
 14            },{
 15                'hardware': 'stm32-l0',
 16                'features': ['oversampler', 'calfact', 'prescaler'],
 17                'protocols': ['analog-in'],
 18                'devices': [{'family': ['l0']}]
 19            },{
 20                'hardware': 'stm32-g0',
 21                'features': ['oversampler', 'calfact', 'prescaler'],
 22                'protocols': ['analog-in'],
 23                'devices': [{'family': ['g0']}]
 24            },{
 25                # F373 & F378 has a non-special ADC
 26                'hardware': 'stm32',
 27                'features': [],
 28                'protocols': ['analog-in'],
 29                'devices': [{'family': ['f3'], 'name': ['73', '78']}]
 30            },{
 31                'hardware': 'stm32-f3',
 32                'features': [],
 33                'protocols': ['analog-in'],
 34                'devices': [{'family': ['f3', 'l4', 'l5', 'g4', 'wb']}]
 35            },{
 36                'hardware': 'stm32-h7',
 37                'features': [],
 38                'protocols': ['analog-in'],
 39                'devices': [{'family': ['h7']}]
 40            },{
 41                'hardware': 'stm32',
 42                'features': [],
 43                'protocols': ['analog-in'],
 44                'devices': '*'
 45            }
 46        ]
 47    }],
 48    'sdadc': [{
 49        'instances': '*',
 50        'groups': [
 51            {
 52                'hardware': 'stm32-f3',
 53                'features': [],
 54                'protocols': ['analog-in'],
 55                'devices': [{'family': ['f3']}]
 56            }
 57        ]
 58    }],
 59    'can': [{
 60        'instances': '*',
 61        'groups': [
 62            {
 63                # 14 shared filters
 64                'hardware': 'stm32',
 65                'features': ['filter-14'],
 66                'protocols': ['can-v2.0a', 'can-v2.0b'],
 67                'devices': [{'family': ['f0', 'g0', 'f1']}]
 68            },{
 69                # 28 shared filters
 70                'hardware': 'stm32',
 71                'features': ['filter-28'],
 72                'protocols': ['can-v2.0a', 'can-v2.0b'],
 73                'devices': '*'
 74            }
 75        ]
 76    }],
 77    'fdcan': [{
 78        'instances': '*',
 79        'groups': [
 80            {
 81                'hardware': 'stm32-h7',
 82                'features': [],
 83                'protocols': [],
 84                'devices': [{'family': ['h7']}]
 85            },{
 86                'hardware': 'stm32',
 87                'features': [],
 88                'protocols': [],
 89                'devices': '*'
 90            }
 91        ]
 92    }],
 93    'crc': [{
 94        'instances': '*',
 95        'groups': [
 96            {
 97                # Custom polynomial and reverse data
 98                'hardware': 'stm32',
 99                'features': ['polynomial', 'reverse'],
100                'protocols': ['crc32'],
101                'devices': [{'family': ['f0', 'f3', 'f7', 'h7', 'l5', 'u5']}]
102            },{
103                # Custom polynomial and reverse data
104                'hardware': 'stm32',
105                'features': ['reverse'],
106                'protocols': ['crc32'],
107                'devices': [{'family': ['g0', 'g4']}]
108            },{
109                # no poly size
110                'hardware': 'stm32',
111                'features': [],
112                'protocols': ['crc32'],
113                'devices': '*'
114            }
115        ]
116    }],
117    'dma': [{
118        'instances': '*',
119        'groups': [
120            {
121                'hardware': 'stm32-mux',
122                'features': [],
123                'protocols': ['mem2mem', 'mem2per', 'per2per'],
124                'devices': [{'family': ['g0', 'g4', 'l5', 'wb', 'wl']}, {'family': ['l4'], 'name': ['p5', 'p7', 'p9', 'q5', 'q7', 'q9', 'r5', 'r7', 'r9', 's5', 's7', 's9']}]
125            },
126            {
127                'hardware': 'stm32-mux-stream',
128                'features': [],
129                'protocols': ['mem2mem', 'mem2per', 'per2per'],
130                'devices': [{'family': ['h7']}]
131            },
132            {
133                'hardware': 'stm32-stream-channel',
134                'features': [],
135                'protocols': ['mem2mem', 'mem2per', 'per2per'],
136                'devices': [{'family': ['f2', 'f4', 'f7']}]
137            },
138            {
139                'hardware': 'stm32-channel-request',
140                'features': [],
141                'protocols': ['mem2mem', 'mem2per', 'per2per'],
142                'devices': [{'family': ['l0', 'l4']}, {'family': ['f0'], 'name': ['91', '98']}, {'family': ['f0'], 'name': ['30'], 'size': ['c']}]
143            },
144            {
145                'hardware': 'stm32-channel',
146                'features': [],
147                'protocols': ['mem2mem', 'mem2per', 'per2per'],
148                'devices': '*'
149            }
150        ]
151    }],
152    'iwdg': [{
153        'instances': '*',
154        'groups': [
155            {
156                'hardware': 'stm32',
157                'features': ['window'],
158                'protocols': [],
159                'devices': [{'family': ['f0', 'f3', 'f7', 'g0', 'g4', 'l5', 'u5', 'wb']}]
160            },{
161                'hardware': 'stm32',
162                'features': [],
163                'protocols': [],
164                'devices': '*'
165            }
166        ]
167    }],
168    'spi': [{
169        'instances': '*',
170        'groups': [
171            {
172                'hardware': 'stm32',
173                'features': ['data-size', 'nss-pulse', 'fifo'],
174                'protocols': [],
175                'devices': [{'family': ['f0', 'g0', 'f3', 'f7', 'l4', 'l5', 'g4', 'wb']}]
176            },{
177                'hardware': 'stm32-extended',
178                'features': [],
179                'protocols': [],
180                'devices': [{'family': ['h7', 'u5']}]
181            },{
182                'hardware': 'stm32',
183                'features': [],
184                'protocols': [],
185                'devices': '*'
186            }
187        ]
188    }],
189    'dac': [{
190        'instances': '*',
191        'groups': [
192            {
193                'hardware': 'stm32',
194                'features': [],
195                'protocols': [],
196                'devices': [{'family': ['f1']}]
197            },{
198                'hardware': 'stm32',
199                'features': ['status'],
200                'protocols': [],
201                'devices': '*'
202            }
203        ]
204    }],
205    'dcmi': [{
206        'instances': '*',
207        'groups': [
208            {
209                'hardware': 'stm32',
210                'features': [],
211                'protocols': [],
212                'devices': '*'
213            }
214        ]
215    }],
216    'dsi': [{
217        'instances': '*',
218        'groups': [
219            {
220                'hardware': 'stm32',
221                'features': [],
222                'protocols': [],
223                'devices': '*'
224            }
225        ]
226    }],
227    'sdio': [{
228        'instances': '*',
229        'groups': [
230            {
231                'hardware': 'stm32',
232                'features': [],
233                'protocols': [],
234                'devices': '*'
235            }
236        ]
237    }],
238    'tim': [
239        {
240            'instances': ['1', '8', '20'],
241            'groups': [
242                {
243                    'hardware': 'stm32-advanced',
244                    'features': [],
245                    'protocols': [],
246                    'devices': '*'
247                }
248            ]
249        },{
250            'instances': ['2', '3', '4', '5'],
251            'groups': [
252                {
253                    'hardware': 'stm32-general-purpose',
254                    'features': [],
255                    'protocols': [],
256                    'devices': '*'
257                }
258            ]
259        },{
260            'instances': ['9', '10', '11', '12', '13', '14', '15', '16', '17'],
261            'groups': [
262                {
263                    'hardware': 'stm32-general-purpose',
264                    'features': [],
265                    'protocols': [],
266                    'devices': '*'
267                }
268            ]
269        },{
270            'instances': ['6', '7'],
271            'groups': [
272                {
273                    'hardware': 'stm32-basic',
274                    'features': [],
275                    'protocols': [],
276                    'devices': '*'
277                }
278            ]
279        }
280    ],
281    'sys': [{
282        'instances': '*',
283        'groups': [
284            {
285                # Registers are called AFIO, not SYS!
286                'hardware': 'stm32-f1',
287                'features': ['exti', 'remap'],
288                'protocols': [],
289                'devices': [{'family': ['f1']}]
290            },{
291                'hardware': 'stm32',
292                'features': ['exti', 'fpu', 'ccm-wp', 'cfgr2'],
293                'protocols': [],
294                'devices': [{'family': ['f3', 'g4']}]
295            },{
296                'hardware': 'stm32',
297                'features': ['exti', 'sram2-wp', 'cfgr2', 'imr'],
298                'protocols': [],
299                'devices': [{'family': ['l5', 'wb']}]
300            },{
301                'hardware': 'stm32',
302                'features': ['exti', 'cfgr2', 'itline'],
303                'protocols': [],
304                'devices': [{'family': ['f0'], 'name': ['91', '98']}, {'family': ['g0']}]
305            },{
306                'hardware': 'stm32',
307                'features': ['exti', 'cfgr2'],
308                'protocols': [],
309                'devices': [{'family': ['f0']}]
310            },{
311                'hardware': 'stm32',
312                'features': ['exti'],
313                'protocols': [],
314                'devices': '*'
315            }
316        ]
317    }],
318    'dma2d': [{
319        'instances': '*',
320        'groups': [
321            {
322                'hardware': 'stm32',
323                'features': [],
324                'protocols': ['2d', 'blitter'],
325                'devices': '*'
326            }
327        ]
328    }],
329    'rng': [{
330        'instances': '*',
331        'groups': [
332            {
333                'hardware': 'stm32',
334                'features': [],
335                'protocols': [],
336                'devices': '*'
337            }
338        ]
339    }],
340    'i2c': [
341        {
342            # F1/F2/F4/L1 standard I2C with SMBus support
343            'instances': '*',
344            'groups': [
345                {
346                    # Some F4 have a digital noise filter
347                    'hardware': 'stm32',
348                    'features': ['dnf'],
349                    'protocols': ['i2c-v3.0', 'smb-v2.0', 'pmb-v1.1'],
350                    'devices': [{'family': ['f4'], 'name': ['27', '29', '37', '39', '46', '69', '79']}]
351                },{
352                    'hardware': 'stm32',
353                    'features': [],
354                    'protocols': ['i2c-v3.0', 'smb-v2.0', 'pmb-v1.1'],
355                    'devices': [{'family': ['f1', 'f2', 'f4', 'l1']}]
356                }
357            ]
358        },{
359            # F0/F3/F7/L0/L4/L4+/H7 extended I2C instance 2 with optional FM+ and SMBus support
360            'instances': ['2'],
361            'groups': [
362                {
363                    # This hardware supports neither FM+ (1 Mhz) nor SMBus
364                    'hardware': 'stm32-extended',
365                    'features': ['dnf'],
366                    'protocols': ['i2c-v3.0'],
367                    'devices': [
368                        {
369                            'family': ['f0'],
370                            'name': ['30', '31', '38', '51', '58']
371                        },{
372                            'family': ['f0'],
373                            'name': ['70'],
374                            'size': ['b']
375                        }
376                    ]
377                },{
378                    # This hardware supports FM+ (1 Mhz) but not SMBus
379                    'hardware': 'stm32-extended',
380                    'features': ['dnf', 'fmp'],
381                    'protocols': ['i2c-v3.0'],
382                    'devices': [{'family': ['f0', 'g0', 'l0']}]
383                },{
384                    # This hardware supports FM+ (1 Mhz) and SMBus
385                    'hardware': 'stm32-extended',
386                    'features': ['dnf', 'fmp'],
387                    'protocols': ['i2c-v3.0', 'smb-v2.0', 'pmb-v1.1'],
388                    'devices': [{'family': ['f3', 'f7', 'l4', 'l5', 'h7', 'g4', 'u5', 'wb']}]
389                }
390            ]
391        },{
392            # F0/F3/F7/L0/L4/L4+/H7 extended I2C with FM+ and SMBus support
393            'instances': ['1', '3', '4'],
394            'groups': [
395                {
396                    # This hardware supports FM+ (1 Mhz) and SMBus
397                    'hardware': 'stm32-extended',
398                    'features': ['dnf', 'fmp'],
399                    'protocols': ['i2c-v3.0', 'smb-v2.0', 'pmb-v1.1'],
400                    'devices': [{'family': ['f0', 'g0', 'f3', 'f7', 'l0', 'l4', 'l5', 'h7', 'g4', 'u5', 'wb']}]
401                }
402            ]
403        }
404    ],
405    'uart': [{
406        'instances': '*',
407        'groups': [
408            {
409                'hardware': 'stm32-extended',
410                'features': ['wakeup'],
411                'protocols': ['uart'],
412                'devices': [{'family': ['f0', 'f3']}]
413            },{
414                'hardware': 'stm32-extended',
415                'features': ['tcbgt'],
416                'protocols': ['uart'],
417                'devices': [{'family': ['l4'], 'name': ['p5', 'p7', 'p9', 'q5', 'q7', 'q9', 'r5', 'r7', 'r9', 's5', 's7', 's9']}, {'family': ['g0', 'g4', 'wb', 'h7', 'l5', 'u5']}]
418            },{
419                'hardware': 'stm32-extended',
420                'features': [],
421                'protocols': ['uart'],
422                'devices': [{'family': ['f7', 'l4']}]
423            },{
424                'hardware': 'stm32',
425                'features': ['over8'],
426                'protocols': ['uart'],
427                'devices': [{'family': ['f2', 'f4']}]
428            },{
429                'hardware': 'stm32',
430                'features': [],
431                'protocols': ['uart'],
432                'devices': '*'
433            }
434        ]
435    }],
436    'usart': [{
437        'instances': '*',
438        'groups': [
439            {
440                'hardware': 'stm32-extended',
441                'features': ['wakeup'],
442                'protocols': ['uart', 'spi'],
443                'devices': [{'family': ['f0', 'f3']}]
444            },{
445                'hardware': 'stm32-extended',
446                'features': ['tcbgt'],
447                'protocols': ['uart', 'spi'],
448                'devices': [{'family': ['l4'], 'name': ['p5', 'p7', 'p9', 'q5', 'q7', 'q9', 'r5', 'r7', 'r9', 's5', 's7', 's9']}, {'family': ['g0', 'g4', 'wb', 'h7', 'l5', 'u5']}]
449            },{
450                'hardware': 'stm32-extended',
451                'features': [],
452                'protocols': ['uart', 'spi'],
453                'devices': [{'family': ['f7', 'l4']}]
454            },{
455                'hardware': 'stm32-extended',
456                'features': ['over8'],
457                'protocols': ['uart', 'spi'],
458                'devices': [{'family': ['l0']}]
459            },{
460                'hardware': 'stm32',
461                'features': ['over8'],
462                'protocols': ['uart', 'spi'],
463                'devices': [{'family': ['f2', 'f4']}]
464            },{
465                'hardware': 'stm32',
466                'features': [],
467                'protocols': ['uart', 'spi'],
468                'devices': '*'
469            }
470        ]
471    }],
472    'gpio': [{
473        'instances': '*',
474        'groups': [
475            {
476                # The F1 remaps groups of pins
477                'hardware': 'stm32-f1',
478                'features': [],
479                'protocols': ['digital-in', 'digital-out', 'open-drain', 'exti'],
480                'devices': [{'family': ['f1']}]
481            },{
482                # The rest remaps pins individually
483                'hardware': 'stm32',
484                'features': [],
485                'protocols': ['digital-in', 'digital-out', 'open-drain', 'exti'],
486                'devices': '*'
487            }
488        ]
489    }]
490}
491
492def _get_index_for_id(merge_group, did):
493    for group in merge_group:
494        if all(did[key] in value for key, value in group.items()):
495            return merge_group.index(group)
496    return -1
497
498def getPeripheralData(did, module):
499    name, inst, version = module
500    if name in stm_peripherals:
501        for instance_list in stm_peripherals[name]:
502            if instance_list['instances'] == '*' or inst[len(name):] in instance_list['instances']:
503                for group in instance_list['groups']:
504                    if group['devices'] == '*' or _get_index_for_id(group['devices'], did) >= 0:
505                        return (group['hardware'], group['features'], group['protocols'])
506
507    return ('stm32-' + version, [], [])
stm_peripherals = {'adc': [{'instances': '*', 'groups': [{'hardware': 'stm32-f0', 'features': [], 'protocols': ['analog-in'], 'devices': [{'family': ['f0']}]}, {'hardware': 'stm32-l0', 'features': ['oversampler', 'calfact', 'prescaler'], 'protocols': ['analog-in'], 'devices': [{'family': ['l0']}]}, {'hardware': 'stm32-g0', 'features': ['oversampler', 'calfact', 'prescaler'], 'protocols': ['analog-in'], 'devices': [{'family': ['g0']}]}, {'hardware': 'stm32', 'features': [], 'protocols': ['analog-in'], 'devices': [{'family': ['f3'], 'name': ['73', '78']}]}, {'hardware': 'stm32-f3', 'features': [], 'protocols': ['analog-in'], 'devices': [{'family': ['f3', 'l4', 'l5', 'g4', 'wb']}]}, {'hardware': 'stm32-h7', 'features': [], 'protocols': ['analog-in'], 'devices': [{'family': ['h7']}]}, {'hardware': 'stm32', 'features': [], 'protocols': ['analog-in'], 'devices': '*'}]}], 'sdadc': [{'instances': '*', 'groups': [{'hardware': 'stm32-f3', 'features': [], 'protocols': ['analog-in'], 'devices': [{'family': ['f3']}]}]}], 'can': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': ['filter-14'], 'protocols': ['can-v2.0a', 'can-v2.0b'], 'devices': [{'family': ['f0', 'g0', 'f1']}]}, {'hardware': 'stm32', 'features': ['filter-28'], 'protocols': ['can-v2.0a', 'can-v2.0b'], 'devices': '*'}]}], 'fdcan': [{'instances': '*', 'groups': [{'hardware': 'stm32-h7', 'features': [], 'protocols': [], 'devices': [{'family': ['h7']}]}, {'hardware': 'stm32', 'features': [], 'protocols': [], 'devices': '*'}]}], 'crc': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': ['polynomial', 'reverse'], 'protocols': ['crc32'], 'devices': [{'family': ['f0', 'f3', 'f7', 'h7', 'l5', 'u5']}]}, {'hardware': 'stm32', 'features': ['reverse'], 'protocols': ['crc32'], 'devices': [{'family': ['g0', 'g4']}]}, {'hardware': 'stm32', 'features': [], 'protocols': ['crc32'], 'devices': '*'}]}], 'dma': [{'instances': '*', 'groups': [{'hardware': 'stm32-mux', 'features': [], 'protocols': ['mem2mem', 'mem2per', 'per2per'], 'devices': [{'family': ['g0', 'g4', 'l5', 'wb', 'wl']}, {'family': ['l4'], 'name': ['p5', 'p7', 'p9', 'q5', 'q7', 'q9', 'r5', 'r7', 'r9', 's5', 's7', 's9']}]}, {'hardware': 'stm32-mux-stream', 'features': [], 'protocols': ['mem2mem', 'mem2per', 'per2per'], 'devices': [{'family': ['h7']}]}, {'hardware': 'stm32-stream-channel', 'features': [], 'protocols': ['mem2mem', 'mem2per', 'per2per'], 'devices': [{'family': ['f2', 'f4', 'f7']}]}, {'hardware': 'stm32-channel-request', 'features': [], 'protocols': ['mem2mem', 'mem2per', 'per2per'], 'devices': [{'family': ['l0', 'l4']}, {'family': ['f0'], 'name': ['91', '98']}, {'family': ['f0'], 'name': ['30'], 'size': ['c']}]}, {'hardware': 'stm32-channel', 'features': [], 'protocols': ['mem2mem', 'mem2per', 'per2per'], 'devices': '*'}]}], 'iwdg': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': ['window'], 'protocols': [], 'devices': [{'family': ['f0', 'f3', 'f7', 'g0', 'g4', 'l5', 'u5', 'wb']}]}, {'hardware': 'stm32', 'features': [], 'protocols': [], 'devices': '*'}]}], 'spi': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': ['data-size', 'nss-pulse', 'fifo'], 'protocols': [], 'devices': [{'family': ['f0', 'g0', 'f3', 'f7', 'l4', 'l5', 'g4', 'wb']}]}, {'hardware': 'stm32-extended', 'features': [], 'protocols': [], 'devices': [{'family': ['h7', 'u5']}]}, {'hardware': 'stm32', 'features': [], 'protocols': [], 'devices': '*'}]}], 'dac': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': [], 'protocols': [], 'devices': [{'family': ['f1']}]}, {'hardware': 'stm32', 'features': ['status'], 'protocols': [], 'devices': '*'}]}], 'dcmi': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': [], 'protocols': [], 'devices': '*'}]}], 'dsi': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': [], 'protocols': [], 'devices': '*'}]}], 'sdio': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': [], 'protocols': [], 'devices': '*'}]}], 'tim': [{'instances': ['1', '8', '20'], 'groups': [{'hardware': 'stm32-advanced', 'features': [], 'protocols': [], 'devices': '*'}]}, {'instances': ['2', '3', '4', '5'], 'groups': [{'hardware': 'stm32-general-purpose', 'features': [], 'protocols': [], 'devices': '*'}]}, {'instances': ['9', '10', '11', '12', '13', '14', '15', '16', '17'], 'groups': [{'hardware': 'stm32-general-purpose', 'features': [], 'protocols': [], 'devices': '*'}]}, {'instances': ['6', '7'], 'groups': [{'hardware': 'stm32-basic', 'features': [], 'protocols': [], 'devices': '*'}]}], 'sys': [{'instances': '*', 'groups': [{'hardware': 'stm32-f1', 'features': ['exti', 'remap'], 'protocols': [], 'devices': [{'family': ['f1']}]}, {'hardware': 'stm32', 'features': ['exti', 'fpu', 'ccm-wp', 'cfgr2'], 'protocols': [], 'devices': [{'family': ['f3', 'g4']}]}, {'hardware': 'stm32', 'features': ['exti', 'sram2-wp', 'cfgr2', 'imr'], 'protocols': [], 'devices': [{'family': ['l5', 'wb']}]}, {'hardware': 'stm32', 'features': ['exti', 'cfgr2', 'itline'], 'protocols': [], 'devices': [{'family': ['f0'], 'name': ['91', '98']}, {'family': ['g0']}]}, {'hardware': 'stm32', 'features': ['exti', 'cfgr2'], 'protocols': [], 'devices': [{'family': ['f0']}]}, {'hardware': 'stm32', 'features': ['exti'], 'protocols': [], 'devices': '*'}]}], 'dma2d': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': [], 'protocols': ['2d', 'blitter'], 'devices': '*'}]}], 'rng': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': [], 'protocols': [], 'devices': '*'}]}], 'i2c': [{'instances': '*', 'groups': [{'hardware': 'stm32', 'features': ['dnf'], 'protocols': ['i2c-v3.0', 'smb-v2.0', 'pmb-v1.1'], 'devices': [{'family': ['f4'], 'name': ['27', '29', '37', '39', '46', '69', '79']}]}, {'hardware': 'stm32', 'features': [], 'protocols': ['i2c-v3.0', 'smb-v2.0', 'pmb-v1.1'], 'devices': [{'family': ['f1', 'f2', 'f4', 'l1']}]}]}, {'instances': ['2'], 'groups': [{'hardware': 'stm32-extended', 'features': ['dnf'], 'protocols': ['i2c-v3.0'], 'devices': [{'family': ['f0'], 'name': ['30', '31', '38', '51', '58']}, {'family': ['f0'], 'name': ['70'], 'size': ['b']}]}, {'hardware': 'stm32-extended', 'features': ['dnf', 'fmp'], 'protocols': ['i2c-v3.0'], 'devices': [{'family': ['f0', 'g0', 'l0']}]}, {'hardware': 'stm32-extended', 'features': ['dnf', 'fmp'], 'protocols': ['i2c-v3.0', 'smb-v2.0', 'pmb-v1.1'], 'devices': [{'family': ['f3', 'f7', 'l4', 'l5', 'h7', 'g4', 'u5', 'wb']}]}]}, {'instances': ['1', '3', '4'], 'groups': [{'hardware': 'stm32-extended', 'features': ['dnf', 'fmp'], 'protocols': ['i2c-v3.0', 'smb-v2.0', 'pmb-v1.1'], 'devices': [{'family': ['f0', 'g0', 'f3', 'f7', 'l0', 'l4', 'l5', 'h7', 'g4', 'u5', 'wb']}]}]}], 'uart': [{'instances': '*', 'groups': [{'hardware': 'stm32-extended', 'features': ['wakeup'], 'protocols': ['uart'], 'devices': [{'family': ['f0', 'f3']}]}, {'hardware': 'stm32-extended', 'features': ['tcbgt'], 'protocols': ['uart'], 'devices': [{'family': ['l4'], 'name': ['p5', 'p7', 'p9', 'q5', 'q7', 'q9', 'r5', 'r7', 'r9', 's5', 's7', 's9']}, {'family': ['g0', 'g4', 'wb', 'h7', 'l5', 'u5']}]}, {'hardware': 'stm32-extended', 'features': [], 'protocols': ['uart'], 'devices': [{'family': ['f7', 'l4']}]}, {'hardware': 'stm32', 'features': ['over8'], 'protocols': ['uart'], 'devices': [{'family': ['f2', 'f4']}]}, {'hardware': 'stm32', 'features': [], 'protocols': ['uart'], 'devices': '*'}]}], 'usart': [{'instances': '*', 'groups': [{'hardware': 'stm32-extended', 'features': ['wakeup'], 'protocols': ['uart', 'spi'], 'devices': [{'family': ['f0', 'f3']}]}, {'hardware': 'stm32-extended', 'features': ['tcbgt'], 'protocols': ['uart', 'spi'], 'devices': [{'family': ['l4'], 'name': ['p5', 'p7', 'p9', 'q5', 'q7', 'q9', 'r5', 'r7', 'r9', 's5', 's7', 's9']}, {'family': ['g0', 'g4', 'wb', 'h7', 'l5', 'u5']}]}, {'hardware': 'stm32-extended', 'features': [], 'protocols': ['uart', 'spi'], 'devices': [{'family': ['f7', 'l4']}]}, {'hardware': 'stm32-extended', 'features': ['over8'], 'protocols': ['uart', 'spi'], 'devices': [{'family': ['l0']}]}, {'hardware': 'stm32', 'features': ['over8'], 'protocols': ['uart', 'spi'], 'devices': [{'family': ['f2', 'f4']}]}, {'hardware': 'stm32', 'features': [], 'protocols': ['uart', 'spi'], 'devices': '*'}]}], 'gpio': [{'instances': '*', 'groups': [{'hardware': 'stm32-f1', 'features': [], 'protocols': ['digital-in', 'digital-out', 'open-drain', 'exti'], 'devices': [{'family': ['f1']}]}, {'hardware': 'stm32', 'features': [], 'protocols': ['digital-in', 'digital-out', 'open-drain', 'exti'], 'devices': '*'}]}]}
def getPeripheralData(did, module):
499def getPeripheralData(did, module):
500    name, inst, version = module
501    if name in stm_peripherals:
502        for instance_list in stm_peripherals[name]:
503            if instance_list['instances'] == '*' or inst[len(name):] in instance_list['instances']:
504                for group in instance_list['groups']:
505                    if group['devices'] == '*' or _get_index_for_id(group['devices'], did) >= 0:
506                        return (group['hardware'], group['features'], group['protocols'])
507
508    return ('stm32-' + version, [], [])