-
Notifications
You must be signed in to change notification settings - Fork 87
Software SPI
SPI, or Serial Peripheral Interface, is a standard of synchronous serial communication (Wikipedia:SPI). These functions provide a software implementation.
Receives the given number of bits from a slave device, generating the clock signal on clk_pin and reading data from data_pin, and returns as an integer. bit_order sets the endianess of the data, and should be either MSBFIRST or LSBFIRST. edge is the edge which triggers the device to write the next bit.
Sends the given data to the slave, generating the clock signal on clk_pin and reading data from data_pin. bit_order sets the endianess of the data, and should be either MSBFIRST or LSBFIRST. edge is the edge which triggers the device to write the next bit.
In shiftOut(), data can be of type string or int, or can be a list containing any combination of strings and ints. Any value with more than one byte will be shifted out with the same byte-endianess as the given bit-endianess. Lists will be iterated in that order as well, e.g.
shiftOut(data_pin, clk_pin, MSBFIRST, ['a', 'bc', ['d', 'e']])
will send the same data as
shiftOut(data_pin, clk_pin, MSBFIRST, 'abcde')