Arduino-SPI
Serial Peripheral Interface (SPI) library for Arduino
SPI Class Referenceabstract

#include <SPI.h>

Inheritance diagram for SPI:
Inheritance graph
Collaboration diagram for SPI:
Collaboration graph

Classes

class  Device
 

Public Member Functions

 SPI ()
 
virtual uint8_t prescale (uint32_t frequency)
 
virtual void acquire (uint8_t mode, uint8_t bitorder, uint8_t prescale)
 
virtual void release ()
 
virtual uint8_t transfer (uint8_t value)=0
 
SPIoperator>> (uint8_t &value)
 
SPIoperator<< (uint8_t value)
 
virtual void transfer (void *dest, const void *src, size_t count)
 
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

volatile bool m_busy
 

Detailed Description

Serial Perpheral Interface (SPI) abstract class.

Definition at line 27 of file SPI.h.

Constructor & Destructor Documentation

SPI::SPI ( )
inline

Construct and initiate bus manager.

Definition at line 35 of file SPI.h.

Member Function Documentation

virtual void SPI::acquire ( uint8_t  mode,
uint8_t  bitorder,
uint8_t  prescale 
)
inlinevirtual

Acquire bus access with given mode.

Parameters
[in]modeof access.
[in]bitorderof serial data.
[in]prescalefor device.

Reimplemented in Hardware::SPI, Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >, and Hardware::SPI.

Definition at line 55 of file SPI.h.

void SPI::lock ( )
inlineprotected

Lock bus manager.

Definition at line 252 of file SPI.h.

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

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)
inline

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)
inlinevirtual

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 
)
inlinevirtual

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.

virtual void SPI::release ( )
inlinevirtual

Release bus access.

Reimplemented in Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >.

Definition at line 67 of file SPI.h.

virtual uint8_t SPI::transfer ( uint8_t  value)
pure virtual

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

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

Implemented in Hardware::SPI, Software::SPI< MOSI_PIN, MISO_PIN, SCK_PIN >, and Hardware::SPI.

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

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 ( )
inlineprotected

Unlock bus manager.

Definition at line 262 of file SPI.h.

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

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

volatile bool SPI::m_busy
protected

Bus manager semaphore.

Definition at line 247 of file SPI.h.

const uint32_t SPI::MAX_FREQ = F_CPU / 2
static

Maximum clock frequency.

Definition at line 30 of file SPI.h.


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