modm_data.cubehal

STMicro STM32CubeHAL Source Code

The STM32CubeHAL source code provides useful information:

  • Determine canonical names of conflicting data items.
  • Determine the map of register bit field values to names.
 1# Copyright 2022, Niklas Hauser
 2# SPDX-License-Identifier: MPL-2.0
 3
 4"""
 5# STMicro STM32CubeHAL Source Code
 6
 7The STM32CubeHAL source code provides useful information:
 8
 9- Determine canonical names of conflicting data items.
10- Determine the map of register bit field values to names.
11"""
12
13from .dmamux_requests import read_request_map, read_bdma_request_map
14
15__all__ = ["read_request_map", "read_bdma_request_map"]
def read_request_map(did: modm_data.kg.DeviceIdentifier) -> dict[str, int]:
17def read_request_map(did: DeviceIdentifier) -> dict[str, int]:
18    """
19    Reads the DMA requests mapping from the Low-Level (LL) CubeHAL header files.
20
21    :param did: Device to query for.
22    :return: A dictionary of DMA trigger name to trigger position.
23    """
24    dma_header = _get_hal_dma_header_path(did)
25    dmamux_header = _get_ll_dmamux_header_path(did)
26    request_map = None
27    if did.family in ["c0", "g4", "h7", "l5"]:
28        request_map = _read_requests(dma_header, _REQUEST_PATTERN)
29    elif did.family in ["g0", "u0", "wb", "wl"]:
30        request_map = _read_requests_from_ll_dmamux(dma_header, dmamux_header)
31    elif did.family == "l4" and did.name[0] in ["p", "q", "r", "s"]:
32        request_map = _read_requests_l4(dma_header, dmamux_header, did)
33    else:
34        raise RuntimeError("No DMAMUX request data available for {}".format(did))
35    _fix_request_data(request_map, "DMA")
36    return request_map

Reads the DMA requests mapping from the Low-Level (LL) CubeHAL header files.

Parameters
  • did: Device to query for.
Returns

A dictionary of DMA trigger name to trigger position.

def read_bdma_request_map(did):
39def read_bdma_request_map(did):
40    dma_header = _get_hal_dma_header_path(did)
41    request_map = _read_requests(dma_header, _BDMA_REQUEST_PATTERN)
42    _fix_request_data(request_map, "BDMA")
43    return request_map