Arduino-SPI
Serial Peripheral Interface (SPI) library for Arduino
SPI::Device< MODE, BITORDER, FREQ, SS_PIN > Class Template Reference

#include <SPI.h>

Collaboration diagram for SPI::Device< MODE, BITORDER, FREQ, SS_PIN >:
Collaboration graph

Public Member Functions

 Device (SPI &spi, bool ss=HIGH)
 
void acquire ()
 
void release ()
 
uint8_t transfer (uint8_t value)
 
void transfer (void *dest, const void *src, size_t count)
 
void read (void *buf, size_t count)
 
void write (const void *buf, size_t count)
 

Protected Attributes

SPIm_spi
 
GPIO< SS_PIN > m_ss
 
const uint8_t PRESCALE
 

Detailed Description

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
class SPI::Device< MODE, BITORDER, FREQ, SS_PIN >

Serial Perpheral Interface (SPI) device driver class.

Parameters
[in]MODEclock mode (polarity and phase).
[in]BITORDERLSB or MSB first.
[in]FREQmax clock frequency.
[in]SS_PINboard pin for device slave select.

Definition at line 152 of file SPI.h.

Constructor & Destructor Documentation

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::Device ( SPI spi,
bool  ss = HIGH 
)
inline

Construct Serial Perpheral Interface (SPI) device driver instance and initiate slave select pin.

Parameters
[in]spibus manager.
[in]ssinitial slave select pin state (default HIGH).

Definition at line 160 of file SPI.h.

Member Function Documentation

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
void SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::acquire ( )
inline

Acquire bus manager and slave device.

Definition at line 171 of file SPI.h.

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
void SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::read ( void *  buf,
size_t  count 
)
inline

Read given number of bytes from device and store in buffer.

Parameters
[in]bufbuffer pointer.
[in]countnumber of bytes.

Definition at line 217 of file SPI.h.

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
void SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::release ( )
inline

Release bus manager and slave device.

Definition at line 181 of file SPI.h.

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
uint8_t SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::transfer ( uint8_t  value)
inline

Send given byte to device. Returns byte received from device.

Parameters
[in]valueto send to device.
Returns
received value.

Definition at line 193 of file SPI.h.

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
void SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::transfer ( void *  dest,
const void *  src,
size_t  count 
)
inline

Transfer given number of bytes from source buffer to device. Store received bytes in destination buffer.

Parameters
[in]destdestination buffer.
[in]srcsource buffer.
[in]countnumber of bytes to transfer.

Definition at line 206 of file SPI.h.

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
void SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::write ( const void *  buf,
size_t  count 
)
inline

Write given number of bytes from buffer to device.

Parameters
[in]bufbuffer pointer.
[in]countnumber of bytes.

Definition at line 228 of file SPI.h.

Member Data Documentation

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
SPI& SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::m_spi
protected

Bus manager.

Definition at line 236 of file SPI.h.

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
GPIO<SS_PIN> SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::m_ss
protected

Slave select pin.

Definition at line 239 of file SPI.h.

template<uint8_t MODE, uint8_t BITORDER, uint32_t FREQ, BOARD::pin_t SS_PIN>
const uint8_t SPI::Device< MODE, BITORDER, FREQ, SS_PIN >::PRESCALE
protected

Bus clock prescale.

Definition at line 242 of file SPI.h.


The documentation for this class was generated from the following file: