Reads and writes the SPI bus (as Controller).
| Constant | Meaning |
|---|---|
const uint8_tSPI_CONF::MSBFIRST |
MSB as the first bit |
const uint8_tSPI_CONF::LSBFIRST |
make LSB the first bit |
const uint8_tSPI_CONF::SPI_MODE0 |
set SPI MODE 0 |
const uint8_tSPI_CONF::SPI_MODE1 |
set to SPI MODE 1 |
const uint8_tSPI_CONF::SPI_MODE2 |
set to SPI MODE 2 |
const uint8_tSPI_CONF::SPI_MODE3 |
set to SPI MODE 3 |
The procedure for using the SPI bus depends on the begin() method.
Reads and writes the SPI bus (MASTER). ### begin()
void begin(uint8_t slave_select, SPISettings settings)
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode)Initialize hardware.
This process is also required after sleep recovery.
| Parameters | Description |
|---|---|
slave_select |
Specify the SPI slave select pin to be used. 0 : DIO19, 1 : DIO0 (DIO 19 is reserved), 2 : DIO1 (DIO 0,19 is reserved) |
settings |
Specifies the SPI bus setting. The clock[hz] specifies the SPI bus frequency. A divisor closer to the specified frequency will be selected: 16Mhz or 16Mhz divided by an even number. bitOrder specifies SPI_CONF::MSBFIRST or SPI_CONF::LSBFIRST. dataMode specifies SPI_CONF::SPIMODE0..3. |
void setup() {
...
SPI.begin(0, SPISettings(2000000, SPI_CONF::MSBFIRST, SPI_CONF::SPI_MODE3));
...
}
void wakeip() {
...
SPI.begin(0, SPISettings(2000000, SPI_CONF::MSBFIRST, SPI_CONF::SPI_MODE3));
...
}Terminate the use of SPI hardware.
There are two types of read/write procedures. Select and use one of them.
beginTransaction(), endTransaction(), transfer(), transfer16(), transfer32()transceiver