HPM SDK
HPMicro Software Development Kit
SPI driver APIs

SPI driver APIs. More...

Data Structures

struct  spi_master_timing_config_t
 spi master interface timing config structure More...
 
struct  spi_timing_config_t
 spi interface timing config structure More...
 
struct  spi_master_format_config_t
 spi master transfer format config structure More...
 
struct  spi_common_format_config_t
 spi common format config structure More...
 
struct  spi_format_config_t
 spi format config structure More...
 
struct  spi_master_control_config_t
 spi master transfer control config structure More...
 
struct  spi_slave_control_config_t
 spi slave transfer control config structure More...
 
struct  spi_common_control_config_t
 spi common transfer control config structure More...
 
struct  spi_control_config_t
 spi control config structure More...
 

Enumerations

enum  spi_dma_enable_t { spi_tx_dma_enable = SPI_CTRL_TXDMAEN_MASK , spi_rx_dma_enable = SPI_CTRL_RXDMAEN_MASK }
 spi dma enable More...
 
enum  spi_interrupt_t {
  spi_rx_fifo_overflow_int = SPI_INTREN_RXFIFOORINTEN_MASK , spi_tx_fifo_underflow_int = SPI_INTREN_TXFIFOURINTEN_MASK , spi_rx_fifo_threshold_int = SPI_INTREN_RXFIFOINTEN_MASK , spi_tx_fifo_threshold_int = SPI_INTREN_TXFIFOINTEN_MASK ,
  spi_end_int = SPI_INTREN_ENDINTEN_MASK , spi_slave_cmd_int = SPI_INTREN_SLVCMDEN_MASK
}
 spi interrupt mask More...
 
enum  spi_mode_selection_t { spi_master_mode = 0 , spi_slave_mode }
 spi mode selection More...
 
enum  spi_sclk_idle_state_t { spi_sclk_low_idle = 0 , spi_sclk_high_idle }
 spi clock polarity More...
 
enum  spi_sclk_sampling_clk_edges_t { spi_sclk_sampling_odd_clk_edges = 0 , spi_sclk_sampling_even_clk_edges }
 spi clock phase More...
 
enum  spi_cs2sclk_duration_t { spi_cs2sclk_half_sclk_1 = 0 , spi_cs2sclk_half_sclk_2 , spi_cs2sclk_half_sclk_3 , spi_cs2sclk_half_sclk_4 }
 spi cs to sclk edge duration More...
 
enum  spi_csht_duration_t {
  spi_csht_half_sclk_1 = 0 , spi_csht_half_sclk_2 , spi_csht_half_sclk_3 , spi_csht_half_sclk_4 ,
  spi_csht_half_sclk_5 , spi_csht_half_sclk_6 , spi_csht_half_sclk_7 , spi_csht_half_sclk_8 ,
  spi_csht_half_sclk_9 , spi_csht_half_sclk_10 , spi_csht_half_sclk_11 , spi_csht_half_sclk_12 ,
  spi_csht_half_sclk_13 , spi_csht_half_sclk_14 , spi_csht_half_sclk_15 , spi_csht_half_sclk_16
}
 spi cs high level duration More...
 
enum  spi_addr_phase_format_t { spi_address_phase_format_single_io_mode = 0 , spi_address_phase_format_dualquad_io_mode }
 spi address phase format More...
 
enum  spi_trans_mode_t {
  spi_trans_write_read_together = 0 , spi_trans_write_only , spi_trans_read_only , spi_trans_write_read ,
  spi_trans_read_write , spi_trans_write_dummy_read , spi_trans_read_dummy_write , spi_trans_no_data ,
  spi_trans_dummy_write , spi_trans_dummy_read
}
 spi transfer mode More...
 
enum  spi_data_phase_format_t { spi_single_io_mode = 0 , spi_dual_io_mode , spi_quad_io_mode }
 spi data phase format More...
 
enum  spi_token_value_t { spi_token_value_0x00 = 0 , spi_token_value_0x69 }
 spi token value More...
 
enum  spi_dummy_count_t { spi_dummy_count_1 = 0 , spi_dummy_count_2 , spi_dummy_count_3 , spi_dummy_count_4 }
 spi dummy count More...
 
enum  spi_shift_direction_t { msb_first = 0 , lsb_first }
 
enum  spi_cs_index_t { spi_cs_0 = 1 , spi_cs_1 = 2 , spi_cs_2 = 4 , spi_cs_3 = 8 }
 
enum  spi_address_len_t { addrlen_8bit = 0 , addrlen_16bit , addrlen_24bit , addrlen_32bit }
 
enum  spi_directio_pin_t {
  hold_pin = 0 , wp_pin , miso_pin , mosi_pin ,
  sclk_pin , cs_pin
}
 
enum  { status_spi_master_busy = MAKE_STATUS(status_group_spi, 1) }
 SPI status. More...
 

Functions

void spi_master_get_default_timing_config (spi_timing_config_t *config)
 spi master get default timing config More...
 
void spi_master_get_default_format_config (spi_format_config_t *config)
 spi master get default format config More...
 
void spi_master_get_default_control_config (spi_control_config_t *config)
 spi master get default control config More...
 
void spi_slave_get_default_format_config (spi_format_config_t *config)
 spi slave get default format config More...
 
void spi_slave_get_default_control_config (spi_control_config_t *config)
 spi slave get default control config More...
 
hpm_stat_t spi_master_timing_init (SPI_Type *ptr, spi_timing_config_t *config)
 spi master timing initialization More...
 
void spi_format_init (SPI_Type *ptr, spi_format_config_t *config)
 spi format initialization More...
 
hpm_stat_t spi_transfer (SPI_Type *ptr, spi_control_config_t *config, uint8_t *cmd, uint32_t *addr, uint8_t *wbuff, uint32_t wcount, uint8_t *rbuff, uint32_t rcount)
 spi transfer More...
 
hpm_stat_t spi_setup_dma_transfer (SPI_Type *ptr, spi_control_config_t *config, uint8_t *cmd, uint32_t *addr, uint32_t wcount, uint32_t rcount)
 spi setup dma transfer More...
 
hpm_stat_t spi_wait_for_idle_status (SPI_Type *ptr)
 spi wait for idle status More...
 
hpm_stat_t spi_wait_for_busy_status (SPI_Type *ptr)
 spi wait for busy status More...
 
static void spi_set_tx_fifo_threshold (SPI_Type *ptr, uint32_t threshold)
 SPI set TX FIFO threshold. More...
 
static void spi_set_rx_fifo_threshold (SPI_Type *ptr, uint32_t threshold)
 SPI set RX FIFO threshold. More...
 
static void spi_enable_dma (SPI_Type *ptr, uint32_t mask)
 Enables the SPI DMA request. More...
 
static void spi_disable_dma (SPI_Type *ptr, uint32_t mask)
 Disables the SPI DMA request. More...
 
static uint32_t spi_get_interrupt_status (SPI_Type *ptr)
 Get the SPI interrupt status. More...
 
static void spi_clear_interrupt_status (SPI_Type *ptr, uint32_t mask)
 Clear the SPI interrupt status. More...
 
static void spi_enable_interrupt (SPI_Type *ptr, uint32_t mask)
 Enables the SPI interrupt. More...
 
static void spi_disable_interrupt (SPI_Type *ptr, uint32_t mask)
 Disables the SPI interrupt. More...
 
hpm_stat_t spi_write_read_data (SPI_Type *ptr, uint8_t data_len_in_bytes, uint8_t *wbuff, uint32_t wcount, uint8_t *rbuff, uint32_t rcount)
 spi write and read data More...
 
hpm_stat_t spi_read_data (SPI_Type *ptr, uint8_t data_len_in_bytes, uint8_t *buff, uint32_t count)
 spi read data More...
 
hpm_stat_t spi_write_data (SPI_Type *ptr, uint8_t data_len_in_bytes, uint8_t *buff, uint32_t count)
 spi write data More...
 
hpm_stat_t spi_write_command (SPI_Type *ptr, spi_mode_selection_t mode, spi_control_config_t *config, uint8_t *cmd)
 spi write command More...
 
hpm_stat_t spi_read_command (SPI_Type *ptr, spi_mode_selection_t mode, spi_control_config_t *config, uint8_t *cmd)
 spi read command More...
 
hpm_stat_t spi_write_address (SPI_Type *ptr, spi_mode_selection_t mode, spi_control_config_t *config, uint32_t *addr)
 spi write address More...
 
hpm_stat_t spi_control_init (SPI_Type *ptr, spi_control_config_t *config, uint32_t wcount, uint32_t rcount)
 spi control initialization More...
 
static uint8_t spi_get_data_length_in_bits (SPI_Type *ptr)
 Get the SPI data length in bits. More...
 
static uint8_t spi_get_data_length_in_bytes (SPI_Type *ptr)
 Get the SPI data length in bytes. More...
 
static bool spi_is_active (SPI_Type *ptr)
 SPI get active status. More...
 
static void spi_enable_tx_dma (SPI_Type *ptr)
 SPI enable tx dma. More...
 
static void spi_disable_tx_dma (SPI_Type *ptr)
 SPI disable tx dma. More...
 
static void spi_enable_rx_dma (SPI_Type *ptr)
 SPI enable rx dma. More...
 
static void spi_disable_rx_dma (SPI_Type *ptr)
 SPI disable rx dma. More...
 
static uint32_t spi_slave_get_sent_data_count (SPI_Type *ptr)
 SPI slave get sent data count. More...
 
static uint32_t spi_slave_get_received_data_count (SPI_Type *ptr)
 SPI slave get received data count. More...
 
static void spi_set_clock_phase (SPI_Type *ptr, spi_sclk_sampling_clk_edges_t clock_phase)
 set spi clock phase More...
 
static spi_sclk_sampling_clk_edges_t spi_get_clock_phase (SPI_Type *ptr)
 get spi clock phase More...
 
static void spi_set_clock_polarity (SPI_Type *ptr, spi_sclk_idle_state_t clock_polarity)
 set spi clock polarity More...
 
static spi_sclk_idle_state_t spi_get_clock_polarity (SPI_Type *ptr)
 get spi clock phase More...
 
static hpm_stat_t spi_set_data_bits (SPI_Type *ptr, uint8_t nbits)
 set spi the length of each data unit in bits More...
 
static void spi_transmit_fifo_reset (SPI_Type *ptr)
 SPI transmit fifo reset. More...
 
static void spi_receive_fifo_reset (SPI_Type *ptr)
 SPI receive fifo reset. More...
 
static void spi_reset (SPI_Type *ptr)
 SPI reset. More...
 
static void spi_set_address_len (SPI_Type *ptr, spi_address_len_t addrlen)
 set spi the length of address More...
 
static void spi_enable_data_merge (SPI_Type *ptr)
 Enable SPI data merge. More...
 
static void spi_disable_data_merge (SPI_Type *ptr)
 Disable SPI data merge. More...
 
hpm_stat_t spi_directio_enable_output (SPI_Type *ptr, spi_directio_pin_t pin)
 enable specific pin output for spi directio More...
 
hpm_stat_t spi_directio_disable_output (SPI_Type *ptr, spi_directio_pin_t pin)
 disable specific pin output for spi directio More...
 
hpm_stat_t spi_directio_write (SPI_Type *ptr, spi_directio_pin_t pin, bool high)
 write specified pin level for spi directio More...
 
uint8_t spi_directio_read (SPI_Type *ptr, spi_directio_pin_t pin)
 Read specified pin level for spi directio. More...
 
static void spi_enable_directio (SPI_Type *ptr)
 Enable SPI directIO control function. More...
 
static void spi_disable_directio (SPI_Type *ptr)
 Disable SPI directIO control function. More...
 
static uint8_t spi_get_directio_enable_status (SPI_Type *ptr)
 get whether spi directio function is enabled More...
 
static uint8_t spi_get_rx_fifo_valid_data_size (SPI_Type *ptr)
 Get valid data size in receive FIFO. More...
 
static uint8_t spi_get_tx_fifo_valid_data_size (SPI_Type *ptr)
 Get valid data size in transmit FIFO. More...
 
static uint8_t spi_get_rx_fifo_size (SPI_Type *ptr)
 Get SPI RXFIFO size. More...
 
static uint8_t spi_get_tx_fifo_size (SPI_Type *ptr)
 Get SPI TXFIFO size. More...
 
static void spi_slave_enable_data_only (SPI_Type *ptr)
 SPI slave enable only date mode. More...
 
static void spi_slave_disable_data_only (SPI_Type *ptr)
 SPI slave disable only date mode. More...
 
static void spi_master_enable_command_phase (SPI_Type *ptr)
 SPI master enable command phase. More...
 
static void spi_master_disable_command_phase (SPI_Type *ptr)
 SPI master disable command phase. More...
 
static void spi_master_enable_address_phase (SPI_Type *ptr)
 SPI master enable address phase. More...
 
static void spi_master_disable_address_phase (SPI_Type *ptr)
 SPI master disable address phase. More...
 
static void spi_master_set_address_phase_format (SPI_Type *ptr, spi_addr_phase_format_t format)
 SPI master set address phase format. More...
 
static void spi_set_transfer_mode (SPI_Type *ptr, spi_trans_mode_t mode)
 SPI master set transfer mode. More...
 
static void spi_master_enable_token_transfer (SPI_Type *ptr)
 SPI master enable token transfer. More...
 
static void spi_master_disable_token_transfer (SPI_Type *ptr)
 SPI master disable token transfer. More...
 
static void spi_set_write_data_count (SPI_Type *ptr, uint32_t count)
 SPI master set transfer count for write data. More...
 
static void spi_set_read_data_count (SPI_Type *ptr, uint32_t count)
 SPI master set transfer count for read data. More...
 
static void spi_master_set_token_value (SPI_Type *ptr, spi_token_value_t value)
 SPI master set the value of the one-byte special token following the address phase for SPI read transfers. More...
 
static void spi_set_dummy_count (SPI_Type *ptr, spi_dummy_count_t count)
 SPI master set dummy data count. More...
 
static void spi_master_set_cs2sclk_timing (SPI_Type *ptr, spi_cs2sclk_duration_t duration)
 SPI master set the minimum time between the edges of SPI CS and the edges of SCLK. More...
 
static spi_cs2sclk_duration_t spi_master_get_cs2sclk_timing (SPI_Type *ptr)
 SPI master get the minimum time between the edges of SPI CS and the edges of SCLK. More...
 
static void spi_master_set_csht_timing (SPI_Type *ptr, spi_csht_duration_t duration)
 SPI master set the minimum time that SPI CS should stay HIGH. More...
 
static spi_csht_duration_t spi_master_get_csht_timing (SPI_Type *ptr)
 SPI master get the minimum time that SPI CS should stay HIGH. More...
 
static void spi_master_set_sclk_div (SPI_Type *ptr, uint8_t div)
 SPI master set the clock frequency ratio between the clock source and SPI SCLK. More...
 
static uint8_t spi_master_get_sclk_div (SPI_Type *ptr)
 SPI master get the clock frequency ratio between the clock source and SPI SCLK. More...
 
static void spi_slave_set_user_status (SPI_Type *ptr, uint16_t user_status)
 SPI slave set the user defined status flags. More...
 
static void spi_master_set_data_phase_format (SPI_Type *ptr, spi_data_phase_format_t format)
 SPI master set data phase format. More...
 
static spi_data_phase_format_t spi_master_get_data_phase_format (SPI_Type *ptr)
 SPI master get data phase format. More...
 
static void spi_set_shift_direction (SPI_Type *ptr, spi_shift_direction_t shift_direction)
 set spi shift direction More...
 
static spi_shift_direction_t spi_get_shift_direction (SPI_Type *ptr)
 get spi shift direction More...
 

Detailed Description

SPI driver APIs.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

#include <drivers/inc/hpm_spi_drv.h>

SPI status.

Enumerator
status_spi_master_busy 

◆ spi_addr_phase_format_t

#include <drivers/inc/hpm_spi_drv.h>

spi address phase format

Enumerator
spi_address_phase_format_single_io_mode 
spi_address_phase_format_dualquad_io_mode 

◆ spi_address_len_t

#include <drivers/inc/hpm_spi_drv.h>

Enumerator
addrlen_8bit 
addrlen_16bit 
addrlen_24bit 
addrlen_32bit 

◆ spi_cs2sclk_duration_t

#include <drivers/inc/hpm_spi_drv.h>

spi cs to sclk edge duration

Enumerator
spi_cs2sclk_half_sclk_1 
spi_cs2sclk_half_sclk_2 
spi_cs2sclk_half_sclk_3 
spi_cs2sclk_half_sclk_4 

◆ spi_cs_index_t

#include <drivers/inc/hpm_spi_drv.h>

Enumerator
spi_cs_0 
spi_cs_1 
spi_cs_2 
spi_cs_3 

◆ spi_csht_duration_t

#include <drivers/inc/hpm_spi_drv.h>

spi cs high level duration

Enumerator
spi_csht_half_sclk_1 
spi_csht_half_sclk_2 
spi_csht_half_sclk_3 
spi_csht_half_sclk_4 
spi_csht_half_sclk_5 
spi_csht_half_sclk_6 
spi_csht_half_sclk_7 
spi_csht_half_sclk_8 
spi_csht_half_sclk_9 
spi_csht_half_sclk_10 
spi_csht_half_sclk_11 
spi_csht_half_sclk_12 
spi_csht_half_sclk_13 
spi_csht_half_sclk_14 
spi_csht_half_sclk_15 
spi_csht_half_sclk_16 

◆ spi_data_phase_format_t

#include <drivers/inc/hpm_spi_drv.h>

spi data phase format

Enumerator
spi_single_io_mode 
spi_dual_io_mode 
spi_quad_io_mode 

◆ spi_directio_pin_t

#include <drivers/inc/hpm_spi_drv.h>

Enumerator
hold_pin 
wp_pin 
miso_pin 
mosi_pin 
sclk_pin 
cs_pin 

◆ spi_dma_enable_t

#include <drivers/inc/hpm_spi_drv.h>

spi dma enable

Enumerator
spi_tx_dma_enable 
spi_rx_dma_enable 

◆ spi_dummy_count_t

#include <drivers/inc/hpm_spi_drv.h>

spi dummy count

Enumerator
spi_dummy_count_1 
spi_dummy_count_2 
spi_dummy_count_3 
spi_dummy_count_4 

◆ spi_interrupt_t

#include <drivers/inc/hpm_spi_drv.h>

spi interrupt mask

Enumerator
spi_rx_fifo_overflow_int 
spi_tx_fifo_underflow_int 
spi_rx_fifo_threshold_int 
spi_tx_fifo_threshold_int 
spi_end_int 
spi_slave_cmd_int 

◆ spi_mode_selection_t

#include <drivers/inc/hpm_spi_drv.h>

spi mode selection

Enumerator
spi_master_mode 
spi_slave_mode 

◆ spi_sclk_idle_state_t

#include <drivers/inc/hpm_spi_drv.h>

spi clock polarity

Enumerator
spi_sclk_low_idle 
spi_sclk_high_idle 

◆ spi_sclk_sampling_clk_edges_t

#include <drivers/inc/hpm_spi_drv.h>

spi clock phase

Enumerator
spi_sclk_sampling_odd_clk_edges 
spi_sclk_sampling_even_clk_edges 

◆ spi_shift_direction_t

#include <drivers/inc/hpm_spi_drv.h>

Enumerator
msb_first 
lsb_first 

◆ spi_token_value_t

#include <drivers/inc/hpm_spi_drv.h>

spi token value

Enumerator
spi_token_value_0x00 
spi_token_value_0x69 

◆ spi_trans_mode_t

#include <drivers/inc/hpm_spi_drv.h>

spi transfer mode

Enumerator
spi_trans_write_read_together 
spi_trans_write_only 
spi_trans_read_only 
spi_trans_write_read 
spi_trans_read_write 
spi_trans_write_dummy_read 
spi_trans_read_dummy_write 
spi_trans_no_data 
spi_trans_dummy_write 
spi_trans_dummy_read 

Function Documentation

◆ spi_clear_interrupt_status()

static void spi_clear_interrupt_status ( SPI_Type ptr,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Clear the SPI interrupt status.

This function clears interrupt status of the SPI.

Parameters
ptrSPI base address.
maskThe interrupt mask; Use the spi_interrupt_t.

◆ spi_control_init()

hpm_stat_t spi_control_init ( SPI_Type ptr,
spi_control_config_t config,
uint32_t  wcount,
uint32_t  rcount 
)

#include <drivers/inc/hpm_spi_drv.h>

spi control initialization

Parameters
[in]ptrSPI base address
[in]configpoint to spi_control_config_t
[in]wcountspi sent data count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
[in]rcountspi receive count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
Return values
hpm_stat_tstatus_success if spi transfer without any error

◆ spi_directio_disable_output()

hpm_stat_t spi_directio_disable_output ( SPI_Type ptr,
spi_directio_pin_t  pin 
)

#include <drivers/inc/hpm_spi_drv.h>

disable specific pin output for spi directio

Parameters
[in]ptrSPI base address
[in]pinspi_directio_pin_t enum

◆ spi_directio_enable_output()

hpm_stat_t spi_directio_enable_output ( SPI_Type ptr,
spi_directio_pin_t  pin 
)

#include <drivers/inc/hpm_spi_drv.h>

enable specific pin output for spi directio

Note
must be used spi_enable_directio API before enable output function
Parameters
[in]ptrSPI base address
[in]pinspi_directio_pin_t enum

◆ spi_directio_read()

uint8_t spi_directio_read ( SPI_Type ptr,
spi_directio_pin_t  pin 
)

#include <drivers/inc/hpm_spi_drv.h>

Read specified pin level for spi directio.

Parameters
[in]ptrSPI base address
pinspi_directio_pin_t enum
Returns
Pin status

◆ spi_directio_write()

hpm_stat_t spi_directio_write ( SPI_Type ptr,
spi_directio_pin_t  pin,
bool  high 
)

#include <drivers/inc/hpm_spi_drv.h>

write specified pin level for spi directio

Parameters
[in]ptrSPI base address
[in]pinspi_directio_pin_t enum
[in]highPin level set to high when it is set to true

◆ spi_disable_data_merge()

static void spi_disable_data_merge ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Disable SPI data merge.

Parameters
[in]ptrSPI base address

◆ spi_disable_directio()

static void spi_disable_directio ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Disable SPI directIO control function.

Parameters
[in]ptrSPI base address

◆ spi_disable_dma()

static void spi_disable_dma ( SPI_Type ptr,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Disables the SPI DMA request.

This function configures the Rx and Tx DMA mask of the SPI. The parameters are base and a DMA mask.

Parameters
ptrSPI base address.
maskThe dma enable mask; Use the spi_dma_enable_t.

◆ spi_disable_interrupt()

static void spi_disable_interrupt ( SPI_Type ptr,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Disables the SPI interrupt.

This function configures interrupt of the SPI. The parameters are base and a interrupt mask.

Parameters
ptrSPI base address.
maskThe interrupt mask; Use the spi_interrupt_t.

◆ spi_disable_rx_dma()

static void spi_disable_rx_dma ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI disable rx dma.

Parameters
ptrSPI base address

◆ spi_disable_tx_dma()

static void spi_disable_tx_dma ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI disable tx dma.

Parameters
ptrSPI base address

◆ spi_enable_data_merge()

static void spi_enable_data_merge ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Enable SPI data merge.

Parameters
[in]ptrSPI base address

◆ spi_enable_directio()

static void spi_enable_directio ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Enable SPI directIO control function.

Note
if SPI transmission is required, the function must be disable
Parameters
[in]ptrSPI base address

◆ spi_enable_dma()

static void spi_enable_dma ( SPI_Type ptr,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Enables the SPI DMA request.

This function configures the Rx and Tx DMA mask of the SPI. The parameters are base and a DMA mask.

Parameters
ptrSPI base address.
maskThe dma enable mask; Use the spi_dma_enable_t.

◆ spi_enable_interrupt()

static void spi_enable_interrupt ( SPI_Type ptr,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Enables the SPI interrupt.

This function configures interrupt of the SPI. The parameters are base and a interrupt mask.

Parameters
ptrSPI base address.
maskThe interrupt mask; Use the spi_interrupt_t.

◆ spi_enable_rx_dma()

static void spi_enable_rx_dma ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI enable rx dma.

Parameters
ptrSPI base address

◆ spi_enable_tx_dma()

static void spi_enable_tx_dma ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI enable tx dma.

Parameters
ptrSPI base address

◆ spi_format_init()

void spi_format_init ( SPI_Type ptr,
spi_format_config_t config 
)

#include <drivers/inc/hpm_spi_drv.h>

spi format initialization

Parameters
[in]ptrSPI base address
[in]configspi_format_config_t

◆ spi_get_clock_phase()

static spi_sclk_sampling_clk_edges_t spi_get_clock_phase ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

get spi clock phase

Parameters
[in]ptrSPI base address
Return values
spi_sclk_sampling_clk_edges_tspi_sclk_sampling_odd_clk_edges if CPHA is 0

◆ spi_get_clock_polarity()

static spi_sclk_idle_state_t spi_get_clock_polarity ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

get spi clock phase

Parameters
[in]ptrSPI base address
Return values
spi_sclk_idle_state_tspi_sclk_low_idle if CPOL is 0

◆ spi_get_data_length_in_bits()

static uint8_t spi_get_data_length_in_bits ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Get the SPI data length in bits.

Parameters
ptrSPI base address.
Return values
SPIdata length in bits

◆ spi_get_data_length_in_bytes()

static uint8_t spi_get_data_length_in_bytes ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Get the SPI data length in bytes.

Parameters
ptrSPI base address.
Return values
SPIdata length in bytes

◆ spi_get_directio_enable_status()

static uint8_t spi_get_directio_enable_status ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

get whether spi directio function is enabled

Parameters
[in]ptrSPI base address
Returns
if pi directio function is enable, it will return 1

◆ spi_get_interrupt_status()

static uint32_t spi_get_interrupt_status ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Get the SPI interrupt status.

This function gets interrupt status of the SPI.

Parameters
ptrSPI base address.
Return values
SPIinterrupt status register value

◆ spi_get_rx_fifo_size()

static uint8_t spi_get_rx_fifo_size ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Get SPI RXFIFO size.

Parameters
[in]ptrSPI base address
Returns
RXFIFO size, the unit is word

◆ spi_get_rx_fifo_valid_data_size()

static uint8_t spi_get_rx_fifo_valid_data_size ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Get valid data size in receive FIFO.

Parameters
[in]ptrSPI base address
Returns
rx fifo valid data size

◆ spi_get_shift_direction()

static spi_shift_direction_t spi_get_shift_direction ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

get spi shift direction

Parameters
[in]ptrSPI base address
Return values
spi_shift_direction_tmsb_first if frist MSB

◆ spi_get_tx_fifo_size()

static uint8_t spi_get_tx_fifo_size ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Get SPI TXFIFO size.

Parameters
[in]ptrSPI base address
Returns
TXFIFO size, the unit is word

◆ spi_get_tx_fifo_valid_data_size()

static uint8_t spi_get_tx_fifo_valid_data_size ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

Get valid data size in transmit FIFO.

Parameters
[in]ptrSPI base address
Returns
tx fifo valid data size

◆ spi_is_active()

static bool spi_is_active ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI get active status.

Parameters
ptrSPI base address.
Return values
booltrue for active, false for inactive

◆ spi_master_disable_address_phase()

static void spi_master_disable_address_phase ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master disable address phase.

Parameters
[in]ptrSPI base address

◆ spi_master_disable_command_phase()

static void spi_master_disable_command_phase ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master disable command phase.

Parameters
[in]ptrSPI base address

◆ spi_master_disable_token_transfer()

static void spi_master_disable_token_transfer ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master disable token transfer.

Parameters
[in]ptrSPI base address

◆ spi_master_enable_address_phase()

static void spi_master_enable_address_phase ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master enable address phase.

Parameters
[in]ptrSPI base address

◆ spi_master_enable_command_phase()

static void spi_master_enable_command_phase ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master enable command phase.

Parameters
[in]ptrSPI base address

◆ spi_master_enable_token_transfer()

static void spi_master_enable_token_transfer ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master enable token transfer.

Parameters
[in]ptrSPI base address

◆ spi_master_get_cs2sclk_timing()

static spi_cs2sclk_duration_t spi_master_get_cs2sclk_timing ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master get the minimum time between the edges of SPI CS and the edges of SCLK.

Parameters
[in]ptrSPI base address
Return values
spi_cs2sclk_duration_tenum

◆ spi_master_get_csht_timing()

static spi_csht_duration_t spi_master_get_csht_timing ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master get the minimum time that SPI CS should stay HIGH.

Parameters
[in]ptrSPI base address
Return values
spi_csht_duration_tenum

◆ spi_master_get_data_phase_format()

static spi_data_phase_format_t spi_master_get_data_phase_format ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master get data phase format.

Parameters
[in]ptrSPI base address
Return values
returnthe data phase format

◆ spi_master_get_default_control_config()

void spi_master_get_default_control_config ( spi_control_config_t config)

#include <drivers/inc/hpm_spi_drv.h>

spi master get default control config

Parameters
[out]configspi_control_config_t

◆ spi_master_get_default_format_config()

void spi_master_get_default_format_config ( spi_format_config_t config)

#include <drivers/inc/hpm_spi_drv.h>

spi master get default format config

Parameters
[out]configspi_format_config_t

◆ spi_master_get_default_timing_config()

void spi_master_get_default_timing_config ( spi_timing_config_t config)

#include <drivers/inc/hpm_spi_drv.h>

spi master get default timing config

Parameters
[out]configspi_timing_config_t

◆ spi_master_get_sclk_div()

static uint8_t spi_master_get_sclk_div ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master get the clock frequency ratio between the clock source and SPI SCLK.

Parameters
[in]ptrSPI base address
Return values
returnthe frequency ratio value

◆ spi_master_set_address_phase_format()

static void spi_master_set_address_phase_format ( SPI_Type ptr,
spi_addr_phase_format_t  format 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set address phase format.

Parameters
[in]ptrSPI base address
[in]formatspi_addr_phase_format_t enum

◆ spi_master_set_cs2sclk_timing()

static void spi_master_set_cs2sclk_timing ( SPI_Type ptr,
spi_cs2sclk_duration_t  duration 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set the minimum time between the edges of SPI CS and the edges of SCLK.

Parameters
[in]ptrSPI base address
[in]durationspi_cs2sclk_duration_t enum

◆ spi_master_set_csht_timing()

static void spi_master_set_csht_timing ( SPI_Type ptr,
spi_csht_duration_t  duration 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set the minimum time that SPI CS should stay HIGH.

Parameters
[in]ptrSPI base address
[in]durationspi_csht_duration_t enum

◆ spi_master_set_data_phase_format()

static void spi_master_set_data_phase_format ( SPI_Type ptr,
spi_data_phase_format_t  format 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set data phase format.

Parameters
[in]ptrSPI base address
[in]formatspi_data_phase_format_t enum

◆ spi_master_set_sclk_div()

static void spi_master_set_sclk_div ( SPI_Type ptr,
uint8_t  div 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set the clock frequency ratio between the clock source and SPI SCLK.

Parameters
[in]ptrSPI base address
[in]divthe frequency ratio value

◆ spi_master_set_token_value()

static void spi_master_set_token_value ( SPI_Type ptr,
spi_token_value_t  value 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set the value of the one-byte special token following the address phase for SPI read transfers.

Parameters
[in]ptrSPI base address
[in]valuespi_token_value_t enum

◆ spi_master_timing_init()

hpm_stat_t spi_master_timing_init ( SPI_Type ptr,
spi_timing_config_t config 
)

#include <drivers/inc/hpm_spi_drv.h>

spi master timing initialization

Parameters
[in]ptrSPI base address
[in]configspi_timing_config_t
Return values
hpm_stat_tstatus_invalid_argument or status_success

◆ spi_read_command()

hpm_stat_t spi_read_command ( SPI_Type ptr,
spi_mode_selection_t  mode,
spi_control_config_t config,
uint8_t *  cmd 
)

#include <drivers/inc/hpm_spi_drv.h>

spi read command

On slave mode, the command field of the last received SPI transaction is stored in this SPI Command Register

Parameters
[in]ptrSPI base address
[in]modespi mode, use the spi_mode_selection_t
[in]configpoint to spi_control_config_t
[out]cmdcommand data address
Return values
hpm_stat_tstatus_success if spi transfer without any error

◆ spi_read_data()

hpm_stat_t spi_read_data ( SPI_Type ptr,
uint8_t  data_len_in_bytes,
uint8_t *  buff,
uint32_t  count 
)

#include <drivers/inc/hpm_spi_drv.h>

spi read data

Note
Call this function after SPI CONTROL is configured by spi_control_init.
Parameters
[in]ptrSPI base address
[in]data_len_in_bytesdata length in bytes
[out]buffspi receive data buff address
[in]countspi receive data count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
Return values
hpm_stat_tstatus_success if spi transfer without any error

◆ spi_receive_fifo_reset()

static void spi_receive_fifo_reset ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI receive fifo reset.

Parameters
ptrSPI base address

◆ spi_reset()

static void spi_reset ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI reset.

Parameters
ptrSPI base address

◆ spi_set_address_len()

static void spi_set_address_len ( SPI_Type ptr,
spi_address_len_t  addrlen 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

set spi the length of address

Parameters
[in]ptrSPI base address
[in]addrlenaddress lenth enum

◆ spi_set_clock_phase()

static void spi_set_clock_phase ( SPI_Type ptr,
spi_sclk_sampling_clk_edges_t  clock_phase 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

set spi clock phase

Parameters
[in]ptrSPI base address
[in]clock_phaseclock phase enum

◆ spi_set_clock_polarity()

static void spi_set_clock_polarity ( SPI_Type ptr,
spi_sclk_idle_state_t  clock_polarity 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

set spi clock polarity

Parameters
[in]ptrSPI base address
[in]clock_polarityclock polarity enum

◆ spi_set_data_bits()

static hpm_stat_t spi_set_data_bits ( SPI_Type ptr,
uint8_t  nbits 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

set spi the length of each data unit in bits

Parameters
[in]ptrSPI base address
[in]nbitsthe actual bits number of a data
Return values
hpm_stat_tstatus_success if spi transfer without any error

◆ spi_set_dummy_count()

static void spi_set_dummy_count ( SPI_Type ptr,
spi_dummy_count_t  count 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set dummy data count.

Parameters
[in]ptrSPI base address
[in]countspi_dummy_count_t enum

◆ spi_set_read_data_count()

static void spi_set_read_data_count ( SPI_Type ptr,
uint32_t  count 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set transfer count for read data.

Parameters
[in]ptrSPI base address
[in]countthe number of units of data to be received from SPI bus and stored to the Data

◆ spi_set_rx_fifo_threshold()

static void spi_set_rx_fifo_threshold ( SPI_Type ptr,
uint32_t  threshold 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI set RX FIFO threshold.

This function configures SPI RX FIFO threshold.

Parameters
ptrSPI base address.
thresholdThe FIFO threshold value, the value should not greater than FIFO size.

◆ spi_set_shift_direction()

static void spi_set_shift_direction ( SPI_Type ptr,
spi_shift_direction_t  shift_direction 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

set spi shift direction

Parameters
[in]ptrSPI base address
[in]shift_directionshift direction enum

◆ spi_set_transfer_mode()

static void spi_set_transfer_mode ( SPI_Type ptr,
spi_trans_mode_t  mode 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set transfer mode.

Parameters
[in]ptrSPI base address
[in]modespi_trans_mode_t enum

◆ spi_set_tx_fifo_threshold()

static void spi_set_tx_fifo_threshold ( SPI_Type ptr,
uint32_t  threshold 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI set TX FIFO threshold.

This function configures SPI TX FIFO threshold.

Parameters
ptrSPI base address.
thresholdThe FIFO threshold value, the value should not greater than FIFO size.

◆ spi_set_write_data_count()

static void spi_set_write_data_count ( SPI_Type ptr,
uint32_t  count 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI master set transfer count for write data.

Parameters
[in]ptrSPI base address
[in]countthe number of units of data to be transmitted to the SPI bus from the Data

◆ spi_setup_dma_transfer()

hpm_stat_t spi_setup_dma_transfer ( SPI_Type ptr,
spi_control_config_t config,
uint8_t *  cmd,
uint32_t *  addr,
uint32_t  wcount,
uint32_t  rcount 
)

#include <drivers/inc/hpm_spi_drv.h>

spi setup dma transfer

Parameters
[in]ptrSPI base address
[in]configspi_control_config_t
[in]cmdspi transfer command address
[in]addrspi transfer target address
[in]wcountspi sent data count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
[in]rcountspi receive data count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
Return values
hpm_stat_tstatus_success if spi setup dma transfer without any error

◆ spi_slave_disable_data_only()

static void spi_slave_disable_data_only ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI slave disable only date mode.

Parameters
[in]ptrSPI base address

◆ spi_slave_enable_data_only()

static void spi_slave_enable_data_only ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI slave enable only date mode.

Note
This mode only works in the uni-directional regular (single) mode
Parameters
[in]ptrSPI base address

◆ spi_slave_get_default_control_config()

void spi_slave_get_default_control_config ( spi_control_config_t config)

#include <drivers/inc/hpm_spi_drv.h>

spi slave get default control config

Parameters
[out]configspi_control_config_t

◆ spi_slave_get_default_format_config()

void spi_slave_get_default_format_config ( spi_format_config_t config)

#include <drivers/inc/hpm_spi_drv.h>

spi slave get default format config

Parameters
[out]configspi_format_config_t

◆ spi_slave_get_received_data_count()

static uint32_t spi_slave_get_received_data_count ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI slave get received data count.

Parameters
ptrSPI base address
Return values
uint32_tdata count

◆ spi_slave_get_sent_data_count()

static uint32_t spi_slave_get_sent_data_count ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI slave get sent data count.

Parameters
ptrSPI base address
Return values
uint32_tdata count

◆ spi_slave_set_user_status()

static void spi_slave_set_user_status ( SPI_Type ptr,
uint16_t  user_status 
)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI slave set the user defined status flags.

Note
in Non-SlvDataOnly, the command is read status command, such as 0x05\0x15\0x25 command
Parameters
[in]ptrSPI base address
[in]user_statususer status value

◆ spi_transfer()

hpm_stat_t spi_transfer ( SPI_Type ptr,
spi_control_config_t config,
uint8_t *  cmd,
uint32_t *  addr,
uint8_t *  wbuff,
uint32_t  wcount,
uint8_t *  rbuff,
uint32_t  rcount 
)

#include <drivers/inc/hpm_spi_drv.h>

spi transfer

Parameters
[in]ptrSPI base address
[in]configspi_control_config_t
[in,out]cmdspi transfer command address
[in]addrspi transfer target address
[in]wbuffspi sent data buff address
[in]wcountspi sent data count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
[out]rbuffspi receive data buff address
[in]rcountspi receive data count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
Return values
hpm_stat_tstatus_success if spi transfer without any error

◆ spi_transmit_fifo_reset()

static void spi_transmit_fifo_reset ( SPI_Type ptr)
inlinestatic

#include <drivers/inc/hpm_spi_drv.h>

SPI transmit fifo reset.

Parameters
ptrSPI base address

◆ spi_wait_for_busy_status()

hpm_stat_t spi_wait_for_busy_status ( SPI_Type ptr)

#include <drivers/inc/hpm_spi_drv.h>

spi wait for busy status

Note
on slave mode, if CS signal is asserted, take it as busy; if SPI CS signal is de-asserted, take it as idle.
Parameters
[in]ptrSPI base address
Return values
hpm_stat_tstatus_success if spi in busy status

◆ spi_wait_for_idle_status()

hpm_stat_t spi_wait_for_idle_status ( SPI_Type ptr)

#include <drivers/inc/hpm_spi_drv.h>

spi wait for idle status

Note
on slave mode, if CS signal is asserted, take it as busy; if SPI CS signal is de-asserted, take it as idle.
Parameters
[in]ptrSPI base address
Return values
hpm_stat_tstatus_success if spi in idle status

◆ spi_write_address()

hpm_stat_t spi_write_address ( SPI_Type ptr,
spi_mode_selection_t  mode,
spi_control_config_t config,
uint32_t *  addr 
)

#include <drivers/inc/hpm_spi_drv.h>

spi write address

Note
Call this function on master mode.
Parameters
[in]ptrSPI base address
[in]modespi mode, use the spi_mode_selection_t
[in]configpoint to spi_control_config_t
[in]addrpoint to address
Return values
hpm_stat_tstatus_success if spi transfer without any error

◆ spi_write_command()

hpm_stat_t spi_write_command ( SPI_Type ptr,
spi_mode_selection_t  mode,
spi_control_config_t config,
uint8_t *  cmd 
)

#include <drivers/inc/hpm_spi_drv.h>

spi write command

Writing operations on this register will trigger SPI transfers, call this function on master mode.

Parameters
[in]ptrSPI base address
[in]modespi mode, use the spi_mode_selection_t
[in]configpoint to spi_control_config_t
[in]cmdcommand data address
Return values
hpm_stat_tstatus_success if spi transfer without any error

◆ spi_write_data()

hpm_stat_t spi_write_data ( SPI_Type ptr,
uint8_t  data_len_in_bytes,
uint8_t *  buff,
uint32_t  count 
)

#include <drivers/inc/hpm_spi_drv.h>

spi write data

Note
Call this function after SPI CONTROL is configured by spi_control_init.
Parameters
[in]ptrSPI base address
[in]data_len_in_bytesdata length in bytes
[in]buffspi sent data buff address
[in]countspi sent data count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
Return values
hpm_stat_tstatus_success if spi transfer without any error

◆ spi_write_read_data()

hpm_stat_t spi_write_read_data ( SPI_Type ptr,
uint8_t  data_len_in_bytes,
uint8_t *  wbuff,
uint32_t  wcount,
uint8_t *  rbuff,
uint32_t  rcount 
)

#include <drivers/inc/hpm_spi_drv.h>

spi write and read data

Note
Call this function after SPI CONTROL is configured by spi_control_init. The order of reading and writing is controlled by spi_control_init.
Parameters
[in]ptrSPI base address
[in]data_len_in_bytesdata length in bytes
[in]wbuffspi sent data buff address
[in]wcountspi sent data count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
[out]rbuffspi receive data buff address
[in]rcountspi receive data count, not greater than SPI_SOC_TRANSFER_COUNT_MAX
Return values
hpm_stat_tstatus_success if spi transfer without any error