Skip to content

Commit 69a214e

Browse files
committed
fixup: better understandable enable/disable decision tree
1 parent 98e7618 commit 69a214e

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

src/modm/platform/dma/stm32/module.lb

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def init(module):
2121
def prepare(module, options):
2222
device = options[":target"]
2323

24+
module.depends(":cmsis:device", ":platform:rcc")
25+
2426
if (not device.has_driver("dma")) or device.get_driver("dma")["type"] not in \
2527
[
2628
"stm32-channel-request",
@@ -31,37 +33,37 @@ def prepare(module, options):
3133
did = device.identifier
3234

3335
# Enable DMA for all but some devices...
34-
if not (
35-
(did["family"] in ["f0"]
36-
# STM32F09x has shared interrupts between DMA1 and DMA2, not supported...
37-
and did["name"] not in ["30", "71", "72", "78", "91", "98"])
38-
or (did["family"] in ["f1"] and
39-
(did["name"] in ["02", "05", "07"]
40-
or
41-
(did["name"] in ["00", "01", "03"]
42-
and did["pin"] in ["r", "v", "z"]
43-
and did["size"] in ["c", "d", "e", "f", "g"]
44-
)
45-
)
46-
)
47-
or (did["family"] in ["f3"] and
48-
did["name"] not in ["73", "78"]
49-
and
50-
(did["name"] in ["02"]
51-
and did["pin"] not in ["c"]
52-
and did["size"] not in ["b", "c"]
53-
)
54-
)
55-
or (did["family"] in ["l0"])
56-
or (did["family"] in ["l1"]
57-
and did["size"] not in ["c"])
58-
or (did["family"] in ["l4"])
59-
):
36+
37+
if did["family"] in ["f0"]:
38+
if did["name"] in ["30", "71", "72", "78", "91", "98"]:
39+
# STM32F09x has shared interrupts between DMA1 and DMA2, not supported...
40+
return False
41+
return True
42+
43+
if did["family"] in ["f1"]:
44+
if did["name"] in ["02", "05", "07"]:
45+
return True
46+
if did["name"] in ["00", "01", "03"] and did["pin"] in ["r", "v", "z"] and did["size"] in ["c", "d", "e", "f", "g"]:
47+
return True
6048
return False
6149

62-
module.depends(":cmsis:device", ":platform:rcc")
50+
if did["family"] in ["f3"]:
51+
if did["name"] in ["73", "78"]:
52+
return False
53+
if did["name"] in ["02"] and did["pin"] in ["c"] and did["size"] in ["b", "c"]:
54+
return False
55+
return True
56+
57+
if did["family"] in ["l0", "l4"]:
58+
return True
59+
60+
if did["family"] in ["l1"]:
61+
if did["size"] in ["c"]:
62+
return False
63+
return True
64+
65+
return False
6366

64-
return True
6567

6668
def build(env):
6769
device = env[":target"]

0 commit comments

Comments
 (0)