Loading...
Searching...
No Matches
PhyduinoSPI Class Reference

SPI controller on one RP2040 SPI peripheral; sketches use SPI. More...

#include <SPI.h>

Inheritance diagram for PhyduinoSPI:

Public Member Functions

 PhyduinoSPI (spi_inst_t *spi, pin_size_t sck, pin_size_t mosi, pin_size_t miso)
 Binds the controller to an SPI peripheral and its pins; nothing is set up until begin().
void begin () override
 Starts the controller and connects SCK, MOSI and MISO.
void end () override
 Stops the controller and frees its pins.
void beginTransaction (arduino::SPISettings settings) override
 Applies the clock, bit order and mode for the next transfers.
void endTransaction () override
 Ends a transaction. Does nothing; kept for Arduino compatibility.
uint8_t transfer (uint8_t data) override
 Sends one byte and returns the byte received at the same time.
uint16_t transfer16 (uint16_t data) override
 Sends 16 bits as two bytes, in the bit order of the transaction.
void transfer (void *buffer, size_t count) override
 Sends a buffer and replaces its contents with the bytes received.
Interrupt-safe transactions

Not needed in v0.1: these do nothing.

void usingInterrupt (int) override
 Does nothing.
void notUsingInterrupt (int) override
 Does nothing.
void attachInterrupt () override
 Does nothing.
void detachInterrupt () override
 Does nothing.

Detailed Description

SPI controller on one RP2040 SPI peripheral; sketches use SPI.

Transfers 8 bits at a time. LSBFIRST is supported (done in software).

Constructor & Destructor Documentation

◆ PhyduinoSPI()

PhyduinoSPI::PhyduinoSPI ( spi_inst_t * spi,
pin_size_t sck,
pin_size_t mosi,
pin_size_t miso )
inline

Binds the controller to an SPI peripheral and its pins; nothing is set up until begin().

Parameters
spipico-sdk SPI (spi0 or spi1).
sckArduino pin for SCK.
mosiArduino pin for MOSI.
misoArduino pin for MISO.

Member Function Documentation

◆ begin()

void PhyduinoSPI::begin ( )
override

Starts the controller and connects SCK, MOSI and MISO.

Uses the settings of the last beginTransaction(), or 4 MHz, MSBFIRST, SPI_MODE0 if there was none.

◆ beginTransaction()

void PhyduinoSPI::beginTransaction ( arduino::SPISettings settings)
override

Applies the clock, bit order and mode for the next transfers.

Parameters
settingsE.g. SPISettings(1000000, MSBFIRST, SPI_MODE0).

◆ transfer() [1/2]

uint8_t PhyduinoSPI::transfer ( uint8_t data)
override

Sends one byte and returns the byte received at the same time.

Parameters
dataByte to send.
Returns
Byte received.

◆ transfer() [2/2]

void PhyduinoSPI::transfer ( void * buffer,
size_t count )
override

Sends a buffer and replaces its contents with the bytes received.

Parameters
bufferBytes to send; overwritten with the received bytes.
countNumber of bytes.

◆ transfer16()

uint16_t PhyduinoSPI::transfer16 ( uint16_t data)
override

Sends 16 bits as two bytes, in the bit order of the transaction.

Parameters
dataValue to send.
Returns
Value received.

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