Skip to content

Class daisy::SpiHandle

ClassList > daisy > SpiHandle

More...

  • #include <spi.h>

Classes

Type Name
struct Config

Public Types

Type Name
enum DmaDirection
typedef void(* EndCallbackFunctionPtr
enum Result
typedef void(* StartCallbackFunctionPtr

Public Functions

Type Name
Result BlockingReceive (uint8_t * buffer, uint16_t size, uint32_t timeout)
Result BlockingTransmit (uint8_t * buff, size_t size, uint32_t timeout=100)
Result BlockingTransmitAndReceive (uint8_t * tx_buff, uint8_t * rx_buff, size_t size, uint32_t timeout=100)
int CheckError ()
Result DmaReceive (uint8_t * buff, size_t size, SpiHandle::StartCallbackFunctionPtr start_callback, SpiHandle::EndCallbackFunctionPtr end_callback, void * callback_context)
Result DmaTransmit (uint8_t * buff, size_t size, SpiHandle::StartCallbackFunctionPtr start_callback, SpiHandle::EndCallbackFunctionPtr end_callback, void * callback_context)
Result DmaTransmitAndReceive (uint8_t * tx_buff, uint8_t * rx_buff, size_t size, SpiHandle::StartCallbackFunctionPtr start_callback, SpiHandle::EndCallbackFunctionPtr end_callback, void * callback_context)
const Config & GetConfig () const
Result Init (const Config & config)
SpiHandle ()
SpiHandle (const SpiHandle & other) = default
SpiHandle & operator= (const SpiHandle & other) = default

Detailed Description

Handler for serial peripheral interface

Public Types Documentation

enum DmaDirection

enum daisy::SpiHandle::DmaDirection {
    RX,
    TX,
    RX_TX
};

typedef EndCallbackFunctionPtr

typedef void(* daisy::SpiHandle::EndCallbackFunctionPtr) (void *context, Result result);

A callback to be executed after a dma transfer is completed.


enum Result

enum daisy::SpiHandle::Result {
    OK,
    ERR
};

Return values for Spi functions.


typedef StartCallbackFunctionPtr

typedef void(* daisy::SpiHandle::StartCallbackFunctionPtr) (void *context);

A callback to be executed right before a dma transfer is started.


Public Functions Documentation

function BlockingReceive

Result daisy::SpiHandle::BlockingReceive (
    uint8_t * buffer,
    uint16_t size,
    uint32_t timeout
) 

Polling Receive

Parameters:

  • buffer input buffer
  • size buffer size
  • timeout How long to timeout for in milliseconds

Returns:

Whether the receive was successful or not


function BlockingTransmit

Result daisy::SpiHandle::BlockingTransmit (
    uint8_t * buff,
    size_t size,
    uint32_t timeout=100
) 

Blocking transmit

Parameters:

  • buff input buffer
  • size buffer size
  • timeout how long in milliseconds the function will wait before returning without successful communication

function BlockingTransmitAndReceive

Result daisy::SpiHandle::BlockingTransmitAndReceive (
    uint8_t * tx_buff,
    uint8_t * rx_buff,
    size_t size,
    uint32_t timeout=100
) 

Blocking transmit and receive

Parameters:

  • tx_buff the transmit buffer
  • rx_buff the receive buffer
  • size the length of the transaction
  • timeout how long in milliseconds the function will wait before returning without successful communication

function CheckError

int daisy::SpiHandle::CheckError () 

Returns:

the result of HAL_SPI_GetError() to the user.


function DmaReceive

Result daisy::SpiHandle::DmaReceive (
    uint8_t * buff,
    size_t size,
    SpiHandle::StartCallbackFunctionPtr start_callback,
    SpiHandle::EndCallbackFunctionPtr end_callback,
    void * callback_context
) 

DMA-based receive

Parameters:

  • *buff input buffer
  • size buffer size
  • start_callback A callback to execute when the transfer starts, or NULL. The callback is called from an interrupt, so keep it fast.
  • end_callback A callback to execute when the transfer finishes, or NULL. The callback is called from an interrupt, so keep it fast.
  • callback_context A pointer that will be passed back to you in the callbacks.

Returns:

Whether the receive was successful or not


function DmaTransmit

Result daisy::SpiHandle::DmaTransmit (
    uint8_t * buff,
    size_t size,
    SpiHandle::StartCallbackFunctionPtr start_callback,
    SpiHandle::EndCallbackFunctionPtr end_callback,
    void * callback_context
) 

DMA-based transmit

Parameters:

  • *buff input buffer
  • size buffer size
  • start_callback A callback to execute when the transfer starts, or NULL. The callback is called from an interrupt, so keep it fast.
  • end_callback A callback to execute when the transfer finishes, or NULL. The callback is called from an interrupt, so keep it fast.
  • callback_context A pointer that will be passed back to you in the callbacks.

Returns:

Whether the transmit was successful or not


function DmaTransmitAndReceive

Result daisy::SpiHandle::DmaTransmitAndReceive (
    uint8_t * tx_buff,
    uint8_t * rx_buff,
    size_t size,
    SpiHandle::StartCallbackFunctionPtr start_callback,
    SpiHandle::EndCallbackFunctionPtr end_callback,
    void * callback_context
) 

DMA-based transmit and receive

Parameters:

  • tx_buff the transmit buffer
  • rx_buff the receive buffer
  • size buffer size
  • start_callback A callback to execute when the transfer starts, or NULL. The callback is called from an interrupt, so keep it fast.
  • end_callback A callback to execute when the transfer finishes, or NULL. The callback is called from an interrupt, so keep it fast.
  • callback_context A pointer that will be passed back to you in the callbacks.

Returns:

Whether the receive was successful or not


function GetConfig

const  Config & daisy::SpiHandle::GetConfig () const

Returns the current config.


function Init

Result daisy::SpiHandle::Init (
    const  Config & config
) 

Initializes handler


function SpiHandle [½]

inline daisy::SpiHandle::SpiHandle () 

function SpiHandle [2/2]

daisy::SpiHandle::SpiHandle (
    const  SpiHandle & other
) = default

function operator=

SpiHandle & daisy::SpiHandle::operator= (
    const  SpiHandle & other
) = default


The documentation for this class was generated from the following file external-docs/libDaisy/src/per/spi.h