Arduino Core for STM32  1.0
HardwareSPI.h File Reference

This file contains class with methods to handle SPI periphery. More...

#include "HardwareCRC.h"
Include dependency graph for HardwareSPI.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SPISettings
 Class, that holds SPI settings. More...
 
class  HardwareSPI
 This class is for handling SPI periphery. More...
 
class  HardwareSPI_O
 This class is for handling SPI periphery, but is more optimized for speed same as arduino SPI class. More...
 

Macros

#define SPI_HAS_TRANSACTION   1
 Macro contains 1 when SPI supports transactions. More...
 
#define SPI_CLOCK_DIV2   SPI_BAUDRATEPRESCALER_2
 
#define SPI_CLOCK_DIV4   SPI_BAUDRATEPRESCALER_4
 
#define SPI_CLOCK_DIV8   SPI_BAUDRATEPRESCALER_8
 
#define SPI_CLOCK_DIV16   SPI_BAUDRATEPRESCALER_16
 
#define SPI_CLOCK_DIV32   SPI_BAUDRATEPRESCALER_32
 
#define SPI_CLOCK_DIV64   SPI_BAUDRATEPRESCALER_64
 
#define SPI_CLOCK_DIV128   SPI_BAUDRATEPRESCALER_128
 
#define SPI_CLOCK_DIV256   SPI_BAUDRATEPRESCALER_256
 
#define SPI_MASTER   SPI_MODE_MASTER
 
#define SPI_SLAVE   SPI_MODE_SLAVE
 

Enumerations

enum  SPI_Status {
  SPI_OK = HAL_OK, SPI_ERR = HAL_ERROR, SPI_BUSY_ERR = HAL_BUSY, SPI_TIMEOUT = HAL_TIMEOUT,
  SPI_GEN_ERR, SPI_ERR_LOCKED, SPI_CRC_ERR
}
 Enumerations of SPI status codes. More...
 
enum  SPI_ErrorCode {
  SPI_ERROR_NONE = HAL_SPI_ERROR_NONE, SPI_ERROR_MODF = HAL_SPI_ERROR_MODF, SPI_ERROR_CRC = HAL_SPI_ERROR_CRC, SPI_ERROR_OVR = HAL_SPI_ERROR_OVR,
  SPI_ERROR_DMA = HAL_SPI_ERROR_DMA, SPI_ERROR_FLAG = HAL_SPI_ERROR_FLAG, SPI_ERROR_ABORT = HAL_SPI_ERROR_ABORT
}
 Enumerations of SPI Hardware error codes. More...
 
enum  SPI_CRCLength { SPI_CRC_DATAWIDTH = 0, SPI_CRC_1BYTE = 8, SPI_CRC_2BYTES = 16 }
 Enumerations of SPI CRC lengths. More...
 

Variables

const uint8_t SPI_MODE0 = 0x00
 CPOL: 0 CPHA: 0. More...
 
const uint8_t SPI_MODE1 = 0x01
 CPOL: 0 CPHA: 1. More...
 
const uint8_t SPI_MODE2 = 0x10
 CPOL: 1 CPHA: 0. More...
 
const uint8_t SPI_MODE3 = 0x11
 CPOL: 1 CPHA: 1. More...
 

Detailed Description

This file contains class with methods to handle SPI periphery.

Credits

Author
Cepko Patrik
Date
June 18, 2021
See also
SPISettings
Hardware I2C documentation

Credits

Author
Matej Fitoš
Date
June 18, 2021
See also
HardwareSPI
HardwareSPI_O
SPISettings
Hardware SPI documentation

Macro Definition Documentation

◆ SPI_HAS_TRANSACTION

#define SPI_HAS_TRANSACTION   1

Macro contains 1 when SPI supports transactions.

Note
Do not change!

Enumeration Type Documentation

◆ SPI_Status

enum SPI_Status

Enumerations of SPI status codes.

Note
Method getError() does not returns values from this enum, but uses SPI_ErrorCode.
See also
lastTransactionStatus()
Enumerator
SPI_OK 

Transaction was without known error.

SPI_ERR 

Error, that happened during ending of transaction.

SPI_BUSY_ERR 

SPI periphery is busy.

SPI_TIMEOUT 

SPI timeout was reached.

SPI_GEN_ERR 

SPI generic error.

This status indicates, that instance does not exists or current method cannot be called with current settings.

SPI_ERR_LOCKED 

SPI periphery is locked already.

SPI_CRC_ERR 

SPI CRC calculation error (see enableCRC())

◆ SPI_ErrorCode

Enumerations of SPI Hardware error codes.

Note
Method lastTransactionStatus() does not returns values from this enum, but uses SPI_Status.
See also
getError()
Enumerator
SPI_ERROR_NONE 

No error.

SPI_ERROR_MODF 

MODF (mode fault) error.

SPI_ERROR_CRC 

CRC error.

SPI_ERROR_OVR 

OVR (overrun) error.

SPI_ERROR_DMA 

DMA transfer error.

SPI_ERROR_FLAG 

Error on RXNE/TXE/BSY/FTLVL/FRLVL Flag.

SPI_ERROR_ABORT 

Error during SPI Abort procedure.

◆ SPI_CRCLength

Enumerations of SPI CRC lengths.

See also
setCRClength()
Enumerator
SPI_CRC_DATAWIDTH 

CRC size will be automatically aligned to data width, but data width have to be set to 8 or 16.

See also
setDataBits()
SPI_CRC_1BYTE 

CRC will be 8 bits wide.

SPI_CRC_2BYTES 

CRC will be 16 bits wide.