Hi guys ,
can someone show me some code on how to set a different length of bytes in to the string for the Shiftout command
the device on the SPI needs LSB to MSB , the number of bytes changes depending on the command sent and then the following amount of data bytes for that command
I only want to have 1 write command routine for all SPI writes and reads
was thinking something like this but cant seem to get the code right in my head to allow for the command to have changing number of bytes lengths in routine
the sample code here will only just add values of data_out(x) which is not going to work
need to have [data_out(0) , data_out(1) , data_out(2), etc ] format for the command to work correctly
cheers
Code:' ------ Rx Address for Pipe 0 ------ data_out[0]=Write_reg+Rx_addr_p0 'Rx address for pipe0 data_out[1]= $4E ' "N" '5 byte address data_out[2]= $45 ' "E" data_out[3]= $54 ' "T" data_out[4]= $01 ' "1" data_out[5]= $04 '"4" num_byte=5 gosub SPI_write SPI_write: CSN = 0 ' Chip enable For x = 0 to Num_byte ' loop for # byte temp_data_out = data_out(x) + temp_data_out next x Shiftout SI, SCK, MSBFIRST, [temp_data_out] ' Send write enable command CS = 1 ' Disable to execute command return




Bookmarks