@@ -337,6 +337,7 @@ def wildcard(self, compact=False):
337
337
f = "function"
338
338
v = "value"
339
339
values = {}
340
+ self .system_config = SystemConfig .getConfig ()
340
341
for i in self .pins + self .overlay_pins :
341
342
if compact :
342
343
func = self .getFunction (i )
@@ -360,9 +361,11 @@ def getFunctionString(self, channel):
360
361
pass
361
362
try :
362
363
# On Raspberry Pis using the spi_bcm2835 driver SPI chip select is done via software rather than hardware
363
- # so the pin function is OUT instead of ALT0. Here we override that if the SPI MOSI pin is set to ALT0
364
- # so the GPIO map in the UI will display the appropriate SPI pin info.
365
- if channel in self .chip_select_pins and f == 1 and self .getFunction (self .spi_mosi_pin ) == 4 :
364
+ # so the pin function is OUT instead of ALT0. Here we override that (and the I2C to be safe) so the GPIO map
365
+ # in the UI will display the appropriate pin info.
366
+ if channel in self .spi_pins and self .system_config ['SPI' ] == 1 :
367
+ function_string = functions [4 ]
368
+ if channel in self .i2c_pins and self .system_config ['I2C' ] == 1 :
366
369
function_string = functions [4 ]
367
370
except :
368
371
pass
@@ -626,16 +629,17 @@ def setPinMapping(self):
626
629
if isinstance (self .MAPPING , list ):
627
630
self .pins = []
628
631
self .overlay_pins = []
632
+ self .spi_pins = []
633
+ self .i2c_pins = []
634
+ self .system_config = SystemConfig .getConfig ()
629
635
for header in self .MAPPING :
630
636
self .pins .extend ([pin ['gpio' ] for pin in header ['map' ] if 'gpio' in pin ])
631
637
try :
632
638
if Hardware ().isRaspberryPi ():
633
- if SystemConfig . getConfig () ['OneWire' ] == 1 :
639
+ if self . system_config ['OneWire' ] == 1 :
634
640
self .overlay_pins .extend ([pin ['gpio' ] for pin in header ['map' ] if 'overlay' in pin and pin ['overlay' ]['channel' ] == 'sys:1wire' ])
635
641
self .pins = [pin for pin in self .pins if pin not in self .overlay_pins ]
636
- self .chip_select_pins = []
637
- self .spi_mosi_pin = 10
638
- for header in self .MAPPING :
639
- self .chip_select_pins .extend ([pin ['gpio' ] for pin in header ['map' ] if 'alt0' in pin and pin ['alt0' ]['name' ] in ('CE0' , 'CE1' )])
642
+ self .spi_pins .extend ([pin ['gpio' ] for pin in header ['map' ] if 'alt0' in pin and pin ['alt0' ]['channel' ] == 'sys:spi' ])
643
+ self .i2c_pins .extend ([pin ['gpio' ] for pin in header ['map' ] if 'alt0' in pin and pin ['alt0' ]['channel' ] == 'sys:i2c' ])
640
644
except :
641
645
pass
0 commit comments