Pico-Arduino
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PicoHardwareSPI Class Reference

Arduino HardwareSPI interface using the Pico API. We use the following default pins spi0: pinRx = 16; pinTx = 19; pinCS = 17; pinSCK = 18; spi1: pinRx = 12; pinTx = 11; pinCS = 13; pinSCK = 10; On the master miso = pinRx and mosi = pinTx. More...

#include <PicoHardwareSPI.h>

Inheritance diagram for PicoHardwareSPI:
arduino::HardwareSPI

Public Member Functions

 PicoHardwareSPI (spi_inst_t *spi)
 
virtual void begin ()
 Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high.
 
virtual void begin (bool slave, int pinRx=-1, int pinTx=-1, int pinCS=-1, int pinSCK=-1)
 Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high. More...
 
virtual void end ()
 Disables the SPI bus (leaving pin modes unchanged).
 
virtual void beginTransaction (SPISettings settings)
 Initializes the SPI bus using the defined SPISettings. More...
 
virtual void endTransaction (void)
 Stop using the SPI bus. Normally this is called after de-asserting the chip select, to allow other libraries to use the SPI bus.
 
virtual uint8_t transfer (uint8_t data)
 SPI transfer is based on a simultaneous send and receive of 1 byte. More...
 
virtual uint16_t transfer16 (uint16_t data)
 SPI transfer is based on a simultaneous send and receive of 2 bytes. More...
 
virtual void transfer (void *array, size_t len)
 SPI transfer is based on a simultaneous send and receive of len bytes. More...
 
virtual void usingInterrupt (int interruptNumber)
 If your program will perform SPI transactions within an interrupt, call this function to register the interrupt number or name with the SPI library. This allows SPI.beginTransaction() to prevent usage conflicts. Note that the interrupt specified in the call to usingInterrupt() will be disabled on a call to beginTransaction() and re-enabled in endTransaction(). More...
 
virtual void notUsingInterrupt (int interruptNumber)
 
virtual void attachInterrupt ()
 
virtual void detachInterrupt ()
 

Protected Member Functions

int getStandardInterrupt ()
 
void setFormat ()
 
void setupPins (int pinRx=-1, int pinTx=-1, int pinCS=-1, int pinSCK=-1)
 
const char * toStr (int value)
 

Protected Attributes

spi_inst_t * spi
 
bool is_transaction
 
spi_cpol_t cpol
 
spi_cpha_t cpha
 
spi_order_t order
 
uint data_bits
 
int using_interrupt_no
 
bool is_init
 
SPISettings last_settings
 

Detailed Description

Arduino HardwareSPI interface using the Pico API. We use the following default pins spi0: pinRx = 16; pinTx = 19; pinCS = 17; pinSCK = 18; spi1: pinRx = 12; pinTx = 11; pinCS = 13; pinSCK = 10; On the master miso = pinRx and mosi = pinTx.

Member Function Documentation

◆ begin()

virtual void PicoHardwareSPI::begin ( bool  slave,
int  pinRx = -1,
int  pinTx = -1,
int  pinCS = -1,
int  pinSCK = -1 
)
inlinevirtual

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

Parameters
slave
pinRx
pinTx
pinCS
pinSCK

◆ beginTransaction()

virtual void PicoHardwareSPI::beginTransaction ( SPISettings  settings)
inlinevirtual

Initializes the SPI bus using the defined SPISettings.

Parameters
settings

Implements arduino::HardwareSPI.

◆ transfer() [1/2]

virtual uint8_t PicoHardwareSPI::transfer ( uint8_t  data)
inlinevirtual

SPI transfer is based on a simultaneous send and receive of 1 byte.

Parameters
datasent
Returns
uint8_t data received

Implements arduino::HardwareSPI.

◆ transfer() [2/2]

virtual void PicoHardwareSPI::transfer ( void *  array,
size_t  len 
)
inlinevirtual

SPI transfer is based on a simultaneous send and receive of len bytes.

Parameters
arraydata sent and received
lenlength of data in bytes

Implements arduino::HardwareSPI.

◆ transfer16()

virtual uint16_t PicoHardwareSPI::transfer16 ( uint16_t  data)
inlinevirtual

SPI transfer is based on a simultaneous send and receive of 2 bytes.

Parameters
datasent
Returns
uint8_t data received

Implements arduino::HardwareSPI.

◆ usingInterrupt()

virtual void PicoHardwareSPI::usingInterrupt ( int  interruptNumber)
inlinevirtual

If your program will perform SPI transactions within an interrupt, call this function to register the interrupt number or name with the SPI library. This allows SPI.beginTransaction() to prevent usage conflicts. Note that the interrupt specified in the call to usingInterrupt() will be disabled on a call to beginTransaction() and re-enabled in endTransaction().

Parameters
interruptNumber

Implements arduino::HardwareSPI.


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