init(_:speed:csPin:CPOL:CPHA:bitOrder:)
Initializes a specified interface for SPI communication as a master device.
init(_ idName: Id, speed: Int = 5_000_000, csPin: DigitalOut? = nil, CPOL: Bool = false, CPHA: Bool = false, bitOrder: BitOrder = .MSB)
Parameters
- idName
REQUIRED Name/label for a physical pin which is associated with the I2C peripheral. See Id for the board in MadBoards library for reference.
- speed
OPTIONAL The clock speed for data transmission, 5_000_000 by default. It should not exceed the maximum supported speed by the device.
- csPin
OPTIONAL The digital output pin connected to slave device’s cs pin. When provided, the SPI interface will manage this CS pin for you. If it’s nil, you need to control it manually using any
DigitalOut
pin.- CPOL
OPTIONAL The state of SCK line when it’s idle,
false
by default.- CPHA
OPTIONAL The phase to sample data, false for the first edge of the clock pulse, true for the second edge.
false
by default.- bitOrder
OPTIONAL The bit order on data line, MSB by default.