Pico-Arduino
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
pico_arduino::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 pico_arduino::PicoHardwareSPI:
arduino::HardwareSPI

Public Member Functions

 PicoHardwareSPI (spi_inst_t *spi)
 
virtual void attachInterrupt ()
 Enable the SPI interrupt: SPI0_IRQ = 18, SPI1_IRQ = 19.
 
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 beginTransaction (SPISettings settings)
 Initializes the SPI bus using the defined SPISettings. More...
 
virtual void detachInterrupt ()
 Turns off the given interrupt: SPI0_IRQ = 18, SPI1_IRQ = 19.
 
virtual void end ()
 Disables the SPI bus (leaving pin modes unchanged).
 
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 void notUsingInterrupt (int interruptNumber)
 If your program will perform SPI transactions within an interrupt, call this function to de-register the interrupt number.
 
virtual uint8_t transfer (uint8_t data)
 SPI transfer is based on a simultaneous send and receive of 1 byte. More...
 
virtual void transfer (void *array, size_t len)
 SPI transfer is based on a simultaneous send and receive of len bytes. More...
 
virtual uint16_t transfer16 (uint16_t data)
 SPI transfer is based on a simultaneous send and receive of 2 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...
 

Protected Member Functions

int getStandardInterrupt ()
 
void setDataWidth (int bits)
 
void setFormat ()
 
void setupPins (int pinRx=-1, int pinTx=-1, int pinCS=-1, int pinSCK=-1)
 

Protected Attributes

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

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.

Author
Phil Schatzmann

Member Function Documentation

◆ begin()

virtual void pico_arduino::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 pico_arduino::PicoHardwareSPI::beginTransaction ( SPISettings  settings)
inlinevirtual

Initializes the SPI bus using the defined SPISettings.

Parameters
settings

Implements arduino::HardwareSPI.

◆ transfer() [1/2]

virtual uint8_t pico_arduino::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 pico_arduino::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 pico_arduino::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 pico_arduino::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: