FD32M0P Microcontroller SDK
|
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 |
struct spi_cfg_t |
SPI Configuation Struct.
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 |
#define SPI_CFG_DEFAULT |
Default Values for SPI in Controller mode.
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.
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. |
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.
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.
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 |
void |
References SPI_REGS_s::MOT_MOD_CNTRL, and SPI_REGS_s::PARITY_CTRL.
Referenced by spi_init().
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.
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 |
void |
References SPI_REGS_s::DATAFRAME_CTRL, and SPI_REGS_s::MODE_CTRL.
Referenced by spi_init().
void spi_start_transaction | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
This function starts spi transaction.
SPI_REGS_PTR | : pointer to the spi register space |
void |
References SPI_REGS_s::MODE_CTRL.
void spi_disable | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
This function disables spi.
SPI_REGS_PTR | : pointer to the spi register space |
void |
References SPI_REGS_s::MODE_CTRL.
void spi_set_loopback | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
This function sets SPI loopback.
SPI_REGS_PTR | : pointer to the spi register space |
void |
References SPI_REGS_s::LOOPBACK_CTRL.
void spi_clr_loopback | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
This function clear SPI loopback.
SPI_REGS_PTR | : pointer to the spi register space |
void |
References SPI_REGS_s::LOOPBACK_CTRL.
void spi_set_tx_ctrl | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint8_t | repeat_tx_data ) |
This function set SPI TX ctrl setting.
SPI_REGS_PTR | : pointer to the spi register space |
repeat_tx_data | : number of spi frames to be repeated after fifo is empty |
void |
References SPI_REGS_s::TX_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.
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 |
void |
References SPI_REGS_s::RX_CTRL.
void spi_init | ( | SPI_REGS_s * | SPI_REGS_PTR, |
spi_cfg_t * | spi_cfg ) |
This function initializes the SPI, with Controller/Peripheral Setting.
SPI_REGS_PTR | : pointer to the spi register space |
spi_cfg | : configuration for SPI. |
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().
uint8_t spi_receive_byte_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
Blocking function to recive a single byte.
SPI_REGS_PTR | : pointer to the spi register space |
byte | data from the rx fifo |
References SPI_RX_FIFO_u::packed_byte, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.
uint16_t spi_receive_halfword_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
Blocking function to recive a half word.
SPI_REGS_PTR | : pointer to the spi register space |
half | word data from the rx fifo |
References SPI_RX_FIFO_u::packed_hw, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.
uint32_t spi_receive_word_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
Blocking function to recive a word.
SPI_REGS_PTR | : pointer to the spi register space |
word | data from the rx fifo |
References SPI_RX_FIFO_u::packed_w, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.
bool spi_receive_byte_non_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint8_t * | byte ) |
Non - Blocking function to recieve a byte.
SPI_REGS_PTR | : pointer to the spi register space |
byte | : pointer to the byte data |
if | data 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.
bool spi_receive_halfword_non_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint16_t * | halfword ) |
Non - Blocking function to recieve a half word.
SPI_REGS_PTR | : pointer to the spi register space |
halfword | : pointer to the halfword data |
if | data 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.
bool spi_receive_word_non_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint32_t * | word ) |
Non - Blocking function to recieve a word.
SPI_REGS_PTR | : pointer to the spi register space |
word | : pointer to the word data |
if | data 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.
void spi_transmit_byte_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint8_t | byte ) |
Blocking function to transmit a byte.
SPI_REGS_PTR | : pointer to the spi register space |
byte | : byte data to be transmitted |
void |
References SPI_TX_FIFO_u::packed_byte, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
void spi_transmit_halfword_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint16_t | halfword ) |
Blocking function to transmit a halfword.
SPI_REGS_PTR | : pointer to the spi register space |
halfword | : halfword data to be transmitted |
void |
References SPI_TX_FIFO_u::packed_hw, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
void spi_transmit_word_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint32_t | word ) |
Blocking function to transmit a word.
SPI_REGS_PTR | : pointer to the spi register space |
word | : word data to be transmitted |
void |
References SPI_TX_FIFO_u::packed_w, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
bool spi_transmit_byte_non_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint8_t | byte ) |
Non - Blocking function to transmit a byte.
SPI_REGS_PTR | : pointer to the spi register space |
byte | : byte data to be transmitted |
True/False | to indicate is the data is transferred succesfully |
References SPI_TX_FIFO_u::packed_byte, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
bool spi_transmit_halfword_non_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint16_t | halfword ) |
Non - Blocking function to transmit a halfword.
SPI_REGS_PTR | : pointer to the spi register space |
halfword | : halfword data to be transmitted |
True/False | to indicate is the data is transferred succesfully |
References SPI_TX_FIFO_u::packed_hw, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
bool spi_transmit_word_non_blocking | ( | SPI_REGS_s * | SPI_REGS_PTR, |
uint32_t | word ) |
Non - Blocking function to transmit word.
SPI_REGS_PTR | : pointer to the spi register space |
word | : word data to be transmitted |
True/False | to indicate is the data is transferred succesfully |
References SPI_TX_FIFO_u::packed_w, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
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.
SPI_REGS_PTR | : pointer to the spi register space |
buffer | : pointer to the byte buffer |
the | number of bytes read |
References SPI_RX_FIFO_u::packed_byte, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.
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.
SPI_REGS_PTR | : pointer to the spi register space |
buffer | : pointer to the halfword buffer |
the | number of halfwords read |
References SPI_RX_FIFO_u::packed_hw, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.
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.
SPI_REGS_PTR | : pointer to the spi register space |
buffer | : pointer to the word buffer |
the | number of words read |
References SPI_RX_FIFO_u::packed_w, SPI_REGS_s::RX_FIFO, and SPI_REGS_s::STS.
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.
SPI_REGS_PTR | : pointer to the spi register space |
buffer | : pointer to the byte buffer |
the | number of bytes transmitted |
References SPI_TX_FIFO_u::packed_byte, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
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.
SPI_REGS_PTR | : pointer to the spi register space |
buffer | : pointer to the halfword buffer |
the | number of halfword transmitted |
References SPI_TX_FIFO_u::packed_hw, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
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.
SPI_REGS_PTR | : pointer to the spi register space |
buffer | : pointer to the word buffer |
the | number of word transmitted |
References SPI_TX_FIFO_u::packed_w, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
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.
SPI_REGS_PTR | : pointer to the spi register space |
buffer | : pointer to the byte buffer |
the | number of bytes transmitted |
References SPI_TX_FIFO_u::packed_byte, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
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.
SPI_REGS_PTR | : pointer to the spi register space |
buffer | : pointer to the halfword buffer |
the | number of halfword transmitted |
References SPI_TX_FIFO_u::packed_hw, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
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.
SPI_REGS_PTR | : pointer to the spi register space |
buffer | : pointer to the word buffer |
the | number of words transmitted |
References SPI_TX_FIFO_u::packed_w, SPI_REGS_s::STS, and SPI_REGS_s::TX_FIFO.
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
SPI_REGS_PTR | : pointer to the spi register space |
soft_cs_en | : en to the soft cs |
cs_sel | : selects the cs |
void |
References SPI_REGS_s::CS_CTRL.
void spi_set_soft_cs | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
function to set soft cs
SPI_REGS_PTR | : pointer to the spi register space |
void |
References SPI_REGS_s::CS_CTRL.
void spi_clr_soft_cs | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
function to set soft cs
SPI_REGS_PTR | : pointer to the spi register space |
void |
References SPI_REGS_s::CS_CTRL.
bool spi_is_idle | ( | SPI_REGS_s * | SPI_REGS_PTR | ) |
function to pool for spi idle
SPI_REGS_PTR | : pointer to the spi register space |
True/False | is 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.