![]() |
S32 SDK
|
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "status.h"
#include "device_registers.h"
Go to the source code of this file.
Data Structures | |
struct | lpspi_tx_cmd_config_t |
LPSPI Transmit Command Register configuration structure. More... | |
struct | lpspi_init_config_t |
LPSPI initialization configuration structure. More... | |
Enumerations | |
enum | lpspi_prescaler_t { LPSPI_DIV_1 = 0U, LPSPI_DIV_2 = 1U, LPSPI_DIV_4 = 2U, LPSPI_DIV_8 = 3U, LPSPI_DIV_16 = 4U, LPSPI_DIV_32 = 5U, LPSPI_DIV_64 = 6U, LPSPI_DIV_128 = 7U } |
Prescaler values for LPSPI clock source. Implements : lpspi_prescaler_t_Class. More... | |
enum | lpspi_status_flag_t { LPSPI_TX_DATA_FLAG = LPSPI_SR_TDF_SHIFT, LPSPI_RX_DATA_FLAG = LPSPI_SR_RDF_SHIFT, LPSPI_WORD_COMPLETE = LPSPI_SR_WCF_SHIFT, LPSPI_FRAME_COMPLETE = LPSPI_SR_FCF_SHIFT, LPSPI_TRANSFER_COMPLETE = LPSPI_SR_TCF_SHIFT, LPSPI_TRANSMIT_ERROR = LPSPI_SR_TEF_SHIFT, LPSPI_RECEIVE_ERROR = LPSPI_SR_REF_SHIFT, LPSPI_DATA_MATCH = LPSPI_SR_DMF_SHIFT, LPSPI_MODULE_BUSY = LPSPI_SR_MBF_SHIFT, LPSPI_ALL_STATUS = 0x00003F00U } |
LPSPI status flags. Implements : lpspi_status_flag_t_Class. More... | |
enum | lpspi_sck_polarity_t { LPSPI_SCK_ACTIVE_HIGH = 0U, LPSPI_SCK_ACTIVE_LOW = 1U } |
LPSPI Clock Signal (SCK) Polarity configuration. Implements : lpspi_sck_polarity_t_Class. More... | |
enum | lpspi_signal_polarity_t { LPSPI_ACTIVE_HIGH = 1U, LPSPI_ACTIVE_LOW = 0U } |
LPSPI Signal (PCS and Host Request) Polarity configuration. Implements : lpspi_signal_polarity_t_Class. More... | |
enum | lpspi_host_request_select_t { LPSPI_HOST_REQ_EXT_PIN = 0U, LPSPI_HOST_REQ_INTERNAL_TRIGGER = 1U } |
LPSPI Host Request select configuration. Implements : lpspi_host_request_select_t_Class. More... | |
enum | lpspi_master_slave_mode_t { LPSPI_MASTER = 1U, LPSPI_SLAVE = 0U } |
LPSPI master or slave configuration. Implements : lpspi_master_slave_mode_t_Class. More... | |
enum | lpspi_which_pcs_t { LPSPI_PCS0 = 0U, LPSPI_PCS1 = 1U, LPSPI_PCS2 = 2U, LPSPI_PCS3 = 3U } |
LPSPI Peripheral Chip Select (PCS) configuration (which PCS to configure). Implements : lpspi_which_pcs_t_Class. More... | |
enum | lpspi_match_config_t { LPSPI_MATCH_DISABLED = 0x0U, LPSPI_1ST_WRD_EQUALS_M0_OR_M1 = 0x2U, LPSPI_ANY_WRD_EQUALS_M0_OR_M1 = 0x3U, LPSPI_1ST_WRD_EQUALS_M0_AND_2ND_WRD_EQUALS_M1 = 0x4U, LPSPI_ANY_WRD_EQUALS_M0_AND_NXT_WRD_EQUALS_M1 = 0x5U, LPSPI_1ST_WRD_AND_M1_EQUALS_M0_AND_M1 = 0x6U, LPSPI_ANY_WRD_AND_M1_EQUALS_M0_AND_M1 = 0x7U } |
LPSPI Match configuration options. Implements : lpspi_match_config_t_Class. More... | |
enum | lpspi_pin_config_t { LPSPI_SDI_IN_SDO_OUT = 0U, LPSPI_SDI_IN_OUT = 1U, LPSPI_SDO_IN_OUT = 2U, LPSPI_SDI_OUT_SDO_IN = 3U } |
LPSPI pin (SDO and SDI) configuration. Implements : lpspi_pin_config_t_Class. More... | |
enum | lpspi_clock_phase_t { LPSPI_CLOCK_PHASE_1ST_EDGE = 0U, LPSPI_CLOCK_PHASE_2ND_EDGE = 1U } |
LPSPI clock phase configuration. Implements : lpspi_clock_phase_t_Class. More... | |
enum | lpspi_data_out_config_t { LPSPI_DATA_OUT_RETAINED = 0U, LPSPI_DATA_OUT_TRISTATE = 1U } |
LPSPI data output configuration. Implements : lpspi_data_out_config_t_Class. More... | |
enum | lpspi_transfer_width_t { LPSPI_SINGLE_BIT_XFER = 0U, LPSPI_TWO_BIT_XFER = 1U, LPSPI_FOUR_BIT_XFER = 2U } |
LPSPI transfer width configuration. Implements : lpspi_transfer_width_t_Class. More... | |
enum | lpspi_delay_type_t { LPSPI_SCK_TO_PCS = LPSPI_CCR_SCKPCS_SHIFT, LPSPI_PCS_TO_SCK = LPSPI_CCR_PCSSCK_SHIFT, LPSPI_BETWEEN_TRANSFER = LPSPI_CCR_DBT_SHIFT } |
LPSPI delay type selection Implements : lpspi_delay_type_t_Class. More... | |
Functions | |
Configuration | |
void | LPSPI_HAL_Init (LPSPI_Type *base) |
Resets the LPSPI internal logic and registers to their default settings. More... | |
status_t | LPSPI_HAL_Config (LPSPI_Type *base, const lpspi_init_config_t *config, lpspi_tx_cmd_config_t *txCmdCfgSet, uint32_t *actualBaudRate) |
Configures the LPSPI registers to a user defined configuration. More... | |
void | LPSPI_HAL_GetVersionId (const LPSPI_Type *base, uint32_t *major, uint32_t *minor, uint32_t *feature) |
Gets the Major, Minor and Feature ID of the LPSPI module. More... | |
static void | LPSPI_HAL_Enable (LPSPI_Type *base) |
Enables the LPSPI module. More... | |
static bool | LPSPI_HAL_IsModuleEnabled (const LPSPI_Type *base) |
Check if LPSPI module is enabled. More... | |
status_t | LPSPI_HAL_Disable (LPSPI_Type *base) |
Disables the LPSPI module. More... | |
status_t | LPSPI_HAL_SetMasterSlaveMode (LPSPI_Type *base, lpspi_master_slave_mode_t mode) |
Configures the LPSPI for master or slave. More... | |
static bool | LPSPI_HAL_IsMaster (const LPSPI_Type *base) |
Returns whether the LPSPI module is in master mode. More... | |
void | LPSPI_HAL_GetFifoSizes (const LPSPI_Type *base, uint8_t *txFifoSize, uint8_t *rxFifoSize) |
Gets the TX and RX FIFO sizes of the LPSPI module. More... | |
void | LPSPI_HAL_SetFlushFifoCmd (LPSPI_Type *base, bool flushTxFifo, bool flushRxFifo) |
Flushes the LPSPI FIFOs. More... | |
static void | LPSPI_HAL_SetRxWatermarks (LPSPI_Type *base, uint32_t rxWater) |
Sets the RX FIFO watermark values. More... | |
static void | LPSPI_HAL_SetTxWatermarks (LPSPI_Type *base, uint32_t txWater) |
Sets the TX FIFO watermark values. More... | |
Status flags and Interrupt configuration | |
static bool | LPSPI_HAL_GetStatusFlag (const LPSPI_Type *base, lpspi_status_flag_t statusFlag) |
Gets the LPSPI status flag state. More... | |
status_t | LPSPI_HAL_ClearStatusFlag (LPSPI_Type *base, lpspi_status_flag_t statusFlag) |
Clears the LPSPI status flag. More... | |
static void | LPSPI_HAL_SetIntMode (LPSPI_Type *base, lpspi_status_flag_t interruptSrc, bool enable) |
Configures the LPSPI interrupts. More... | |
static bool | LPSPI_HAL_GetIntMode (const LPSPI_Type *base, lpspi_status_flag_t interruptSrc) |
Returns if the LPSPI interrupt request is enabled or disabled. More... | |
DMA configuration | |
static void | LPSPI_HAL_SetTxDmaCmd (LPSPI_Type *base, bool enable) |
Sets the LPSPI Transmit Data DMA configuration (enable or disable). More... | |
static void | LPSPI_HAL_SetRxDmaCmd (LPSPI_Type *base, bool enable) |
Sets the LPSPI Receive Data DMA configuration (enable or disable). More... | |
SPI Bus Configuration | |
void | LPSPI_HAL_SetHostRequestMode (LPSPI_Type *base, lpspi_host_request_select_t hostReqInput, lpspi_signal_polarity_t hostReqPol, bool enable) |
Configures the LPSPI Host Request input. More... | |
status_t | LPSPI_HAL_SetPcsPolarityMode (LPSPI_Type *base, lpspi_which_pcs_t whichPcs, lpspi_signal_polarity_t pcsPolarity) |
Configures the desired LPSPI PCS polarity. More... | |
status_t | LPSPI_HAL_SetMatchConfigMode (LPSPI_Type *base, lpspi_match_config_t matchCondition, bool rxDataMatchOnly, uint32_t match0, uint32_t match1) |
Configures the LPSPI data match configuration mode. More... | |
status_t | LPSPI_HAL_SetPinConfigMode (LPSPI_Type *base, lpspi_pin_config_t pinCfg, lpspi_data_out_config_t dataOutConfig, bool pcs3and2Enable) |
Configures the LPSPI SDO/SDI pin configuration mode. More... | |
uint32_t | LPSPI_HAL_SetBaudRate (LPSPI_Type *base, uint32_t bitsPerSec, uint32_t sourceClockInHz, uint32_t *tcrPrescaleValue) |
Sets the LPSPI baud rate in bits per second. More... | |
status_t | LPSPI_HAL_SetBaudRateDivisor (LPSPI_Type *base, uint32_t divisor) |
Configures the baud rate divisor manually (only the LPSPI_CCR[SCKDIV]). More... | |
status_t | LPSPI_HAL_SetDelay (LPSPI_Type *base, lpspi_delay_type_t whichDelay, uint32_t delay) |
Manually configures a specific LPSPI delay parameter (module must be disabled to change the delay values). More... | |
Data transfer | |
void | LPSPI_HAL_SetTxCommandReg (LPSPI_Type *base, const lpspi_tx_cmd_config_t *txCmdCfgSet) |
Sets the Transmit Command Register (TCR) parameters. More... | |
static void | LPSPI_HAL_WriteData (LPSPI_Type *base, uint32_t data) |
Writes data into the TX data buffer. More... | |
void | LPSPI_HAL_WriteDataBlocking (LPSPI_Type *base, uint32_t data) |
Writes a data into the TX data buffer and waits till complete to return. More... | |
static uint32_t | LPSPI_HAL_ReadData (const LPSPI_Type *base) |
Reads data from the data buffer. More... | |
uint32_t | LPSPI_HAL_ReadDataBlocking (const LPSPI_Type *base) |
Reads data from the data buffer but first waits till data is ready. More... | |
static uint32_t | LPSPI_HAL_ReadTxCount (const LPSPI_Type *base) |
Reads TX COUNT form the FIFO Status Register. More... | |
static uint32_t | LPSPI_HAL_ReadRxCount (const LPSPI_Type *base) |
Reads RX COUNT form the FIFO Status Register. More... | |
static void | LPSPI_HAL_ClearContCBit (LPSPI_Type *base) |
Clear CONTC bit form TCR Register. More... | |
static void | LPSPI_HAL_SetContCBit (LPSPI_Type *base) |
Set CONTC bit form TCR Register. More... | |
static void | LPSPI_HAL_SetClockPrescaler (LPSPI_Type *base, lpspi_prescaler_t prescaler) |
Configures the clock prescaler used for all LPSPI master logic. More... | |
static lpspi_prescaler_t | LPSPI_HAL_GetClockPrescaler (const LPSPI_Type *base) |
Get the clock prescaler used for all LPSPI master logic. More... | |
Variables | |
static const uint32_t | s_baudratePrescaler [] = { 1, 2, 4, 8, 16, 32, 64, 128 } |