#NEWLINE# def write( self , data , assert_ss = True , deassert_ss = True ) : #NEWLINE# #INDENT# 'Half-duplex SPI write.  If assert_ss is True, the SS line will be\n        asserted low, the specified bytes will be clocked out the MOSI line, and\n        if deassert_ss is True the SS line be put back high.\n        ' #NEWLINE# if ( self . _mosi is None ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Write attempted with no MOSI pin specified.' ) #NEWLINE# #UNINDENT# if ( assert_ss and ( self . _ss is not None ) ) : #NEWLINE# #INDENT# self . _gpio . set_low ( self . _ss ) #NEWLINE# #UNINDENT# for byte in data : #NEWLINE# #INDENT# for i in range ( 8 ) : #NEWLINE# #INDENT# if ( self . _write_shift ( byte , i ) & self . _mask ) : #NEWLINE# #INDENT# self . _gpio . set_high ( self . _mosi ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _gpio . set_low ( self . _mosi ) #NEWLINE# #UNINDENT# self . _gpio . output ( self . _sclk , ( not self . _clock_base ) ) #NEWLINE# self . _gpio . output ( self . _sclk , self . _clock_base ) #NEWLINE# #UNINDENT# #UNINDENT# if ( deassert_ss and ( self . _ss is not None ) ) : #NEWLINE# #INDENT# self . _gpio . set_high ( self . _ss )