NEORV32 - Software Framework Documentation
Functions
neorv32_spi.h File Reference

Serial peripheral interface controller (SPI) HW driver header file. More...

Go to the source code of this file.

Functions

int neorv32_spi_available (void)
 
void neorv32_spi_setup (uint8_t prsc, uint8_t clk_phase, uint8_t clk_polarity, uint8_t data_size)
 
void neorv32_spi_disable (void)
 
void neorv32_spi_enable (void)
 
void neorv32_spi_highspeed_enable (void)
 
void neorv32_spi_highspeed_disable (void)
 
void neorv32_spi_cs_en (uint8_t cs)
 
void neorv32_spi_cs_dis (uint8_t cs)
 
uint32_t neorv32_spi_trans (uint32_t tx_data)
 
void neorv32_spi_put_nonblocking (uint32_t tx_data)
 
uint32_t neorv32_spi_get_nonblocking (void)
 
int neorv32_spi_busy (void)
 

Detailed Description

Serial peripheral interface controller (SPI) HW driver header file.

Note
These functions should only be used if the SPI unit was synthesized (IO_SPI_EN = true).

Function Documentation

◆ neorv32_spi_available()

int neorv32_spi_available ( void  )

Check if SPI unit was synthesized.

Returns
0 if SPI was not synthesized, 1 if SPI is available.

◆ neorv32_spi_busy()

int neorv32_spi_busy ( void  )

Check if SPI transceiver is busy.

Returns
0 if idle, 1 if busy

◆ neorv32_spi_cs_dis()

void neorv32_spi_cs_dis ( uint8_t  cs)

Deactivate SPI chip select signal.

Note
The chip select output lines are HIGH when deactivated.
Parameters
csChip select line to deactivate (0..7).

◆ neorv32_spi_cs_en()

void neorv32_spi_cs_en ( uint8_t  cs)

Activate SPI chip select signal.

Note
The chip select output lines are LOW when activated.
Parameters
csChip select line to activate (0..7).

◆ neorv32_spi_disable()

void neorv32_spi_disable ( void  )

Disable SPI controller.

◆ neorv32_spi_enable()

void neorv32_spi_enable ( void  )

Enable SPI controller.

◆ neorv32_spi_get_nonblocking()

uint32_t neorv32_spi_get_nonblocking ( void  )

Get SPI RX data (non-blocking).

Returns
Receive data (8/16/24/32-bit, LSB-aligned).

◆ neorv32_spi_highspeed_disable()

void neorv32_spi_highspeed_disable ( void  )

Disable high-speed SPI mode.

Note
High-speed SPI mode ignores the programmed clock prescaler configuration.

◆ neorv32_spi_highspeed_enable()

void neorv32_spi_highspeed_enable ( void  )

Enable high-speed SPI mode (running at half of the processor clock).

Note
High-speed SPI mode ignores the programmed clock prescaler configuration.

◆ neorv32_spi_put_nonblocking()

void neorv32_spi_put_nonblocking ( uint32_t  tx_data)

Initiate SPI TX transfer (non-blocking).

Parameters
tx_dataTransmit data (8/16/24/32-bit, LSB-aligned).

◆ neorv32_spi_setup()

void neorv32_spi_setup ( uint8_t  prsc,
uint8_t  clk_phase,
uint8_t  clk_polarity,
uint8_t  data_size 
)

Enable and configure SPI controller. The SPI control register bits are listed in NEORV32_SPI_CTRL_enum.

Parameters
[in]prscClock prescaler select (0..7). See NEORV32_CLOCK_PRSC_enum.
[in]clk_phaseClock phase (0=sample on rising edge, 1=sample on falling edge).
[in]clk_polarityClock polarity (when idle).
[in]data_sizeData transfer size (0: 8-bit, 1: 16-bit, 2: 24-bit, 3: 32-bit).

◆ neorv32_spi_trans()

uint32_t neorv32_spi_trans ( uint32_t  tx_data)

Initiate SPI transfer.

Note
This function is blocking.
Parameters
tx_dataTransmit data (8/16/24/32-bit, LSB-aligned).
Returns
Receive data (8/16/24/32-bit, LSB-aligned).