128x64 EasyC OLED Display 1.0.0
This is a library for Soldered OLED Display
Loading...
Searching...
No Matches
Adafruit_SPIDevice Class Reference

#include <Adafruit_SPIDevice.h>

Public Member Functions

 Adafruit_SPIDevice (int8_t cspin, uint32_t freq=1000000, BusIOBitOrder dataOrder=SPI_BITORDER_MSBFIRST, uint8_t dataMode=SPI_MODE0, SPIClass *theSPI=&SPI)
 Create an SPI device with the given CS pin and settins.
 
 Adafruit_SPIDevice (int8_t cspin, int8_t sck, int8_t miso, int8_t mosi, uint32_t freq=1000000, BusIOBitOrder dataOrder=SPI_BITORDER_MSBFIRST, uint8_t dataMode=SPI_MODE0)
 Create an SPI device with the given CS pin and settins.
 
 ~Adafruit_SPIDevice ()
 Release memory allocated in constructors.
 
bool begin (void)
 Initializes SPI bus and sets CS pin high.
 
bool read (uint8_t *buffer, size_t len, uint8_t sendvalue=0xFF)
 
bool write (uint8_t *buffer, size_t len, uint8_t *prefix_buffer=NULL, size_t prefix_len=0)
 
bool write_then_read (uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len, uint8_t sendvalue=0xFF)
 
uint8_t transfer (uint8_t send)
 
void transfer (uint8_t *buffer, size_t len)
 Transfer (send/receive) one byte over hard/soft SPI.
 
void beginTransaction (void)
 
void endTransaction (void)
 

Private Attributes

SPIClass_spi
 
SPISettings * _spiSetting
 
uint32_t _freq
 
BusIOBitOrder _dataOrder
 
uint8_t _dataMode
 
int8_t _cs
 
int8_t _sck
 
int8_t _mosi
 
int8_t _miso
 
BusIO_PortRegmosiPort
 
BusIO_PortRegclkPort
 
BusIO_PortRegmisoPort
 
BusIO_PortRegcsPort
 
BusIO_PortMask mosiPinMask
 
BusIO_PortMask misoPinMask
 
BusIO_PortMask clkPinMask
 
BusIO_PortMask csPinMask
 
bool _begun
 

Detailed Description

! The class which defines how we will talk to this device over SPI

Constructor & Destructor Documentation

◆ Adafruit_SPIDevice() [1/2]

Adafruit_SPIDevice::Adafruit_SPIDevice ( int8_t cspin,
uint32_t freq = 1000000,
BusIOBitOrder dataOrder = SPI_BITORDER_MSBFIRST,
uint8_t dataMode = SPI_MODE0,
SPIClass * theSPI = &SPI )

Create an SPI device with the given CS pin and settins.

Parameters
cspinThe arduino pin number to use for chip select
freqThe SPI clock frequency to use, defaults to 1MHz
dataOrderThe SPI data order to use for bits within each byte, defaults to SPI_BITORDER_MSBFIRST
dataModeThe SPI mode to use, defaults to SPI_MODE0
theSPIThe SPI bus to use, defaults to &theSPI

◆ Adafruit_SPIDevice() [2/2]

Adafruit_SPIDevice::Adafruit_SPIDevice ( int8_t cspin,
int8_t sckpin,
int8_t misopin,
int8_t mosipin,
uint32_t freq = 1000000,
BusIOBitOrder dataOrder = SPI_BITORDER_MSBFIRST,
uint8_t dataMode = SPI_MODE0 )

Create an SPI device with the given CS pin and settins.

Parameters
cspinThe arduino pin number to use for chip select
sckpinThe arduino pin number to use for SCK
misopinThe arduino pin number to use for MISO, set to -1 if not used
mosipinThe arduino pin number to use for MOSI, set to -1 if not used
freqThe SPI clock frequency to use, defaults to 1MHz
dataOrderThe SPI data order to use for bits within each byte, defaults to SPI_BITORDER_MSBFIRST
dataModeThe SPI mode to use, defaults to SPI_MODE0

◆ ~Adafruit_SPIDevice()

Adafruit_SPIDevice::~Adafruit_SPIDevice ( )

Release memory allocated in constructors.

Member Function Documentation

◆ begin()

bool Adafruit_SPIDevice::begin ( void )

Initializes SPI bus and sets CS pin high.

Returns
Always returns true because there's no way to test success of SPI init

◆ beginTransaction()

void Adafruit_SPIDevice::beginTransaction ( void )

◆ endTransaction()

void Adafruit_SPIDevice::endTransaction ( void )

◆ read()

bool Adafruit_SPIDevice::read ( uint8_t * buffer,
size_t len,
uint8_t sendvalue = 0xFF )

◆ transfer() [1/2]

void Adafruit_SPIDevice::transfer ( uint8_t * buffer,
size_t len )

Transfer (send/receive) one byte over hard/soft SPI.

Parameters
bufferThe buffer to send and receive at the same time
lenThe number of bytes to transfer

Transfer (send/receive) one byte over hard/soft SPI

Parameters
sendThe byte to send
Returns
The byte received while transmitting

Manually begin a transaction (calls beginTransaction if hardware SPI)

Manually end a transaction (calls endTransaction if hardware SPI)

Write a buffer or two to the SPI device.

Parameters
bufferPointer to buffer of data to write
lenNumber of bytes from buffer to write
prefix_bufferPointer to optional array of data to write before buffer.
prefix_lenNumber of bytes from prefix buffer to write
Returns
Always returns true because there's no way to test success of SPI writes

Read from SPI into a buffer from the SPI device.

Parameters
bufferPointer to buffer of data to read into
lenNumber of bytes from buffer to read.
sendvalueThe 8-bits of data to write when doing the data read, defaults to 0xFF
Returns
Always returns true because there's no way to test success of SPI writes

Write some data, then read some data from SPI into another buffer. The buffers can point to same/overlapping locations. This does not transmit-receive at the same time!

Parameters
write_bufferPointer to buffer of data to write from
write_lenNumber of bytes from buffer to write.
read_bufferPointer to buffer of data to read into.
read_lenNumber of bytes from buffer to read.
sendvalueThe 8-bits of data to write when doing the data read, defaults to 0xFF
Returns
Always returns true because there's no way to test success of SPI writes

◆ transfer() [2/2]

uint8_t Adafruit_SPIDevice::transfer ( uint8_t send)

◆ write()

bool Adafruit_SPIDevice::write ( uint8_t * buffer,
size_t len,
uint8_t * prefix_buffer = NULL,
size_t prefix_len = 0 )

◆ write_then_read()

bool Adafruit_SPIDevice::write_then_read ( uint8_t * write_buffer,
size_t write_len,
uint8_t * read_buffer,
size_t read_len,
uint8_t sendvalue = 0xFF )

Member Data Documentation

◆ _begun

bool Adafruit_SPIDevice::_begun
private

◆ _cs

int8_t Adafruit_SPIDevice::_cs
private

◆ _dataMode

uint8_t Adafruit_SPIDevice::_dataMode
private

◆ _dataOrder

BusIOBitOrder Adafruit_SPIDevice::_dataOrder
private

◆ _freq

uint32_t Adafruit_SPIDevice::_freq
private

◆ _miso

int8_t Adafruit_SPIDevice::_miso
private

◆ _mosi

int8_t Adafruit_SPIDevice::_mosi
private

◆ _sck

int8_t Adafruit_SPIDevice::_sck
private

◆ _spi

SPIClass* Adafruit_SPIDevice::_spi
private

◆ _spiSetting

SPISettings* Adafruit_SPIDevice::_spiSetting
private

◆ clkPinMask

BusIO_PortMask Adafruit_SPIDevice::clkPinMask
private

◆ clkPort

BusIO_PortReg * Adafruit_SPIDevice::clkPort
private

◆ csPinMask

BusIO_PortMask Adafruit_SPIDevice::csPinMask
private

◆ csPort

BusIO_PortReg * Adafruit_SPIDevice::csPort
private

◆ misoPinMask

BusIO_PortMask Adafruit_SPIDevice::misoPinMask
private

◆ misoPort

BusIO_PortReg * Adafruit_SPIDevice::misoPort
private

◆ mosiPinMask

BusIO_PortMask Adafruit_SPIDevice::mosiPinMask
private

◆ mosiPort

BusIO_PortReg* Adafruit_SPIDevice::mosiPort
private

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