SPI controller. More...
#include <SPI.h>
Public Member Functions | |
SPIClass (int port) | |
Create SPIClass object. More... | |
void | begin (void) |
Initialize the SPI library. | |
void | end (void) |
Disable the SPI bus. | |
void | beginTransaction (SPISettings settings) |
Before using SPI.transfer() or asserting chip select pins, this function is used to gain exclusive access to the SPI bus and configure the correct settings. More... | |
void | endTransaction (void) |
After performing a group of transfers and releasing the chip select signal, this function allows others to access the SPI bus. | |
void | setBitOrder (uint8_t bitOrder) |
This function is deprecated. New applications should use beginTransaction() to configure SPI settings. More... | |
void | setDataMode (uint8_t dataMode) |
This function is deprecated. New applications should use beginTransaction() to configure SPI settings. More... | |
void | setClockDivider (uint8_t clockDiv) |
This function is deprecated. New applications should use beginTransaction() to configure SPI settings. More... | |
void | usingInterrupt (uint8_t interruptNumber) |
Register interrupt with the SPI library. More... | |
void | notUsingInterrupt (uint8_t interruptNumber) |
Disable interrupt with the SPI library. More... | |
uint8_t | transfer (uint8_t data) |
Write 8-bit data to the SPI bus and also receive 8-bit data. More... | |
uint16_t | transfer16 (uint16_t data) |
Write 16-bit data to the SPI bus and also receive 16-bit data. More... | |
void | transfer (void *buf, size_t count) |
Write data to the SPI bus and also receive data. More... | |
void | transfer16 (void *buf, size_t count) |
Write 16-bit data to the SPI bus and also receive data. More... | |
void | send (void *buf, size_t count) |
Write buffer to the SPI bus (only write transfer) More... | |
void | send16 (void *buf, size_t count) |
Write 16-bit buffer the SPI bus (only write transfer) More... | |
void | selectCS (int cs) |
Select chip select number (only for SPI3) More... | |
void | enableCS () |
Enable chip select by software (only for SPI3) More... | |
void | disableCS () |
Disable chip select by software (only for SPI3) More... | |
SPI controller.
You can control SPI comunication by operating SPIClass objects instantiated in your app.
SPIClass::SPIClass | ( | int | port | ) |
Create SPIClass object.
[in] | port | The default port is 4. You can control SPI4 using object SPI e.g. SPI.begin(); SPI5 is also supported. You can control SPI5 using object SPI5 e.g. SPI5.begin(); |
void SPIClass::beginTransaction | ( | SPISettings | settings | ) |
Before using SPI.transfer() or asserting chip select pins, this function is used to gain exclusive access to the SPI bus and configure the correct settings.
[in] | settings | SPISettings object |
void SPIClass::setBitOrder | ( | uint8_t | bitOrder | ) |
This function is deprecated. New applications should use beginTransaction() to configure SPI settings.
[in] | bitOrder | Bit order |
void SPIClass::setDataMode | ( | uint8_t | dataMode | ) |
This function is deprecated. New applications should use beginTransaction() to configure SPI settings.
[in] | dataMode | SPI mode |
void SPIClass::setClockDivider | ( | uint8_t | clockDiv | ) |
This function is deprecated. New applications should use beginTransaction() to configure SPI settings.
[in] | clockDiv | Clock divider |
void SPIClass::usingInterrupt | ( | uint8_t | interruptNumber | ) |
Register interrupt with the SPI library.
If SPI is used from within an interrupt, this function registers that interrupt with the SPI library, so beginTransaction() can prevent conflicts. The input interruptNumber is the number used with attachInterrupt. If SPI is used from a different interrupt (eg, a timer), interruptNumber should be 255.
[in] | interruptNumber | Interrupt number |
void SPIClass::notUsingInterrupt | ( | uint8_t | interruptNumber | ) |
Disable interrupt with the SPI library.
[in] | interruptNumber | Interrupt number |
uint8_t SPIClass::transfer | ( | uint8_t | data | ) |
Write 8-bit data to the SPI bus and also receive 8-bit data.
[in] | data | 8-bit data to send |
uint16_t SPIClass::transfer16 | ( | uint16_t | data | ) |
Write 16-bit data to the SPI bus and also receive 16-bit data.
[in] | data | 16-bit data to send |
void SPIClass::transfer | ( | void * | buf, |
size_t | count | ||
) |
Write data to the SPI bus and also receive data.
[in,out] | buf | Buffer to send and receive |
[in] | count | The number of bytes to transmit |
void SPIClass::transfer16 | ( | void * | buf, |
size_t | count | ||
) |
Write 16-bit data to the SPI bus and also receive data.
[in,out] | buf | Buffer to send and receive |
[in] | count | The number of 16-bit data to transmit |
void SPIClass::send | ( | void * | buf, |
size_t | count | ||
) |
Write buffer to the SPI bus (only write transfer)
[in] | buf | Buffer to send |
[in] | count | The number of bytes to transmit |
void SPIClass::send16 | ( | void * | buf, |
size_t | count | ||
) |
Write 16-bit buffer the SPI bus (only write transfer)
[in] | buf | Buffer to send |
[in] | count | The number of 16-bit data to transmit |
void SPIClass::selectCS | ( | int | cs | ) |
Select chip select number (only for SPI3)
[in] | cs | chip select number When SPI3_CS0_X is used, set cs to 0 (default). When SPI3_CS1_X is used, set cs to 1. |
void SPIClass::enableCS | ( | ) |
Enable chip select by software (only for SPI3)
void SPIClass::disableCS | ( | ) |
Disable chip select by software (only for SPI3)