FD32M0P Microcontroller SDK
Loading...
Searching...
No Matches

Data Structures

struct  spi_cfg_t
 SPI Configuation Struct. More...

Macros

#define SPI_CFG_DEFAULT
 Default Values for SPI in Controller mode.

Functions

void spi_set_clk_cfg (SPI_REGS_s *SPI_REGS_PTR, SPI_CLKSEL_CLK_SEL_E clk_sel, uint8_t div_ratio)
 This function updates the clock setting use by the SPI.
void spi_set_moto_mode_cfg (SPI_REGS_s *SPI_REGS_PTR, SPI_MOT_MOD_CNTRL_CLOCK_POLARITY_E clk_polarity, SPI_MOT_MOD_CNTRL_CLOCK_PHASE_E clk_phase, bool parity_en, bool even_partiy)
 This function updates SPI configuration for Moto Mode.
void spi_set_mode_cfg (SPI_REGS_s *SPI_REGS_PTR, SPI_MODE_CTRL_PERIPHERAL_MODE_E mode, SPI_MODE_CTRL_FRAME_FORMAT_E frame_format, uint8_t data_size, bool msb_first)
 This function configure the SPI mode/type of Operation.
void spi_start_transaction (SPI_REGS_s *SPI_REGS_PTR)
 This function starts spi transaction.
void spi_disable (SPI_REGS_s *SPI_REGS_PTR)
 This function disables spi.
void spi_set_loopback (SPI_REGS_s *SPI_REGS_PTR)
 This function sets SPI loopback.
void spi_clr_loopback (SPI_REGS_s *SPI_REGS_PTR)
 This function clear SPI loopback.
void spi_set_tx_ctrl (SPI_REGS_s *SPI_REGS_PTR, uint8_t repeat_tx_data)
 This function set SPI TX ctrl setting.
void spi_set_rx_ctrl (SPI_REGS_s *SPI_REGS_PTR, uint8_t receive_timeout, uint8_t ignore_rx_cnt, uint8_t dly_sample_on_rx)
 This function set SPI RX ctrl setting.
void spi_init (SPI_REGS_s *SPI_REGS_PTR, spi_cfg_t *spi_cfg)
 This function initializes the SPI, with Controller/Peripheral Setting.
uint8_t spi_receive_byte_blocking (SPI_REGS_s *SPI_REGS_PTR)
 Blocking function to recive a single byte.
uint16_t spi_receive_halfword_blocking (SPI_REGS_s *SPI_REGS_PTR)
 Blocking function to recive a half word.
uint32_t spi_receive_word_blocking (SPI_REGS_s *SPI_REGS_PTR)
 Blocking function to recive a word.
bool spi_receive_byte_non_blocking (SPI_REGS_s *SPI_REGS_PTR, uint8_t *byte)
 Non - Blocking function to recieve a byte.
bool spi_receive_halfword_non_blocking (SPI_REGS_s *SPI_REGS_PTR, uint16_t *halfword)
 Non - Blocking function to recieve a half word.
bool spi_receive_word_non_blocking (SPI_REGS_s *SPI_REGS_PTR, uint32_t *word)
 Non - Blocking function to recieve a word.
void spi_transmit_byte_blocking (SPI_REGS_s *SPI_REGS_PTR, uint8_t byte)
 Blocking function to transmit a byte.
void spi_transmit_halfword_blocking (SPI_REGS_s *SPI_REGS_PTR, uint16_t halfword)
 Blocking function to transmit a halfword.
void spi_transmit_word_blocking (SPI_REGS_s *SPI_REGS_PTR, uint32_t word)
 Blocking function to transmit a word.
bool spi_transmit_byte_non_blocking (SPI_REGS_s *SPI_REGS_PTR, uint8_t byte)
 Non - Blocking function to transmit a byte.
bool spi_transmit_halfword_non_blocking (SPI_REGS_s *SPI_REGS_PTR, uint16_t halfword)
 Non - Blocking function to transmit a halfword.
bool spi_transmit_word_non_blocking (SPI_REGS_s *SPI_REGS_PTR, uint32_t word)
 Non - Blocking function to transmit word.
uint8_t spi_rx_fifo_drain_byte (SPI_REGS_s *SPI_REGS_PTR, uint8_t *buffer, uint8_t max_count)
 Non - Blocking function to drain the rx fifo based on max count.
uint8_t spi_rx_fifo_drain_halfword (SPI_REGS_s *SPI_REGS_PTR, uint16_t *buffer, uint8_t max_count)
 Non - Blocking function to drain the rx fifo based on max count.
uint8_t spi_rx_fifo_drain_word (SPI_REGS_s *SPI_REGS_PTR, uint32_t *buffer, uint8_t max_count)
 Non - Blocking function to drain the rx fifo based on max count.
uint8_t spi_tx_fifo_fill_byte_non_blocking (SPI_REGS_s *SPI_REGS_PTR, const uint8_t *buffer, uint8_t max_count)
 Non - Blocking function to fill the tx fifo based on max count.
uint8_t spi_tx_fifo_fill_halfword_non_blocking (SPI_REGS_s *SPI_REGS_PTR, const uint16_t *buffer, uint8_t max_count)
 Non - Blocking function to fill the tx fifo based on max count.
uint8_t spi_tx_fifo_fill_word_non_blocking (SPI_REGS_s *SPI_REGS_PTR, const uint32_t *buffer, uint8_t max_count)
 Non - Blocking function to fill the tx fifo based on max count.
void spi_tx_fifo_fill_byte_blocking (SPI_REGS_s *SPI_REGS_PTR, const uint8_t *buffer, uint8_t max_count)
 Blocking function to fill the tx fifo based on max count.
void spi_tx_fifo_fill_halfword_blocking (SPI_REGS_s *SPI_REGS_PTR, const uint16_t *buffer, uint8_t max_count)
 Blocking function to fill the tx fifo based on max count.
void spi_tx_fifo_fill_word_blocking (SPI_REGS_s *SPI_REGS_PTR, const uint32_t *buffer, uint8_t max_count)
 Blocking function to fill the tx fifo based on max count.
void spi_enable_cs (SPI_REGS_s *SPI_REGS_PTR, bool soft_cs_en, uint8_t cs_sel)
 function to set enable software controlled cs and sel the cs
void spi_set_soft_cs (SPI_REGS_s *SPI_REGS_PTR)
 function to set soft cs
void spi_clr_soft_cs (SPI_REGS_s *SPI_REGS_PTR)
 function to set soft cs
bool spi_is_idle (SPI_REGS_s *SPI_REGS_PTR)
 function to pool for spi idle

Detailed Description


Data Structure Documentation

◆ spi_cfg_t

struct spi_cfg_t

SPI Configuation Struct.

Note
This struct contain parameters for initializing SPI while using either in controller or peripheral mode.
Data Fields
SPI_MODE_CTRL_FRAME_FORMAT_E frame_format
uint8_t data_size_sel
bool msb_first
SPI_MOT_MOD_CNTRL_CLOCK_POLARITY_E clk_polarity
SPI_MOT_MOD_CNTRL_CLOCK_PHASE_E clk_phase
bool parity_en
bool even_partiy
SPI_MODE_CTRL_PERIPHERAL_MODE_E mode

Macro Definition Documentation

◆ SPI_CFG_DEFAULT

#define SPI_CFG_DEFAULT
Value:
{ \
.data_size_sel = 8 ,\
.msb_first = 0 ,\
.parity_en = 0 ,\
.even_partiy = 0 ,\
}
@ SPI_MODE_CTRL_PERIPHERAL_MODE_CONTROLLER
0x0
Definition SPI_REGS.h:806
@ SPI_MODE_CTRL_FRAME_FORMAT_MOTOROLA
0x0
Definition SPI_REGS.h:814
@ SPI_MOT_MOD_CNTRL_CLOCK_POLARITY_LOW
0x0
Definition SPI_REGS.h:790
@ SPI_MOT_MOD_CNTRL_CLOCK_PHASE_LEADING
0x0
Definition SPI_REGS.h:798

Default Values for SPI in Controller mode.

Function Documentation

◆ spi_set_clk_cfg()

void spi_set_clk_cfg ( SPI_REGS_s * SPI_REGS_PTR,
SPI_CLKSEL_CLK_SEL_E clk_sel,
uint8_t div_ratio )

This function updates the clock setting use by the SPI.

Parameters
SPI_REGS_PTR: pointer to the spi register space
clk_sel: enum for clock to be used for SPI
div_ratio: 8 bit value for the clock divider.
Return values
void

References SPI_REGS_s::CLK_CTRL, SPI_REGS_s::CLK_DIV, SPI_REGS_s::CLKSEL, SPI_CLK_DIV_u::packed_w, and SPI_CLKSEL_u::packed_w.

◆ spi_set_moto_mode_cfg()

void spi_set_moto_mode_cfg ( SPI_REGS_s * SPI_REGS_PTR,
SPI_MOT_MOD_CNTRL_CLOCK_POLARITY_E clk_polarity,
SPI_MOT_MOD_CNTRL_CLOCK_PHASE_E clk_phase,
bool parity_en,
bool even_partiy )

This function updates SPI configuration for Moto Mode.

Parameters
SPI_REGS_PTR: pointer to the spi register space
clk_polarity: enum for clock polarity
clk_phase: enum for clock phase
parity_en: set this to enable parity
even_partiy: set this to enable enable parity
Return values
void

References SPI_REGS_s::MOT_MOD_CNTRL, and SPI_REGS_s::PARITY_CTRL.

Referenced by spi_init().

Here is the caller graph for this function:

◆ spi_set_mode_cfg()

void spi_set_mode_cfg ( SPI_REGS_s * SPI_REGS_PTR,
SPI_MODE_CTRL_PERIPHERAL_MODE_E mode,
SPI_MODE_CTRL_FRAME_FORMAT_E frame_format,
uint8_t data_size,
bool msb_first )

This function configure the SPI mode/type of Operation.

Parameters
SPI_REGS_PTR: pointer to the spi register space
mode: enum for controller or peripheral mode
frame_format: enum for the type of SPI
data_size: Input for the size of the data
msb_first: Set this enable msb first
Return values
void

References SPI_REGS_s::DATAFRAME_CTRL, and SPI_REGS_s::MODE_CTRL.

Referenced by spi_init().

Here is the caller graph for this function:

◆ spi_start_transaction()

void spi_start_transaction ( SPI_REGS_s * SPI_REGS_PTR)

This function starts spi transaction.

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
void

References SPI_REGS_s::MODE_CTRL.

◆ spi_disable()

void spi_disable ( SPI_REGS_s * SPI_REGS_PTR)

This function disables spi.

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
void

References SPI_REGS_s::MODE_CTRL.

◆ spi_set_loopback()

void spi_set_loopback ( SPI_REGS_s * SPI_REGS_PTR)

This function sets SPI loopback.

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
void

References SPI_REGS_s::LOOPBACK_CTRL.

◆ spi_clr_loopback()

void spi_clr_loopback ( SPI_REGS_s * SPI_REGS_PTR)

This function clear SPI loopback.

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
void

References SPI_REGS_s::LOOPBACK_CTRL.

◆ spi_set_tx_ctrl()

void spi_set_tx_ctrl ( SPI_REGS_s * SPI_REGS_PTR,
uint8_t repeat_tx_data )

This function set SPI TX ctrl setting.

Parameters
SPI_REGS_PTR: pointer to the spi register space
repeat_tx_data: number of spi frames to be repeated after fifo is empty
Return values
void

References SPI_REGS_s::TX_CTRL.

◆ spi_set_rx_ctrl()

void spi_set_rx_ctrl ( SPI_REGS_s * SPI_REGS_PTR,
uint8_t receive_timeout,
uint8_t ignore_rx_cnt,
uint8_t dly_sample_on_rx )

This function set SPI RX ctrl setting.

Parameters
SPI_REGS_PTR: pointer to the spi register space
receive_timeout: timeout for RX not receing any data to generate interrupt. Timeout is specified in number of clk_spi cycles
ignore_rx_cnt: number of spi frame rx should ignore
dly_sample_on_rx: the delay on the rx sample for improving stablity at higher clock speeds
Return values
void

References SPI_REGS_s::RX_CTRL.

◆ spi_init()

void spi_init ( SPI_REGS_s * SPI_REGS_PTR,
spi_cfg_t * spi_cfg )

This function initializes the SPI, with Controller/Peripheral Setting.

Parameters
SPI_REGS_PTR: pointer to the spi register space
spi_cfg: configuration for SPI.
Return values
void

References spi_cfg_t::clk_phase, spi_cfg_t::clk_polarity, spi_cfg_t::data_size_sel, spi_cfg_t::even_partiy, spi_cfg_t::frame_format, spi_cfg_t::mode, spi_cfg_t::msb_first, spi_cfg_t::parity_en, spi_set_mode_cfg(), and spi_set_moto_mode_cfg().

Here is the call graph for this function:

◆ spi_receive_byte_blocking()

uint8_t spi_receive_byte_blocking ( SPI_REGS_s * SPI_REGS_PTR)

Blocking function to recive a single byte.

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
bytedata from the rx fifo

References SPI_RX_FIFO_u::packed_byte, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.

◆ spi_receive_halfword_blocking()

uint16_t spi_receive_halfword_blocking ( SPI_REGS_s * SPI_REGS_PTR)

Blocking function to recive a half word.

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
halfword data from the rx fifo

References SPI_RX_FIFO_u::packed_hw, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.

◆ spi_receive_word_blocking()

uint32_t spi_receive_word_blocking ( SPI_REGS_s * SPI_REGS_PTR)

Blocking function to recive a word.

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
worddata from the rx fifo

References SPI_RX_FIFO_u::packed_w, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.

◆ spi_receive_byte_non_blocking()

bool spi_receive_byte_non_blocking ( SPI_REGS_s * SPI_REGS_PTR,
uint8_t * byte )

Non - Blocking function to recieve a byte.

Parameters
SPI_REGS_PTR: pointer to the spi register space
byte: pointer to the byte data
Return values
ifdata is present in the fifo, true is returned

References SPI_RX_FIFO_u::packed_byte, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.

◆ spi_receive_halfword_non_blocking()

bool spi_receive_halfword_non_blocking ( SPI_REGS_s * SPI_REGS_PTR,
uint16_t * halfword )

Non - Blocking function to recieve a half word.

Parameters
SPI_REGS_PTR: pointer to the spi register space
halfword: pointer to the halfword data
Return values
ifdata is present in the fifo, true is returned

References SPI_RX_FIFO_u::packed_hw, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.

◆ spi_receive_word_non_blocking()

bool spi_receive_word_non_blocking ( SPI_REGS_s * SPI_REGS_PTR,
uint32_t * word )

Non - Blocking function to recieve a word.

Parameters
SPI_REGS_PTR: pointer to the spi register space
word: pointer to the word data
Return values
ifdata is present in the fifo, true is returned

References SPI_RX_FIFO_u::packed_w, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.

◆ spi_transmit_byte_blocking()

void spi_transmit_byte_blocking ( SPI_REGS_s * SPI_REGS_PTR,
uint8_t byte )

Blocking function to transmit a byte.

Parameters
SPI_REGS_PTR: pointer to the spi register space
byte: byte data to be transmitted
Return values
void

References SPI_TX_FIFO_u::packed_byte, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_transmit_halfword_blocking()

void spi_transmit_halfword_blocking ( SPI_REGS_s * SPI_REGS_PTR,
uint16_t halfword )

Blocking function to transmit a halfword.

Parameters
SPI_REGS_PTR: pointer to the spi register space
halfword: halfword data to be transmitted
Return values
void

References SPI_TX_FIFO_u::packed_hw, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_transmit_word_blocking()

void spi_transmit_word_blocking ( SPI_REGS_s * SPI_REGS_PTR,
uint32_t word )

Blocking function to transmit a word.

Parameters
SPI_REGS_PTR: pointer to the spi register space
word: word data to be transmitted
Return values
void

References SPI_TX_FIFO_u::packed_w, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_transmit_byte_non_blocking()

bool spi_transmit_byte_non_blocking ( SPI_REGS_s * SPI_REGS_PTR,
uint8_t byte )

Non - Blocking function to transmit a byte.

Parameters
SPI_REGS_PTR: pointer to the spi register space
byte: byte data to be transmitted
Return values
True/Falseto indicate is the data is transferred succesfully

References SPI_TX_FIFO_u::packed_byte, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_transmit_halfword_non_blocking()

bool spi_transmit_halfword_non_blocking ( SPI_REGS_s * SPI_REGS_PTR,
uint16_t halfword )

Non - Blocking function to transmit a halfword.

Parameters
SPI_REGS_PTR: pointer to the spi register space
halfword: halfword data to be transmitted
Return values
True/Falseto indicate is the data is transferred succesfully

References SPI_TX_FIFO_u::packed_hw, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_transmit_word_non_blocking()

bool spi_transmit_word_non_blocking ( SPI_REGS_s * SPI_REGS_PTR,
uint32_t word )

Non - Blocking function to transmit word.

Parameters
SPI_REGS_PTR: pointer to the spi register space
word: word data to be transmitted
Return values
True/Falseto indicate is the data is transferred succesfully

References SPI_TX_FIFO_u::packed_w, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_rx_fifo_drain_byte()

uint8_t spi_rx_fifo_drain_byte ( SPI_REGS_s * SPI_REGS_PTR,
uint8_t * buffer,
uint8_t max_count )

Non - Blocking function to drain the rx fifo based on max count.

Parameters
SPI_REGS_PTR: pointer to the spi register space
buffer: pointer to the byte buffer
Return values
thenumber of bytes read

References SPI_RX_FIFO_u::packed_byte, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.

◆ spi_rx_fifo_drain_halfword()

uint8_t spi_rx_fifo_drain_halfword ( SPI_REGS_s * SPI_REGS_PTR,
uint16_t * buffer,
uint8_t max_count )

Non - Blocking function to drain the rx fifo based on max count.

Parameters
SPI_REGS_PTR: pointer to the spi register space
buffer: pointer to the halfword buffer
Return values
thenumber of halfwords read

References SPI_RX_FIFO_u::packed_hw, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.

◆ spi_rx_fifo_drain_word()

uint8_t spi_rx_fifo_drain_word ( SPI_REGS_s * SPI_REGS_PTR,
uint32_t * buffer,
uint8_t max_count )

Non - Blocking function to drain the rx fifo based on max count.

Parameters
SPI_REGS_PTR: pointer to the spi register space
buffer: pointer to the word buffer
Return values
thenumber of words read

References SPI_RX_FIFO_u::packed_w, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.

◆ spi_tx_fifo_fill_byte_non_blocking()

uint8_t spi_tx_fifo_fill_byte_non_blocking ( SPI_REGS_s * SPI_REGS_PTR,
const uint8_t * buffer,
uint8_t max_count )

Non - Blocking function to fill the tx fifo based on max count.

Parameters
SPI_REGS_PTR: pointer to the spi register space
buffer: pointer to the byte buffer
Return values
thenumber of bytes transmitted

References SPI_TX_FIFO_u::packed_byte, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_tx_fifo_fill_halfword_non_blocking()

uint8_t spi_tx_fifo_fill_halfword_non_blocking ( SPI_REGS_s * SPI_REGS_PTR,
const uint16_t * buffer,
uint8_t max_count )

Non - Blocking function to fill the tx fifo based on max count.

Parameters
SPI_REGS_PTR: pointer to the spi register space
buffer: pointer to the halfword buffer
Return values
thenumber of halfword transmitted

References SPI_TX_FIFO_u::packed_hw, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_tx_fifo_fill_word_non_blocking()

uint8_t spi_tx_fifo_fill_word_non_blocking ( SPI_REGS_s * SPI_REGS_PTR,
const uint32_t * buffer,
uint8_t max_count )

Non - Blocking function to fill the tx fifo based on max count.

Parameters
SPI_REGS_PTR: pointer to the spi register space
buffer: pointer to the word buffer
Return values
thenumber of word transmitted

References SPI_TX_FIFO_u::packed_w, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_tx_fifo_fill_byte_blocking()

void spi_tx_fifo_fill_byte_blocking ( SPI_REGS_s * SPI_REGS_PTR,
const uint8_t * buffer,
uint8_t max_count )

Blocking function to fill the tx fifo based on max count.

Parameters
SPI_REGS_PTR: pointer to the spi register space
buffer: pointer to the byte buffer
Return values
thenumber of bytes transmitted

References SPI_TX_FIFO_u::packed_byte, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_tx_fifo_fill_halfword_blocking()

void spi_tx_fifo_fill_halfword_blocking ( SPI_REGS_s * SPI_REGS_PTR,
const uint16_t * buffer,
uint8_t max_count )

Blocking function to fill the tx fifo based on max count.

Parameters
SPI_REGS_PTR: pointer to the spi register space
buffer: pointer to the halfword buffer
Return values
thenumber of halfword transmitted

References SPI_TX_FIFO_u::packed_hw, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_tx_fifo_fill_word_blocking()

void spi_tx_fifo_fill_word_blocking ( SPI_REGS_s * SPI_REGS_PTR,
const uint32_t * buffer,
uint8_t max_count )

Blocking function to fill the tx fifo based on max count.

Parameters
SPI_REGS_PTR: pointer to the spi register space
buffer: pointer to the word buffer
Return values
thenumber of words transmitted

References SPI_TX_FIFO_u::packed_w, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.

◆ spi_enable_cs()

void spi_enable_cs ( SPI_REGS_s * SPI_REGS_PTR,
bool soft_cs_en,
uint8_t cs_sel )

function to set enable software controlled cs and sel the cs

Parameters
SPI_REGS_PTR: pointer to the spi register space
soft_cs_en: en to the soft cs
cs_sel: selects the cs
Return values
void

References SPI_REGS_s::CS_CTRL.

◆ spi_set_soft_cs()

void spi_set_soft_cs ( SPI_REGS_s * SPI_REGS_PTR)

function to set soft cs

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
void

References SPI_REGS_s::CS_CTRL.

◆ spi_clr_soft_cs()

void spi_clr_soft_cs ( SPI_REGS_s * SPI_REGS_PTR)

function to set soft cs

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
void

References SPI_REGS_s::CS_CTRL.

◆ spi_is_idle()

bool spi_is_idle ( SPI_REGS_s * SPI_REGS_PTR)

function to pool for spi idle

Parameters
SPI_REGS_PTR: pointer to the spi register space
Return values
True/Falseis spi is in idle or not

References SPI_REGS_s::INTR_EVENT, SPI_INTR_EVENT_u::packed_w, SPI_INTR_EVENT_IDLE_MASK, and SPI_INTR_EVENT_IDLE_OFS.