@@ -184,7 +184,9 @@ def add_pin(pin: GD32Pin, func: GD32PinFunction, function_bits:str, commented_ou
184184 @staticmethod
185185 def add_alt_pins (pin :GD32Pin , func :GD32PinFunction , function_bits , remapping_macros : any , commented_out :bool , alt : int = 0 ):
186186 retStr = ""
187- for remapping_macro in remapping_macros :
187+ for remapping_macro in remapping_macros .copy ():
188+ if "DISABLE" in remapping_macro [1 ]:
189+ remapping_macro = (remapping_macro [0 ], "0" )
188190 retStr += GD32PinMapGenerator .add_pin (
189191 pin , func , function_bits % remapping_macro , commented_out , alt = alt )
190192 alt += 1
@@ -197,7 +199,7 @@ def add_adc_pin(pin: GD32Pin, func: GD32PinFunction, mcu:GD32MCUInfo, context: a
197199 if func .family_type == "A" :
198200 remapping_macros = func .remapping_macros (mcu )
199201 context ["alt" ] += len (remapping_macros ) or 1
200- if len (remapping_macros ):
202+ if len (remapping_macros ) and not any ([ "DISABLE" in x for x in remapping_macros ]) :
201203 return GD32PinMapGenerator .add_alt_pins (
202204 pin , func , "GD_PIN_FUNC_ANALOG_CH(%d)" , [chan_num ] * len (remapping_macros ), False , alt )
203205 else :
@@ -224,7 +226,7 @@ def add_i2c_pin(pin: GD32Pin, func: GD32PinFunction, mcu: GD32MCUInfo, context)
224226 alt = context ["alt" ]
225227 remapping_macros = func .remapping_macros (mcu )
226228 context ["alt" ] += len (remapping_macros ) or 1
227- if remapping_macros and len (remapping_macros ):
229+ if remapping_macros and len (remapping_macros ) and not any ([ "DISABLE" in x for x in remapping_macros ]) :
228230 return GD32PinMapGenerator .add_alt_pins (pin , func , "GD_PIN_FUNCTION5(PIN_MODE_AF, PIN_OTYPE_PP, PIN_PUPD_PULLUP, %s)" , remapping_macros , False , alt )
229231 else :
230232 return GD32PinMapGenerator .add_pin (pin , func , "GPIO_MODE_AF_OD" , False )
@@ -244,7 +246,7 @@ def add_uart_pin(pin: GD32Pin, func: GD32PinFunction, mcu: GD32MCUInfo, context)
244246 alt = context ["alt" ]
245247 remapping_macros = func .remapping_macros (mcu )
246248 context ["alt" ] += len (remapping_macros ) or 1
247- if remapping_macros and len (remapping_macros ):
249+ if remapping_macros and len (remapping_macros ) and not any ([ "DISABLE" in x for x in remapping_macros ]) :
248250 return GD32PinMapGenerator .add_alt_pins (pin , func , "GD_PIN_FUNCTION5(PIN_MODE_AF, PIN_OTYPE_PP, PIN_PUPD_PULLUP, %s)" , remapping_macros , False , alt )
249251 elif func .family_type == "B" :
250252 if func .has_af_number ():
@@ -269,7 +271,7 @@ def add_standard_af_pin(pin: GD32Pin, func: GD32PinFunction, mcu: GD32MCUInfo, c
269271 alt = context ["alt" ]
270272 remapping_macros = func .remapping_macros (mcu )
271273 context ["alt" ] += len (remapping_macros ) or 1
272- if remapping_macros and len (remapping_macros ):
274+ if remapping_macros and len (remapping_macros ) and not any ([ "DISABLE" in x for x in remapping_macros ]) :
273275 return GD32PinMapGenerator .add_alt_pins (pin , func , "GD_PIN_FUNCTION5(PIN_MODE_AF, PIN_OTYPE_PP, PIN_PUPD_PULLUP, %s)" , remapping_macros , False , alt )
274276 elif func .family_type == "B" :
275277 af_num = func .af_number
0 commit comments