RF22
Public Member Functions | List of all members
GenericSPIClass Class Referenceabstract

Base class for SPI interfaces. More...

#include <GenericSPI.h>

Inheritance diagram for GenericSPIClass:
HardwareSPIClass SoftwareSPIClass

Public Member Functions

virtual uint8_t transfer (uint8_t data)=0
 
virtual void attachInterrupt ()
 
virtual void detachInterrupt ()
 
virtual void begin ()
 
virtual void end ()
 
virtual void setBitOrder (uint8_t bitOrder)
 
virtual void setDataMode (uint8_t mode)
 
virtual void setClockDivider (uint8_t rate)
 

Detailed Description

Base class for SPI interfaces.

This generic abstract class is used to encapsulate hardware or software SPI interfaces. The intention is so that the main RF22 class can be configured to use hardware or software SPI without changing the main code.

You must provide a subclass of this class to RF22 constructor. A concrete subclass theat encapsualtes the standard Arcuino hardware SPI is provided

Member Function Documentation

virtual void GenericSPIClass::attachInterrupt ( )
inlinevirtual

Enable SPI interrupts (if supported) This can be used in an SPI slave to indicate when an SPI message has been received

Reimplemented in SoftwareSPIClass, and HardwareSPIClass.

virtual void GenericSPIClass::begin ( )
inlinevirtual

Initialise the SPI library. Call this before configuring or using the SPI library

Reimplemented in SoftwareSPIClass, and HardwareSPIClass.

Referenced by RF22::init().

virtual void GenericSPIClass::detachInterrupt ( )
inlinevirtual

Disable SPI interrupts (if supported) This can be used to diable the SPI interrupt in slaves where that is supported.

Reimplemented in SoftwareSPIClass, and HardwareSPIClass.

virtual void GenericSPIClass::end ( )
inlinevirtual

Disables the SPI bus (leaving pin modes unchanged). Call this after you have finished using the SPI interface

Reimplemented in SoftwareSPIClass, and HardwareSPIClass.

virtual void GenericSPIClass::setBitOrder ( uint8_t  bitOrder)
inlinevirtual

Sets the bit order the SPI interface will use Sets the order of the bits shifted out of and into the SPI bus, either LSBFIRST (least-significant bit first) or MSBFIRST (most-significant bit first).

Parameters
[in]bitOrderBit order to be used: LSBFIRST or MSBFIRST

Reimplemented in SoftwareSPIClass, and HardwareSPIClass.

Referenced by RF22::init().

virtual void GenericSPIClass::setClockDivider ( uint8_t  rate)
inlinevirtual

Sets the SPI clock divider relative to the system clock. On AVR based boards, the dividers available are 2, 4, 8, 16, 32, 64 or 128. The default setting is SPI_CLOCK_DIV4, which sets the SPI clock to one-quarter the frequency of the system clock (4 Mhz for the boards at 16 MHz).

Parameters
[in]rateThe data rate to use: one of SPI_CLOCK_

Reimplemented in SoftwareSPIClass, and HardwareSPIClass.

Referenced by RF22::init().

virtual void GenericSPIClass::setDataMode ( uint8_t  mode)
inlinevirtual

Sets the SPI data mode: that is, clock polarity and phase. See the Wikipedia article on SPI for details.

Parameters
[in]modeThe mode to use: SPI_MODE0 SPI_MODE1 SPI_MODE2 SPI_MODE3

Reimplemented in SoftwareSPIClass, and HardwareSPIClass.

Referenced by RF22::init().

virtual uint8_t GenericSPIClass::transfer ( uint8_t  data)
pure virtual

Transfer a single octet to and from the SPI interface

Parameters
[in]dataThe octet to send
Returns
The octet read from SPI while the data octet was sent

Implemented in SoftwareSPIClass, and HardwareSPIClass.

Referenced by RF22::spiBurstRead(), RF22::spiBurstWrite(), RF22::spiRead(), and RF22::spiWrite().


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