Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
SPI support classes

Provides SPI support. More...

Functions

virtual void SPIBase::begin ()=0
 begin(): Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high. More...
 
virtual void SPIBase::end ()=0
 end(): Disables the SPI bus (leaving pin modes unchanged). More...
 
virtual void SPIBase::beginTransaction (SPISettings mySettings)=0
 beginTransaction(): Initializes the SPI bus using the defined SPISettings. More...
 
virtual void SPIBase::endTransaction ()=0
 endTransaction(): Stop using the SPI bus. Normally this is called after de-asserting the chip select, to allow other libraries to use the SPI bus. More...
 
virtual unsigned char SPIBase::transfer (unsigned char val)=0
 transfer(), transfer16() More...
 
virtual unsigned short SPIBase::transfer16 (unsigned short val)=0
 
virtual void SPIBase::transfer (uint8 *buffer, size_t size)=0
 
 SPISettings::SPISettings (int speed, uint8 byteOrder, uint8 dataMode)
 constructor for SPISettings More...
 
uint8 SPISettings::getDataMode ()
 
bool SPISettings::operator== (const SPISettings &other) const
 
void SPISettings::print (const char *s)
 

Variables

SPISettings SPIBase::SPIDefaultSettings
 

Friends

class SPIClass
 

Detailed Description

Provides SPI support.

SPISettings() default Constructor.

SPIBase() default Constructor.

Function Documentation

virtual void SPIBase::begin ( )
pure virtual

begin(): Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high.

Implemented in SPIClass, and SPISoft.

virtual void SPIBase::beginTransaction ( SPISettings  mySettings)
pure virtual

beginTransaction(): Initializes the SPI bus using the defined SPISettings.

Implemented in SPIClass, and SPISoft.

virtual void SPIBase::end ( )
pure virtual

end(): Disables the SPI bus (leaving pin modes unchanged).

Implemented in SPIClass, and SPISoft.

virtual void SPIBase::endTransaction ( )
pure virtual

endTransaction(): Stop using the SPI bus. Normally this is called after de-asserting the chip select, to allow other libraries to use the SPI bus.

Implemented in SPIClass, and SPISoft.

SPISettings::SPISettings ( int  speed,
uint8  byteOrder,
uint8  dataMode 
)

constructor for SPISettings

Settings are applied to SPI::beginTransaction(SPISettings) and are valid until next beginTransaction()

Parameters
speedThe maximum speed of communication. For a SPI chip rated up to sys clock speed. For 20 MHz, use 20000000.
byteOrderMSBFIRST or LSBFIRST
dataMode: SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3

byteOrder's are:

    MSBFIRST    Data is sent out starting with Bit31 and down to Bit0
    LSBFIRST    Data is sent out starting with the lowest BYTE, from MSB to LSB.
                0xABCDEFGH would be sent as 0xGHEFCDAB

Data modes are:

    Mode        Clock Polarity (CPOL)   Clock Phase (CPHA)
    SPI_MODE0       0                   0
    SPI_MODE1       0                   1
    SPI_MODE2       1                   0
    SPI_MODE3       1                   1
virtual unsigned char SPIBase::transfer ( unsigned char  val)
pure virtual

transfer(), transfer16()

SPI transfer is based on a simultaneous send and receive: the received data is returned in receivedVal (or receivedVal16). In case of buffer transfers the received data is stored in the buffer in-place (the old data is replaced with the data received).

    receivedVal = SPI.transfer(val)
    receivedVal16 = SPI.transfer16(val16)
    SPI.transfer(buffer, size)

Implemented in SPIClass, and SPISoft.