@@ -21,9 +21,7 @@ def prepare(module, options):
2121 if not options [":target" ].has_driver ("rcc:stm32*" ):
2222 return False
2323
24- module .depends (":cmsis:device" , ":utils" , ":platform:clock" )
25- # FIXME: Move Peripherals enum somewhere better
26- module .depends (":platform:gpio" )
24+ module .depends (":cmsis:device" , ":utils" , ":platform:clock" , ":platform:core" )
2725 return True
2826
2927def build (env ):
@@ -67,31 +65,18 @@ def build(env):
6765 properties ["pllsai_p_usb" ] = (target ["family" ] == "f7" ) or \
6866 ((target ["family" ] == "f4" ) and target ["name" ] in ["46" , "69" , "79" ])
6967
70- flash_latencies = {}
71- for vcore in device .get_driver ("flash" )["latency" ]:
72- flash_latencies [int (vcore ["vcore-min" ])] = sorted ([int (f ["hclk-max" ]) for f in vcore ["wait-state" ]])
73-
74- properties ["table" ] = flash_latencies
68+ properties ["table" ] = device .flash .wait_states
7569 env .substitutions = properties
7670 env .outbasepath = "modm/src/modm/platform/clock"
7771
7872 env .template ("rcc.cpp.in" )
7973 env .template ("rcc.hpp.in" )
8074
81- all_peripherals = set ()
82- all_drivers = [d for d in device ._properties ["driver" ] if d ["name" ] not in ["gpio" , "core" ]]
83- translate = lambda s : s .replace ("_" , "" ).capitalize ()
84- for d in all_drivers :
85- dname = translate (d ["name" ])
86- if "instance" in d :
87- all_peripherals .update (dname + translate (i ) for i in d ["instance" ])
88- else :
89- all_peripherals .add (dname )
90- all_peripherals = sorted (list (all_peripherals ))
91-
9275 rcc_map = env .query (":cmsis:device:rcc-map" )
9376 rcc_enable = {}
9477 rcc_reset = {}
78+ all_peripherals = uniquify (map (env .filter ("modm.fmt.driver" ), env [":target" ].peripherals ))
79+ all_peripherals_lut = {p .lower ():p for p in all_peripherals }
9580
9681 for per , mode in rcc_map .items ():
9782 nper = per
@@ -110,14 +95,14 @@ def build(env):
11095 if "Eth" in all_peripherals and per == "ETHMAC" :
11196 per = "Eth"
11297 # Fix USBOTG OTG
113- if "Usbotgfs " in all_peripherals and per .startswith ("OTG" ):
98+ if "UsbOtgFs " in all_peripherals and per .startswith ("OTG" ):
11499 if per == "OTGH" : per = "OTGHS" ;
115100 per = "USB" + per
116101 # print(per, mode)
117- if per .capitalize () not in all_peripherals :
102+ if per .lower () not in all_peripherals_lut :
118103 continue
119104 if "EN" in mode :
120- rcc_enable [per .capitalize () ] = (nper , mode ["EN" ])
105+ rcc_enable [all_peripherals_lut [ per .lower ()] ] = (nper , mode ["EN" ])
121106 if "RST" in mode :
122107 rcc_reset [nper ] = mode ["RST" ]
123108
0 commit comments