C++ DevKit
C++ set of OOP library
Loading...
Searching...
No Matches
rtos_HW_SPI_Master Class Reference

This is a C++ wrapper for the original pico SDK spi master API, adapted to FreeRTOS environment. More...

#include <rtos_hw_spi.h>

Inheritance diagram for rtos_HW_SPI_Master:
Inheritance graph
Collaboration diagram for rtos_HW_SPI_Master:
Collaboration graph

Public Member Functions

 rtos_HW_SPI_Master (struct_ConfigMasterSPI master_config, irq_num_t dma_tx_irq_number=DMA_IRQ_0, irq_handler_t dma_tx_irq_handler=nullptr, irq_num_t dma_rx_irq_number=DMA_IRQ_1, irq_handler_t dma_rx_irq_handler=nullptr)
 Construct a new hw spi master object.
 
int burst_write_8 (uint8_t *src, size_t len) override
 send a serie of 8 bit data on the SPI MOSI port DMA not implemented
 
int burst_write_16 (uint16_t *src, size_t len) override
 send a serie of 16 bit data on the SPI MOSI port. Use DMA.
 
int repeat_write_16 (uint16_t *src, size_t len)
 repeat a single 16 bit data on the SPI MOSI port. Use DMA.
 
int burst_read_16 (uint16_t *dst, size_t len)
 read a serie of 16 bit data on the SPI MISO port. Use DMA.
 
int burst_write_read_8 (uint8_t *src, uint8_t *dest, size_t len) override
 read / write a serie of 8 bit data on the SPI MISO/MOSI ports DMA not implemented
 
int burst_read_8 (uint8_t repeated_tx_data, uint8_t *dest, size_t len)
 read a serie of byte on the SPI MISO port DMA not implemented
 
void spi_tx_dma_isr ()
 ISR handler for SPI TX DMA.
 
void spi_rx_dma_isr ()
 ISR handler for SPI RX DMA.
 
- Public Member Functions inherited from HW_SPI_Master
 HW_SPI_Master (struct_ConfigMasterSPI master_config)
 Construct a new hw spi master object.
 
int single_write_8 (uint8_t byte_value)
 write a single byte on the SPI MOSI port
 
int single_write_16 (uint16_t word_value)
 write a single 16bit word on the SPI MOSI port
 
int single_read_8 (uint8_t *dest)
 read a single byte on the SPI MISO port
 
int burst_read_8 (uint8_t repeated_tx_data, uint8_t *dest, size_t len)
 read a serie of byte on the SPI MISO port
 
bool device_is_connected (uint8_t slave_address)
 a test that checks if the slave_address device is connected
 

Public Attributes

HW_DMAdma_rx
 the DMA channel used for SPI RX
 
HW_DMAdma_tx
 the DMA channel used for SPI TX
 
- Public Attributes inherited from HW_SPI_Master
spi_inst_t * spi
 the spi hardware instance of the Pico that handles the spi master
 

Detailed Description

This is a C++ wrapper for the original pico SDK spi master API, adapted to FreeRTOS environment.

Constructor & Destructor Documentation

◆ rtos_HW_SPI_Master()

rtos_HW_SPI_Master::rtos_HW_SPI_Master ( struct_ConfigMasterSPI master_config,
irq_num_t dma_tx_irq_number = DMA_IRQ_0,
irq_handler_t dma_tx_irq_handler = nullptr,
irq_num_t dma_rx_irq_number = DMA_IRQ_1,
irq_handler_t dma_rx_irq_handler = nullptr )

Construct a new hw spi master object.

Parameters
master_configthe data structure that contains SPI configuration
dma_tx_irq_numberthe DMA IRQ number attached to TX DMA
dma_tx_irq_handlerthe DMA IRQ handler attached to TX DMA
dma_rx_irq_numberthe DMA IRQ number attached to RX DMA
dma_rx_irq_handlerthe DMA IRQ handler attached to RX DMA
Here is the call graph for this function:

Member Function Documentation

◆ burst_read_16()

int rtos_HW_SPI_Master::burst_read_16 ( uint16_t * dst,
size_t len )

read a serie of 16 bit data on the SPI MISO port. Use DMA.

Parameters
dstthe destination of the data
lenthe length of the serie
Returns
error code

◆ burst_read_8()

int rtos_HW_SPI_Master::burst_read_8 ( uint8_t repeated_tx_data,
uint8_t * dest,
size_t len )

read a serie of byte on the SPI MISO port DMA not implemented

Parameters
repeated_tx_datathe byte sent on MOSI port during the read transfer
destthe destination that receives the data
lenthe length of the serie
Returns
error code

◆ burst_write_16()

int rtos_HW_SPI_Master::burst_write_16 ( uint16_t * src,
size_t len )
overridevirtual

send a serie of 16 bit data on the SPI MOSI port. Use DMA.

Parameters
srcthe source of the data
lenthe length of the serie
Returns
error code

Reimplemented from HW_SPI_Master.

◆ burst_write_8()

int rtos_HW_SPI_Master::burst_write_8 ( uint8_t * src,
size_t len )
overridevirtual

send a serie of 8 bit data on the SPI MOSI port DMA not implemented

Parameters
srcthe source of the data
lenthe lenght of the serie
Returns
int the number of byte sent

Reimplemented from HW_SPI_Master.

◆ burst_write_read_8()

int rtos_HW_SPI_Master::burst_write_read_8 ( uint8_t * src,
uint8_t * dest,
size_t len )
overridevirtual

read / write a serie of 8 bit data on the SPI MISO/MOSI ports DMA not implemented

Parameters
srcthe source of the data
destthe destination of the data
lenthe length of the serie
Returns
error code

Reimplemented from HW_SPI_Master.

◆ repeat_write_16()

int rtos_HW_SPI_Master::repeat_write_16 ( uint16_t * src,
size_t len )

repeat a single 16 bit data on the SPI MOSI port. Use DMA.

Parameters
srcthe source of the data
lenthe length of the repetition
Returns
error code

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