HSPI Namespace Reference

Namespaces

 RAM
 
 Test
 

Classes

struct  IoModeInfo
 
struct  SpiPins
 SPI pin connections. More...
 
class  Controller
 Manages access to SPI hardware. More...
 
struct  Data
 Specifies a block incoming or outgoing data. More...
 
class  Device
 Manages a specific SPI device instance attached to a controller. More...
 
class  MemoryDevice
 Base class for read/write addressable devices. More...
 
struct  Request
 Defines an SPI Request Packet. More...
 
class  StreamAdapter
 Helper class for streaming data to/from SPI devices. More...
 

Typedefs

using IoModes = BitSet< uint16_t, IoMode, unsigned(IoMode::MAX)>
 
using ByteOrder = uint8_t
 
using BitOrder = uint8_t
 
using Callback = bool(*)(Request &request)
 SPI completion callback routine. More...
 

Enumerations

enum class  ClockMode : uint8_t { mode0 = 0x00 , mode1 = 0x01 , mode2 = 0x10 , mode3 = 0x11 }
 SPI clock polarity (CPOL) and phase (CPHA) More...
 
enum class  IoMode : uint8_t {
  SPI , SPIHD , SPI3WIRE , DUAL ,
  DIO , SDI , QUAD , QIO ,
  SQI , MAX
}
 Mode of data transfer. More...
 
enum class  PinSet { none , normal , manual , overlap }
 How SPI hardware pins are connected. More...
 

Functions

constexpr IoModes operator| (IoMode a, IoMode b)
 
const IoModeInfo getIoModeInfo (IoMode mode)
 
String toString (IoMode mode)
 
uint16_t bswap16 (uint16_t value)
 
uint32_t bswap24 (uint32_t value)
 
uint32_t bswap32 (uint32_t value)
 
RequestreQueueRequest (Request *head, Request *request)
 Support function for fast request re-queuing. More...
 

Variables

static constexpr uint8_t SPI_PIN_NONE {0xff}
 
static constexpr uint8_t SPI_PIN_DEFAULT {0xfe}
 

Typedef Documentation

◆ BitOrder

using HSPI::BitOrder = typedef uint8_t

◆ ByteOrder

using HSPI::ByteOrder = typedef uint8_t

◆ IoModes

using HSPI::IoModes = typedef BitSet<uint16_t, IoMode, unsigned(IoMode::MAX)>

Enumeration Type Documentation

◆ ClockMode

enum HSPI::ClockMode : uint8_t
strong

SPI clock polarity (CPOL) and phase (CPHA)

Enumerator
mode0 

CPOL: 0 CPHA: 0.

mode1 

CPOL: 0 CPHA: 1.

mode2 

CPOL: 1 CPHA: 0.

mode3 

CPOL: 1 CPHA: 1.

◆ IoMode

enum HSPI::IoMode : uint8_t
strong

Mode of data transfer.

Enumerator
SPI 

One bit per clock, MISO stage concurrent with MISO (full-duplex)

SPIHD 

One bit per clock, MISO stage follows MOSI (half-duplex)

SPI3WIRE 

Half-duplex using MOSI for both sending and receiving data.

DUAL 

Two bits per clock for Data, 1-bit for Command and Address.

DIO 

Two bits per clock for Address and Data, 1-bit for Command.

SDI 

Two bits per clock for Command, Address and Data.

QUAD 

Four bits per clock for Data, 1-bit for Command and Address.

QIO 

Four bits per clock for Address and Data, 1-bit for Command.

SQI 

Four bits per clock for Command, Address and Data.

MAX 

◆ PinSet

enum HSPI::PinSet
strong

How SPI hardware pins are connected.

Enumerator
none 

Disabled.

normal 

Standard HSPI pins.

manual 

HSPI pins with manual chip select.

overlap 

Overlapped with SPI 0.

Function Documentation

◆ bswap16()

uint16_t HSPI::bswap16 ( uint16_t  value)
inline

◆ bswap24()

uint32_t HSPI::bswap24 ( uint32_t  value)
inline

◆ bswap32()

uint32_t HSPI::bswap32 ( uint32_t  value)
inline

◆ getIoModeInfo()

const IoModeInfo HSPI::getIoModeInfo ( IoMode  mode)

◆ operator|()

constexpr IoModes HSPI::operator| ( IoMode  a,
IoMode  b 
)
inlineconstexpr

◆ reQueueRequest()

Request* HSPI::reQueueRequest ( Request head,
Request request 
)

Support function for fast request re-queuing.

Parameters
headThe current queue head
requestThe request to append
Return values
Request*The new queue head

Append a request back onto the queue.

Don't just put it at the front of the queue though as it will block any other requests. So it goes at the end. BUT! we must preserve execution order for all requests for a given device, so any other requests for the same device must go after it.

The easiest way to do this is to build two queues, one off the current request (A) and the other containing all other requests (B). We then append (A) to (B) and set the head to the start of (B).

This is kind of laborious but fast as it's just pointer manipulation.

◆ toString()

String HSPI::toString ( IoMode  mode)
inline

Variable Documentation

◆ SPI_PIN_DEFAULT

constexpr uint8_t HSPI::SPI_PIN_DEFAULT {0xfe}
staticconstexpr

◆ SPI_PIN_NONE

constexpr uint8_t HSPI::SPI_PIN_NONE {0xff}
staticconstexpr