Arduino-SPI
Serial Peripheral Interface (SPI) library for Arduino
Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN > Class Template Reference

#include <SPI.h>

Inheritance diagram for Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >:
Inheritance graph
Collaboration diagram for Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >:
Collaboration graph

Public Member Functions

 SPI ()
 
virtual void acquire (uint8_t mode, uint8_t bitorder, uint8_t scale)
 
virtual void release ()
 
virtual uint8_t transfer (uint8_t value)
 
virtual uint8_t prescale (uint32_t frequency)
 
virtual void transfer (void *dest, const void *src, size_t count)
 
SPIoperator>> (uint8_t &value)
 
SPIoperator<< (uint8_t value)
 
virtual void read (void *buf, size_t count)
 
virtual void write (const void *buf, size_t count)
 

Static Public Attributes

static const uint32_t MAX_FREQ = F_CPU / 2
 

Protected Member Functions

void lock ()
 
void unlock ()
 

Protected Attributes

GPIO< SCK_PINm_sck
 
GPIO< MOSI_PINm_mosi
 
GPIO< MISO_PINm_miso
 
bool m_cpha
 
uint8_t m_bitorder
 
volatile bool m_busy
 

Detailed Description

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
class Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >

Definition at line 39 of file SPI.h.

Constructor & Destructor Documentation

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >::SPI ( )
inline

Serial Perpheral Interface (SPI) constructor. Initiate pin input/output mode.

Definition at line 45 of file SPI.h.

Member Function Documentation

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
virtual void Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >::acquire ( uint8_t  mode,
uint8_t  bitorder,
uint8_t  scale 
)
inlinevirtual

Acquire bus access. Yield until bus is released.

Parameters
[in]modeof access.
[in]bitorderof serial data.
[in]scaleclock frequency.

Reimplemented from SPI.

Definition at line 60 of file SPI.h.

void SPI::lock ( )
inlineprotectedinherited

Lock bus manager.

Definition at line 252 of file SPI.h.

SPI& SPI::operator<< ( uint8_t  value)
inlineinherited

Write value to device. Shorthand for write().

Parameters
[in]valueto write to device.

Definition at line 95 of file SPI.h.

SPI& SPI::operator>> ( uint8_t &  value)
inlineinherited

Read value from device.

Parameters
[out]valueread from device.

Definition at line 84 of file SPI.h.

virtual uint8_t SPI::prescale ( uint32_t  frequency)
inlinevirtualinherited

Calculate clock prescale from device frequency.

Parameters
[in]frequencydevice access.
Returns
prescale

Reimplemented in Hardware::SPI.

Definition at line 43 of file SPI.h.

virtual void SPI::read ( void *  buf,
size_t  count 
)
inlinevirtualinherited

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

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

Reimplemented in Hardware::SPI, and Hardware::SPI.

Definition at line 124 of file SPI.h.

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
virtual void Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >::release ( )
inlinevirtual

Release bus access.

Reimplemented from SPI.

Definition at line 73 of file SPI.h.

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
virtual uint8_t Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >::transfer ( uint8_t  value)
inlinevirtual

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

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

Implements SPI.

Definition at line 85 of file SPI.h.

virtual void SPI::transfer ( void *  dest,
const void *  src,
size_t  count 
)
inlinevirtualinherited

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.

Reimplemented in Hardware::SPI, and Hardware::SPI.

Definition at line 110 of file SPI.h.

void SPI::unlock ( )
inlineprotectedinherited

Unlock bus manager.

Definition at line 262 of file SPI.h.

virtual void SPI::write ( const void *  buf,
size_t  count 
)
inlinevirtualinherited

Write given number of bytes from buffer to device.

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

Reimplemented in Hardware::SPI, and Hardware::SPI.

Definition at line 137 of file SPI.h.

Member Data Documentation

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
uint8_t Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >::m_bitorder
protected

Serial data bitorder flag.

Definition at line 128 of file SPI.h.

volatile bool SPI::m_busy
protectedinherited

Bus manager semaphore.

Definition at line 247 of file SPI.h.

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
bool Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >::m_cpha
protected

Clock phase flag.

Definition at line 125 of file SPI.h.

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
GPIO<MISO_PIN> Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >::m_miso
protected

Master Input Slave Output pin.

Definition at line 122 of file SPI.h.

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
GPIO<MOSI_PIN> Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >::m_mosi
protected

Master Output Slave Input pin.

Definition at line 119 of file SPI.h.

template<BOARD::pin_t MOSI_PIN, BOARD::pin_t MISO_PIN, BOARD::pin_t SCK_PIN>
GPIO<SCK_PIN> Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >::m_sck
protected

Clock pin.

Definition at line 116 of file SPI.h.

const uint32_t SPI::MAX_FREQ = F_CPU / 2
staticinherited

Maximum clock frequency.

Definition at line 30 of file SPI.h.


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