Complete the code to import the SPI library for Raspberry Pi.
import [1]
The spidev library is used to control SPI devices on Raspberry Pi.
Complete the code to open SPI bus 0, device 0.
spi = spidev.SpiDev() spi.[1](0, 0)
The open method opens the SPI bus and device for communication.
Fix the error in the code to send data [0xAA, 0xBB] over SPI.
data = [0xAA, 0xBB] spi.[1](data)
The writebytes method sends a list of bytes over SPI without reading response.
Fill both blanks to set SPI max speed to 1 MHz and mode to 0.
spi.max_speed_hz = [1] spi.mode = [2]
SPI max speed is set in Hz, so 1 MHz is 1000000. Mode 0 means clock polarity and phase are zero.
Fill all three blanks to create a dictionary comprehension that maps each byte in data to its hex string if byte is greater than 0x80.
result = [1]: hex([2]) for [3] in data if [2] > 0x80
The dictionary comprehension uses b as key, b as value after converting to hex, and iterates with b over data.
