#NEWLINE# def open( self ) : #NEWLINE# #INDENT# if self . _is_open : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# overlay = ( 'BB-SPIDEV%i' % self . bus ) #NEWLINE# cape_manager . load ( overlay , auto_unload = False ) #NEWLINE# bbio . common . delay ( 250 ) #NEWLINE# assert cape_manager . isLoaded ( path ) , 'Could not load SPI overlay' #NEWLINE# for i in glob . glob ( '/sys/bus/spi/devices/*.0' ) : #NEWLINE# #INDENT# path = os . path . realpath ( i ) #NEWLINE# module_addr = int ( path . split ( '/' ) [ 4 ] . split ( '.' ) [ 0 ] , 16 ) #NEWLINE# if ( module_addr == SPI_BASE_ADDRESSES [ self . bus ] ) : #NEWLINE# #INDENT# self . bus = int ( path . split ( '/' ) [ 6 ] [ ( - 1 ) ] ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# super ( SPIBus , self ) . open ( ) #NEWLINE# self . setCSActiveLow ( 0 ) #NEWLINE# self . setBitsPerWord ( 0 , 8 ) #NEWLINE# self . setMaxFrequency ( 0 , 8000000 ) #NEWLINE# self . setClockMode ( 0 , 0 ) #NEWLINE# self . _is_open = True