|
STM32 core 3.0.1-dev
Arduino core for STM32 based boards: API reference
|
← STM32duino documentation
|
SPI controller or peripheral instance. More...
#include <SPI.h>
Public Member Functions | |
| SPIClass (pin_size_t mosi=MOSI, pin_size_t miso=MISO, pin_size_t sclk=SCK, pin_size_t ssel=PNUM_NOT_DEFINED) | |
| Construct an SPI instance using the given pins. | |
| void | setMISO (pin_size_t miso) |
| Set the MISO pin. | |
| void | setMOSI (pin_size_t mosi) |
| Set the MOSI pin. | |
| void | setSCLK (pin_size_t sclk) |
| Set the SCLK pin. | |
| void | setSSEL (pin_size_t ssel) |
| Set the SSEL pin. | |
| void | setMISO (PinName miso) |
| Set the MISO pin. | |
| void | setMOSI (PinName mosi) |
| Set the MOSI pin. | |
| void | setSCLK (PinName sclk) |
| Set the SCLK pin. | |
| void | setSSEL (PinName ssel) |
| Set the SSEL pin. | |
| void | begin (SPIBusMode busMode) |
| Initialize the SPI instance with the default parameters: 4 MHz, MSBFIRST, SPI_MODE0. | |
| void | begin () override |
| Initialize the SPI instance as controller (default bus mode) with the default parameters. | |
| void | end (void) override |
| Deinitialize the SPI instance and stop it. | |
| void | beginTransaction (SPISettings settings) override |
| Configure the SPI instance with the given settings, when the default parameters of begin() are not suitable. | |
| void | endTransaction (void) override |
| End the transaction started with beginTransaction(). | |
| uint8_t | transfer (uint8_t data, bool skipReceive) |
| Transfer one byte on the SPI bus. | |
| uint8_t | transfer (uint8_t data) override |
| Transfer one byte on the SPI bus and receive data. | |
| uint16_t | transfer16 (uint16_t data, bool skipReceive) |
| Transfer two bytes on the SPI bus in 16-bit format. | |
| uint16_t | transfer16 (uint16_t data) override |
| Transfer two bytes on the SPI bus in 16-bit format and receive data. | |
| void | transfer (void *buf, size_t count, bool skipReceive) |
| Transfer several bytes using one buffer to send and receive. | |
| void | transfer (void *buf, size_t count) override |
| Transfer several bytes using one buffer to send and receive data. | |
| void | transfer (const void *tx_buf, void *rx_buf, size_t count) |
| Transfer several bytes using one constant Tx buffer and one Rx buffer. | |
| void | usingInterrupt (int interruptNumber) override |
| Not implemented. | |
| void | notUsingInterrupt (int interruptNumber) override |
| Not implemented. | |
| void | attachInterrupt (void) override |
| Not implemented. | |
| void | detachInterrupt (void) override |
| Not implemented. | |
| SPI_HandleTypeDef * | getHandle (void) |
| Get the SPI handle to mix the Arduino API and the STM32Cube HAL API (e.g. | |
| void | attachSlaveInterrupt (uint8_t pin, voidFuncPtr callback) |
| Attach a callback on the falling edge of a pin. | |
| void | detachSlaveInterrupt (uint8_t pin) |
| Detach the callback attached with attachSlaveInterrupt(). | |
Protected Attributes | |
| spi_t | _spi |
| SPI instance data. | |
SPI controller or peripheral instance.
The default instance is SPI.
| SPIClass::SPIClass | ( | pin_size_t | mosi = MOSI, |
| pin_size_t | miso = MISO, |
||
| pin_size_t | sclk = SCK, |
||
| pin_size_t | ssel = PNUM_NOT_DEFINED |
||
| ) |
Construct an SPI instance using the given pins.
Default values are the pins of the default SPI peripheral defined in the variant. All pins must be attached to the same SPI peripheral, see the datasheet of the microcontroller.
| mosi | SPI MOSI pin. Accepted format: number, Arduino format (Dx) or ST format (Pxy). |
| miso | SPI MISO pin. Accepted format: number, Arduino format (Dx) or ST format (Pxy). |
| sclk | SPI clock pin. Accepted format: number, Arduino format (Dx) or ST format (Pxy). |
| ssel | Optional SPI SSEL pin, must be a hardware CS pin managed by the SPI peripheral itself (see PinMap_SPI_SSEL[] in the PeripheralPins.c file of the board and the datasheet of the microcontroller). If set, no other CS pin can be used and no CS pin must be passed to any function of the class. Default: not defined (no hardware SSEL). |
|
override |
Not implemented.
Kept for compatibility.
|
inline |
Attach a callback on the falling edge of a pin.
Dedicated to SPI slave (chip select detection).
| pin | Pin number. |
| callback | Function called on the falling edge. |
| void SPIClass::begin | ( | SPIBusMode | busMode | ) |
Initialize the SPI instance with the default parameters: 4 MHz, MSBFIRST, SPI_MODE0.
| busMode | Bus mode: SPI_CONTROLLER or SPI_PERIPHERAL. |
|
override |
Configure the SPI instance with the given settings, when the default parameters of begin() are not suitable.
| settings | SPI settings (clock speed, bit order, data mode, bus mode). |
|
override |
Not implemented.
Kept for compatibility.
|
inline |
Detach the callback attached with attachSlaveInterrupt().
| pin | Pin number. |
|
inline |
Get the SPI handle to mix the Arduino API and the STM32Cube HAL API (e.g.
DMA).
|
override |
Not implemented.
Kept for compatibility.
| interruptNumber | Unused. |
|
inline |
Set the MISO pin.
Must be called before begin().
| miso | MISO pin. Accepted format: number, Arduino format (Dx) or ST format (Pxy). |
|
inline |
|
inline |
Set the MOSI pin.
Must be called before begin().
| mosi | MOSI pin. Accepted format: number, Arduino format (Dx) or ST format (Pxy). |
|
inline |
|
inline |
Set the SCLK pin.
Must be called before begin().
| sclk | SCLK pin. Accepted format: number, Arduino format (Dx) or ST format (Pxy). |
|
inline |
|
inline |
Set the SSEL pin.
Must be called before begin().
| ssel | SSEL pin. Accepted format: number, Arduino format (Dx) or ST format (Pxy). |
|
inline |
| void SPIClass::transfer | ( | const void * | tx_buf, |
| void * | rx_buf, | ||
| size_t | count | ||
| ) |
Transfer several bytes using one constant Tx buffer and one Rx buffer.
begin() or beginTransaction() must be called at least once before. Expands the SPI API, see https://github.com/arduino/ArduinoCore-API/discussions/189
| tx_buf | Array of Tx bytes filled by the user before the transfer. If NULL, dummy 0xFF bytes are clocked out. |
| rx_buf | Array of Rx bytes filled by the peripheral during the transfer. If NULL, the received data is discarded. |
| count | Number of bytes to send/receive. |
|
inlineoverride |
Transfer one byte on the SPI bus and receive data.
begin() or beginTransaction() must be called at least once before.
| data | Byte to send. |
| uint8_t SPIClass::transfer | ( | uint8_t | data, |
| bool | skipReceive | ||
| ) |
Transfer one byte on the SPI bus.
begin() or beginTransaction() must be called at least once before.
| data | Byte to send. |
| skipReceive | true to skip receiving data (SPI_TRANSMITONLY), false to receive (SPI_TRANSMITRECEIVE). |
|
inlineoverride |
Transfer several bytes using one buffer to send and receive data.
begin() or beginTransaction() must be called at least once before.
| buf | Pointer to the bytes to send. The bytes received are copied in this buffer. |
| count | Number of bytes to send/receive. |
| void SPIClass::transfer | ( | void * | buf, |
| size_t | count, | ||
| bool | skipReceive | ||
| ) |
Transfer several bytes using one buffer to send and receive.
begin() or beginTransaction() must be called at least once before.
| buf | Pointer to the bytes to send. The bytes received are copied in this buffer. |
| count | Number of bytes to send/receive. |
| skipReceive | true to skip receiving data (SPI_TRANSMITONLY), false to receive (SPI_TRANSMITRECEIVE). |
|
inlineoverride |
Transfer two bytes on the SPI bus in 16-bit format and receive data.
begin() or beginTransaction() must be called at least once before.
| data | Bytes to send. |
| uint16_t SPIClass::transfer16 | ( | uint16_t | data, |
| bool | skipReceive | ||
| ) |
Transfer two bytes on the SPI bus in 16-bit format.
begin() or beginTransaction() must be called at least once before.
| data | Bytes to send. |
| skipReceive | true to skip receiving data (SPI_TRANSMITONLY), false to receive (SPI_TRANSMITRECEIVE). |
|
override |
Not implemented.
Kept for compatibility.
| interruptNumber | Unused. |