rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures
Lpspi_driver

Data Structures

struct  _lpspi_master_config
 LPSPI master configuration structure. More...
 
struct  _lpspi_slave_config
 LPSPI slave configuration structure. More...
 
struct  _lpspi_transfer
 LPSPI master/slave transfer structure. More...
 
struct  _lpspi_master_handle
 LPSPI master transfer handle structure used for transactional API. More...
 
struct  _lpspi_slave_handle
 LPSPI slave transfer handle structure used for transactional API. More...
 

Driver version

enum  _lpspi_status { kStatus_LPSPI_Busy = MAKE_STATUS(kStatusGroup_LPSPI, 0) , kStatus_LPSPI_Error = MAKE_STATUS(kStatusGroup_LPSPI, 1) , kStatus_LPSPI_Idle = MAKE_STATUS(kStatusGroup_LPSPI, 2) , kStatus_LPSPI_OutOfRange = MAKE_STATUS(kStatusGroup_LPSPI, 3) }
 Status for the LPSPI driver. More...
 
enum  _lpspi_flags {
  kLPSPI_TxDataRequestFlag = LPSPI_SR_TDF_MASK , kLPSPI_RxDataReadyFlag = LPSPI_SR_RDF_MASK , kLPSPI_WordCompleteFlag = LPSPI_SR_WCF_MASK , kLPSPI_FrameCompleteFlag = LPSPI_SR_FCF_MASK ,
  kLPSPI_TransferCompleteFlag = LPSPI_SR_TCF_MASK , kLPSPI_TransmitErrorFlag = LPSPI_SR_TEF_MASK , kLPSPI_ReceiveErrorFlag = LPSPI_SR_REF_MASK , kLPSPI_DataMatchFlag = LPSPI_SR_DMF_MASK ,
  kLPSPI_ModuleBusyFlag = LPSPI_SR_MBF_MASK , kLPSPI_AllStatusFlag
}
 LPSPI status flags in SPIx_SR register. More...
 
enum  _lpspi_interrupt_enable {
  kLPSPI_TxInterruptEnable = LPSPI_IER_TDIE_MASK , kLPSPI_RxInterruptEnable = LPSPI_IER_RDIE_MASK , kLPSPI_WordCompleteInterruptEnable = LPSPI_IER_WCIE_MASK , kLPSPI_FrameCompleteInterruptEnable = LPSPI_IER_FCIE_MASK ,
  kLPSPI_TransferCompleteInterruptEnable = LPSPI_IER_TCIE_MASK , kLPSPI_TransmitErrorInterruptEnable = LPSPI_IER_TEIE_MASK , kLPSPI_ReceiveErrorInterruptEnable = LPSPI_IER_REIE_MASK , kLPSPI_DataMatchInterruptEnable = LPSPI_IER_DMIE_MASK ,
  kLPSPI_AllInterruptEnable
}
 LPSPI interrupt source. More...
 
enum  _lpspi_dma_enable { kLPSPI_TxDmaEnable = LPSPI_DER_TDDE_MASK , kLPSPI_RxDmaEnable = LPSPI_DER_RDDE_MASK }
 LPSPI DMA source. More...
 
enum  _lpspi_master_slave_mode { kLPSPI_Master = 1U , kLPSPI_Slave = 0U }
 LPSPI master or slave mode configuration. More...
 
enum  _lpspi_which_pcs_config { kLPSPI_Pcs0 = 0U , kLPSPI_Pcs1 = 1U , kLPSPI_Pcs2 = 2U , kLPSPI_Pcs3 = 3U }
 LPSPI Peripheral Chip Select (PCS) configuration (which PCS to configure). More...
 
enum  _lpspi_pcs_polarity_config { kLPSPI_PcsActiveHigh = 1U , kLPSPI_PcsActiveLow = 0U }
 LPSPI Peripheral Chip Select (PCS) Polarity configuration. More...
 
enum  _lpspi_pcs_polarity {
  kLPSPI_Pcs0ActiveLow = 1U << 0 , kLPSPI_Pcs1ActiveLow = 1U << 1 , kLPSPI_Pcs2ActiveLow = 1U << 2 , kLPSPI_Pcs3ActiveLow = 1U << 3 ,
  kLPSPI_PcsAllActiveLow = 0xFU
}
 LPSPI Peripheral Chip Select (PCS) Polarity. More...
 
enum  _lpspi_clock_polarity { kLPSPI_ClockPolarityActiveHigh = 0U , kLPSPI_ClockPolarityActiveLow = 1U }
 LPSPI clock polarity configuration. More...
 
enum  _lpspi_clock_phase { kLPSPI_ClockPhaseFirstEdge = 0U , kLPSPI_ClockPhaseSecondEdge = 1U }
 LPSPI clock phase configuration. More...
 
enum  _lpspi_shift_direction { kLPSPI_MsbFirst = 0U , kLPSPI_LsbFirst = 1U }
 LPSPI data shifter direction options. More...
 
enum  _lpspi_host_request_select { kLPSPI_HostReqExtPin = 0U , kLPSPI_HostReqInternalTrigger = 1U }
 LPSPI Host Request select configuration. More...
 
enum  _lpspi_match_config {
  kLPSI_MatchDisabled = 0x0U , kLPSI_1stWordEqualsM0orM1 = 0x2U , kLPSI_AnyWordEqualsM0orM1 = 0x3U , kLPSI_1stWordEqualsM0and2ndWordEqualsM1 = 0x4U ,
  kLPSI_AnyWordEqualsM0andNxtWordEqualsM1 = 0x5U , kLPSI_1stWordAndM1EqualsM0andM1 = 0x6U , kLPSI_AnyWordAndM1EqualsM0andM1 = 0x7U
}
 LPSPI Match configuration options. More...
 
enum  _lpspi_pin_config { kLPSPI_SdiInSdoOut = 0U , kLPSPI_SdiInSdiOut = 1U , kLPSPI_SdoInSdoOut = 2U , kLPSPI_SdoInSdiOut = 3U }
 LPSPI pin (SDO and SDI) configuration. More...
 
enum  _lpspi_data_out_config { kLpspiDataOutRetained = 0U , kLpspiDataOutTristate = 1U }
 LPSPI data output configuration. More...
 
enum  _lpspi_transfer_width { kLPSPI_SingleBitXfer = 0U , kLPSPI_TwoBitXfer = 1U , kLPSPI_FourBitXfer = 2U }
 LPSPI transfer width configuration. More...
 
enum  _lpspi_delay_type { kLPSPI_PcsToSck = 1U , kLPSPI_LastSckToPcs , kLPSPI_BetweenTransfer }
 LPSPI delay type selection. More...
 
enum  _lpspi_transfer_config_flag_for_master {
  kLPSPI_MasterPcs0 = 0U << LPSPI_MASTER_PCS_SHIFT , kLPSPI_MasterPcs1 = 1U << LPSPI_MASTER_PCS_SHIFT , kLPSPI_MasterPcs2 = 2U << LPSPI_MASTER_PCS_SHIFT , kLPSPI_MasterPcs3 = 3U << LPSPI_MASTER_PCS_SHIFT ,
  kLPSPI_MasterPcsContinuous = 1U << 20 , kLPSPI_MasterByteSwap
}
 Use this enumeration for LPSPI master transfer configFlags. More...
 
enum  _lpspi_transfer_config_flag_for_slave {
  kLPSPI_SlavePcs0 = 0U << LPSPI_SLAVE_PCS_SHIFT , kLPSPI_SlavePcs1 = 1U << LPSPI_SLAVE_PCS_SHIFT , kLPSPI_SlavePcs2 = 2U << LPSPI_SLAVE_PCS_SHIFT , kLPSPI_SlavePcs3 = 3U << LPSPI_SLAVE_PCS_SHIFT ,
  kLPSPI_SlaveByteSwap
}
 Use this enumeration for LPSPI slave transfer configFlags. More...
 
enum  _lpspi_transfer_state { kLPSPI_Idle = 0x0U , kLPSPI_Busy , kLPSPI_Error }
 LPSPI transfer state, which is used for LPSPI transactional API state machine. More...
 
typedef enum _lpspi_master_slave_mode lpspi_master_slave_mode_t
 LPSPI master or slave mode configuration.
 
typedef enum _lpspi_which_pcs_config lpspi_which_pcs_t
 LPSPI Peripheral Chip Select (PCS) configuration (which PCS to configure).
 
typedef enum _lpspi_pcs_polarity_config lpspi_pcs_polarity_config_t
 LPSPI Peripheral Chip Select (PCS) Polarity configuration.
 
typedef enum _lpspi_clock_polarity lpspi_clock_polarity_t
 LPSPI clock polarity configuration.
 
typedef enum _lpspi_clock_phase lpspi_clock_phase_t
 LPSPI clock phase configuration.
 
typedef enum _lpspi_shift_direction lpspi_shift_direction_t
 LPSPI data shifter direction options.
 
typedef enum _lpspi_host_request_select lpspi_host_request_select_t
 LPSPI Host Request select configuration.
 
typedef enum _lpspi_match_config lpspi_match_config_t
 LPSPI Match configuration options.
 
typedef enum _lpspi_pin_config lpspi_pin_config_t
 LPSPI pin (SDO and SDI) configuration.
 
typedef enum _lpspi_data_out_config lpspi_data_out_config_t
 LPSPI data output configuration.
 
typedef enum _lpspi_transfer_width lpspi_transfer_width_t
 LPSPI transfer width configuration.
 
typedef enum _lpspi_delay_type lpspi_delay_type_t
 LPSPI delay type selection.
 
typedef struct _lpspi_master_config lpspi_master_config_t
 LPSPI master configuration structure.
 
typedef struct _lpspi_slave_config lpspi_slave_config_t
 LPSPI slave configuration structure.
 
typedef struct _lpspi_master_handle lpspi_master_handle_t
 Forward declaration of the _lpspi_master_handle typedefs.
 
typedef struct _lpspi_slave_handle lpspi_slave_handle_t
 Forward declaration of the _lpspi_slave_handle typedefs.
 
typedef void(* lpspi_master_transfer_callback_t) (LPSPI_Type *base, lpspi_master_handle_t *handle, status_t status, void *userData)
 Master completion callback function pointer type.
 
typedef void(* lpspi_slave_transfer_callback_t) (LPSPI_Type *base, lpspi_slave_handle_t *handle, status_t status, void *userData)
 Slave completion callback function pointer type.
 
typedef struct _lpspi_transfer lpspi_transfer_t
 LPSPI master/slave transfer structure.
 
volatile uint8_t g_lpspiDummyData []
 Global variable for dummy data value setting.
 

Initialization and deinitialization

void LPSPI_MasterInit (LPSPI_Type *base, const lpspi_master_config_t *masterConfig, uint32_t srcClock_Hz)
 Initializes the LPSPI master.
 
void LPSPI_MasterGetDefaultConfig (lpspi_master_config_t *masterConfig)
 Sets the lpspi_master_config_t structure to default values.
 
void LPSPI_SlaveInit (LPSPI_Type *base, const lpspi_slave_config_t *slaveConfig)
 LPSPI slave configuration.
 
void LPSPI_SlaveGetDefaultConfig (lpspi_slave_config_t *slaveConfig)
 Sets the lpspi_slave_config_t structure to default values.
 
void LPSPI_Deinit (LPSPI_Type *base)
 De-initializes the LPSPI peripheral. Call this API to disable the LPSPI clock.
 
void LPSPI_Reset (LPSPI_Type *base)
 Restores the LPSPI peripheral to reset state. Note that this function sets all registers to reset state. As a result, the LPSPI module can't work after calling this API.
 
static void LPSPI_Enable (LPSPI_Type *base, bool enable)
 Enables the LPSPI peripheral and sets the MCR MDIS to 0.
 

Status

static uint32_t LPSPI_GetStatusFlags (LPSPI_Type *base)
 Gets the LPSPI status flag state.
 
static uint32_t LPSPI_GetTxFifoSize (LPSPI_Type *base)
 Gets the LPSPI Tx FIFO size.
 
static uint32_t LPSPI_GetRxFifoSize (LPSPI_Type *base)
 Gets the LPSPI Rx FIFO size.
 
static uint32_t LPSPI_GetTxFifoCount (LPSPI_Type *base)
 Gets the LPSPI Tx FIFO count.
 
static uint32_t LPSPI_GetRxFifoCount (LPSPI_Type *base)
 Gets the LPSPI Rx FIFO count.
 
static void LPSPI_ClearStatusFlags (LPSPI_Type *base, uint32_t statusFlags)
 Clears the LPSPI status flag.
 

Interrupts

static void LPSPI_EnableInterrupts (LPSPI_Type *base, uint32_t mask)
 Enables the LPSPI interrupts.
 
static void LPSPI_DisableInterrupts (LPSPI_Type *base, uint32_t mask)
 Disables the LPSPI interrupts.
 

DMA Control

static void LPSPI_EnableDMA (LPSPI_Type *base, uint32_t mask)
 Enables the LPSPI DMA request.
 
static void LPSPI_DisableDMA (LPSPI_Type *base, uint32_t mask)
 Disables the LPSPI DMA request.
 
static uint32_t LPSPI_GetTxRegisterAddress (LPSPI_Type *base)
 Gets the LPSPI Transmit Data Register address for a DMA operation.
 
static uint32_t LPSPI_GetRxRegisterAddress (LPSPI_Type *base)
 Gets the LPSPI Receive Data Register address for a DMA operation.
 

Bus Operations

bool LPSPI_CheckTransferArgument (lpspi_transfer_t *transfer, uint32_t bitsPerFrame, uint32_t bytesPerFrame)
 Check the argument for transfer .
 
static void LPSPI_SetMasterSlaveMode (LPSPI_Type *base, lpspi_master_slave_mode_t mode)
 Configures the LPSPI for either master or slave.
 
static bool LPSPI_IsMaster (LPSPI_Type *base)
 Returns whether the LPSPI module is in master mode.
 
static void LPSPI_FlushFifo (LPSPI_Type *base, bool flushTxFifo, bool flushRxFifo)
 Flushes the LPSPI FIFOs.
 
static void LPSPI_SetFifoWatermarks (LPSPI_Type *base, uint32_t txWater, uint32_t rxWater)
 Sets the transmit and receive FIFO watermark values.
 
static void LPSPI_SetAllPcsPolarity (LPSPI_Type *base, uint32_t mask)
 Configures all LPSPI peripheral chip select polarities simultaneously.
 
static void LPSPI_SetFrameSize (LPSPI_Type *base, uint32_t frameSize)
 Configures the frame size.
 
uint32_t LPSPI_MasterSetBaudRate (LPSPI_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz, uint32_t *tcrPrescaleValue)
 Sets the LPSPI baud rate in bits per second.
 
void LPSPI_MasterSetDelayScaler (LPSPI_Type *base, uint32_t scaler, lpspi_delay_type_t whichDelay)
 Manually configures a specific LPSPI delay parameter (module must be disabled to change the delay values).
 
uint32_t LPSPI_MasterSetDelayTimes (LPSPI_Type *base, uint32_t delayTimeInNanoSec, lpspi_delay_type_t whichDelay, uint32_t srcClock_Hz)
 Calculates the delay based on the desired delay input in nanoseconds (module must be disabled to change the delay values).
 
static void LPSPI_WriteData (LPSPI_Type *base, uint32_t data)
 Writes data into the transmit data buffer.
 
static uint32_t LPSPI_ReadData (LPSPI_Type *base)
 Reads data from the data buffer.
 
void LPSPI_SetDummyData (LPSPI_Type *base, uint8_t dummyData)
 Set up the dummy data.
 

Transactional

void LPSPI_MasterTransferCreateHandle (LPSPI_Type *base, lpspi_master_handle_t *handle, lpspi_master_transfer_callback_t callback, void *userData)
 Initializes the LPSPI master handle.
 
status_t LPSPI_MasterTransferBlocking (LPSPI_Type *base, lpspi_transfer_t *transfer)
 LPSPI master transfer data using a polling method.
 
status_t LPSPI_MasterTransferNonBlocking (LPSPI_Type *base, lpspi_master_handle_t *handle, lpspi_transfer_t *transfer)
 LPSPI master transfer data using an interrupt method.
 
status_t LPSPI_MasterTransferGetCount (LPSPI_Type *base, lpspi_master_handle_t *handle, size_t *count)
 Gets the master transfer remaining bytes.
 
void LPSPI_MasterTransferAbort (LPSPI_Type *base, lpspi_master_handle_t *handle)
 LPSPI master abort transfer which uses an interrupt method.
 
void LPSPI_MasterTransferHandleIRQ (LPSPI_Type *base, lpspi_master_handle_t *handle)
 LPSPI Master IRQ handler function.
 
void LPSPI_SlaveTransferCreateHandle (LPSPI_Type *base, lpspi_slave_handle_t *handle, lpspi_slave_transfer_callback_t callback, void *userData)
 Initializes the LPSPI slave handle.
 
status_t LPSPI_SlaveTransferNonBlocking (LPSPI_Type *base, lpspi_slave_handle_t *handle, lpspi_transfer_t *transfer)
 LPSPI slave transfer data using an interrupt method.
 
status_t LPSPI_SlaveTransferGetCount (LPSPI_Type *base, lpspi_slave_handle_t *handle, size_t *count)
 Gets the slave transfer remaining bytes.
 
void LPSPI_SlaveTransferAbort (LPSPI_Type *base, lpspi_slave_handle_t *handle)
 LPSPI slave aborts a transfer which uses an interrupt method.
 
void LPSPI_SlaveTransferHandleIRQ (LPSPI_Type *base, lpspi_slave_handle_t *handle)
 LPSPI Slave IRQ handler function.
 

Detailed Description

Typedef Documentation

◆ lpspi_clock_phase_t

LPSPI clock phase configuration.

◆ lpspi_clock_polarity_t

LPSPI clock polarity configuration.

◆ lpspi_data_out_config_t

LPSPI data output configuration.

◆ lpspi_delay_type_t

LPSPI delay type selection.

◆ lpspi_host_request_select_t

LPSPI Host Request select configuration.

◆ lpspi_master_config_t

LPSPI master configuration structure.

◆ lpspi_master_handle_t

Forward declaration of the _lpspi_master_handle typedefs.

Definition at line 302 of file fsl_lpspi.h.

◆ lpspi_master_slave_mode_t

LPSPI master or slave mode configuration.

◆ lpspi_master_transfer_callback_t

typedef void(* lpspi_master_transfer_callback_t) (LPSPI_Type *base, lpspi_master_handle_t *handle, status_t status, void *userData)

Master completion callback function pointer type.

Parameters
baseLPSPI peripheral address.
handlePointer to the handle for the LPSPI master.
statusSuccess or error code describing whether the transfer is completed.
userDataArbitrary pointer-dataSized value passed from the application.

Definition at line 317 of file fsl_lpspi.h.

◆ lpspi_match_config_t

LPSPI Match configuration options.

◆ lpspi_pcs_polarity_config_t

LPSPI Peripheral Chip Select (PCS) Polarity configuration.

◆ lpspi_pin_config_t

LPSPI pin (SDO and SDI) configuration.

◆ lpspi_shift_direction_t

LPSPI data shifter direction options.

◆ lpspi_slave_config_t

LPSPI slave configuration structure.

◆ lpspi_slave_handle_t

Forward declaration of the _lpspi_slave_handle typedefs.

Definition at line 307 of file fsl_lpspi.h.

◆ lpspi_slave_transfer_callback_t

typedef void(* lpspi_slave_transfer_callback_t) (LPSPI_Type *base, lpspi_slave_handle_t *handle, status_t status, void *userData)

Slave completion callback function pointer type.

Parameters
baseLPSPI peripheral address.
handlePointer to the handle for the LPSPI slave.
statusSuccess or error code describing whether the transfer is completed.
userDataArbitrary pointer-dataSized value passed from the application.

Definition at line 330 of file fsl_lpspi.h.

◆ lpspi_transfer_t

LPSPI master/slave transfer structure.

◆ lpspi_transfer_width_t

LPSPI transfer width configuration.

◆ lpspi_which_pcs_t

LPSPI Peripheral Chip Select (PCS) configuration (which PCS to configure).

Enumeration Type Documentation

◆ _lpspi_clock_phase

LPSPI clock phase configuration.

Enumerator
kLPSPI_ClockPhaseFirstEdge 

CPHA=0. Data is captured on the leading edge of the SCK and changed on the following edge.

kLPSPI_ClockPhaseSecondEdge 

CPHA=1. Data is changed on the leading edge of the SCK and captured on the following edge.

Definition at line 126 of file fsl_lpspi.h.

127{
128 kLPSPI_ClockPhaseFirstEdge = 0U, /*!< CPHA=0. Data is captured on the leading edge of the SCK and changed on the
129 following edge.*/
130 kLPSPI_ClockPhaseSecondEdge = 1U /*!< CPHA=1. Data is changed on the leading edge of the SCK and captured on the
131 following edge.*/
enum _lpspi_clock_phase lpspi_clock_phase_t
LPSPI clock phase configuration.
@ kLPSPI_ClockPhaseFirstEdge
Definition fsl_lpspi.h:128
@ kLPSPI_ClockPhaseSecondEdge
Definition fsl_lpspi.h:130

◆ _lpspi_clock_polarity

LPSPI clock polarity configuration.

Enumerator
kLPSPI_ClockPolarityActiveHigh 

CPOL=0. Active-high LPSPI clock (idles low)

kLPSPI_ClockPolarityActiveLow 

CPOL=1. Active-low LPSPI clock (idles high)

Definition at line 119 of file fsl_lpspi.h.

120{
121 kLPSPI_ClockPolarityActiveHigh = 0U, /*!< CPOL=0. Active-high LPSPI clock (idles low)*/
122 kLPSPI_ClockPolarityActiveLow = 1U /*!< CPOL=1. Active-low LPSPI clock (idles high)*/
enum _lpspi_clock_polarity lpspi_clock_polarity_t
LPSPI clock polarity configuration.
@ kLPSPI_ClockPolarityActiveHigh
Definition fsl_lpspi.h:121
@ kLPSPI_ClockPolarityActiveLow
Definition fsl_lpspi.h:122

◆ _lpspi_data_out_config

LPSPI data output configuration.

Enumerator
kLpspiDataOutRetained 

Data out retains last value when chip select is de-asserted

kLpspiDataOutTristate 

Data out is tristated when chip select is de-asserted

Definition at line 170 of file fsl_lpspi.h.

171{
172 kLpspiDataOutRetained = 0U, /*!< Data out retains last value when chip select is de-asserted */
173 kLpspiDataOutTristate = 1U /*!< Data out is tristated when chip select is de-asserted */
enum _lpspi_data_out_config lpspi_data_out_config_t
LPSPI data output configuration.
@ kLpspiDataOutRetained
Definition fsl_lpspi.h:172
@ kLpspiDataOutTristate
Definition fsl_lpspi.h:173

◆ _lpspi_delay_type

LPSPI delay type selection.

Enumerator
kLPSPI_PcsToSck 

PCS-to-SCK delay.

kLPSPI_LastSckToPcs 

Last SCK edge to PCS delay.

kLPSPI_BetweenTransfer 

Delay between transfers.

Definition at line 185 of file fsl_lpspi.h.

186{
187 kLPSPI_PcsToSck = 1U, /*!< PCS-to-SCK delay. */
188 kLPSPI_LastSckToPcs, /*!< Last SCK edge to PCS delay. */
189 kLPSPI_BetweenTransfer /*!< Delay between transfers. */
enum _lpspi_delay_type lpspi_delay_type_t
LPSPI delay type selection.
@ kLPSPI_PcsToSck
Definition fsl_lpspi.h:187
@ kLPSPI_LastSckToPcs
Definition fsl_lpspi.h:188
@ kLPSPI_BetweenTransfer
Definition fsl_lpspi.h:189

◆ _lpspi_dma_enable

LPSPI DMA source.

Enumerator
kLPSPI_TxDmaEnable 

Transmit data DMA enable

kLPSPI_RxDmaEnable 

Receive data DMA enable

Definition at line 79 of file fsl_lpspi.h.

80{
81 kLPSPI_TxDmaEnable = LPSPI_DER_TDDE_MASK, /*!< Transmit data DMA enable */
82 kLPSPI_RxDmaEnable = LPSPI_DER_RDDE_MASK /*!< Receive data DMA enable */
83};
@ kLPSPI_TxDmaEnable
Definition fsl_lpspi.h:81
@ kLPSPI_RxDmaEnable
Definition fsl_lpspi.h:82

◆ _lpspi_flags

LPSPI status flags in SPIx_SR register.

Enumerator
kLPSPI_TxDataRequestFlag 

Transmit data flag

kLPSPI_RxDataReadyFlag 

Receive data flag

kLPSPI_WordCompleteFlag 

Word Complete flag

kLPSPI_FrameCompleteFlag 

Frame Complete flag

kLPSPI_TransferCompleteFlag 

Transfer Complete flag

kLPSPI_TransmitErrorFlag 

Transmit Error flag (FIFO underrun)

kLPSPI_ReceiveErrorFlag 

Receive Error flag (FIFO overrun)

kLPSPI_DataMatchFlag 

Data Match flag

kLPSPI_ModuleBusyFlag 

Module Busy flag

kLPSPI_AllStatusFlag 

Used for clearing all w1c status flags

Definition at line 46 of file fsl_lpspi.h.

47{
48 kLPSPI_TxDataRequestFlag = LPSPI_SR_TDF_MASK, /*!< Transmit data flag */
49 kLPSPI_RxDataReadyFlag = LPSPI_SR_RDF_MASK, /*!< Receive data flag */
50 kLPSPI_WordCompleteFlag = LPSPI_SR_WCF_MASK, /*!< Word Complete flag */
51 kLPSPI_FrameCompleteFlag = LPSPI_SR_FCF_MASK, /*!< Frame Complete flag */
52 kLPSPI_TransferCompleteFlag = LPSPI_SR_TCF_MASK, /*!< Transfer Complete flag */
53 kLPSPI_TransmitErrorFlag = LPSPI_SR_TEF_MASK, /*!< Transmit Error flag (FIFO underrun) */
54 kLPSPI_ReceiveErrorFlag = LPSPI_SR_REF_MASK, /*!< Receive Error flag (FIFO overrun) */
55 kLPSPI_DataMatchFlag = LPSPI_SR_DMF_MASK, /*!< Data Match flag */
56 kLPSPI_ModuleBusyFlag = LPSPI_SR_MBF_MASK, /*!< Module Busy flag */
57 kLPSPI_AllStatusFlag = (LPSPI_SR_TDF_MASK | LPSPI_SR_RDF_MASK | LPSPI_SR_WCF_MASK | LPSPI_SR_FCF_MASK |
58 LPSPI_SR_TCF_MASK | LPSPI_SR_TEF_MASK | LPSPI_SR_REF_MASK | LPSPI_SR_DMF_MASK |
59 LPSPI_SR_MBF_MASK) /*!< Used for clearing all w1c status flags */
60};
@ kLPSPI_TransmitErrorFlag
Definition fsl_lpspi.h:53
@ kLPSPI_TxDataRequestFlag
Definition fsl_lpspi.h:48
@ kLPSPI_TransferCompleteFlag
Definition fsl_lpspi.h:52
@ kLPSPI_DataMatchFlag
Definition fsl_lpspi.h:55
@ kLPSPI_RxDataReadyFlag
Definition fsl_lpspi.h:49
@ kLPSPI_ModuleBusyFlag
Definition fsl_lpspi.h:56
@ kLPSPI_ReceiveErrorFlag
Definition fsl_lpspi.h:54
@ kLPSPI_FrameCompleteFlag
Definition fsl_lpspi.h:51
@ kLPSPI_WordCompleteFlag
Definition fsl_lpspi.h:50
@ kLPSPI_AllStatusFlag
Definition fsl_lpspi.h:57

◆ _lpspi_host_request_select

LPSPI Host Request select configuration.

Enumerator
kLPSPI_HostReqExtPin 

Host Request is an ext pin.

kLPSPI_HostReqInternalTrigger 

Host Request is an internal trigger.

Definition at line 142 of file fsl_lpspi.h.

143{
144 kLPSPI_HostReqExtPin = 0U, /*!< Host Request is an ext pin. */
145 kLPSPI_HostReqInternalTrigger = 1U /*!< Host Request is an internal trigger. */
enum _lpspi_host_request_select lpspi_host_request_select_t
LPSPI Host Request select configuration.
@ kLPSPI_HostReqExtPin
Definition fsl_lpspi.h:144
@ kLPSPI_HostReqInternalTrigger
Definition fsl_lpspi.h:145

◆ _lpspi_interrupt_enable

LPSPI interrupt source.

Enumerator
kLPSPI_TxInterruptEnable 

Transmit data interrupt enable

kLPSPI_RxInterruptEnable 

Receive data interrupt enable

kLPSPI_WordCompleteInterruptEnable 

Word complete interrupt enable

kLPSPI_FrameCompleteInterruptEnable 

Frame complete interrupt enable

kLPSPI_TransferCompleteInterruptEnable 

Transfer complete interrupt enable

kLPSPI_TransmitErrorInterruptEnable 

Transmit error interrupt enable(FIFO underrun)

kLPSPI_ReceiveErrorInterruptEnable 

Receive Error interrupt enable (FIFO overrun)

kLPSPI_DataMatchInterruptEnable 

Data Match interrupt enable

kLPSPI_AllInterruptEnable 

All above interrupts enable.

Definition at line 63 of file fsl_lpspi.h.

64{
65 kLPSPI_TxInterruptEnable = LPSPI_IER_TDIE_MASK, /*!< Transmit data interrupt enable */
66 kLPSPI_RxInterruptEnable = LPSPI_IER_RDIE_MASK, /*!< Receive data interrupt enable */
67 kLPSPI_WordCompleteInterruptEnable = LPSPI_IER_WCIE_MASK, /*!< Word complete interrupt enable */
68 kLPSPI_FrameCompleteInterruptEnable = LPSPI_IER_FCIE_MASK, /*!< Frame complete interrupt enable */
69 kLPSPI_TransferCompleteInterruptEnable = LPSPI_IER_TCIE_MASK, /*!< Transfer complete interrupt enable */
70 kLPSPI_TransmitErrorInterruptEnable = LPSPI_IER_TEIE_MASK, /*!< Transmit error interrupt enable(FIFO underrun)*/
71 kLPSPI_ReceiveErrorInterruptEnable = LPSPI_IER_REIE_MASK, /*!< Receive Error interrupt enable (FIFO overrun) */
72 kLPSPI_DataMatchInterruptEnable = LPSPI_IER_DMIE_MASK, /*!< Data Match interrupt enable */
74 (LPSPI_IER_TDIE_MASK | LPSPI_IER_RDIE_MASK | LPSPI_IER_WCIE_MASK | LPSPI_IER_FCIE_MASK | LPSPI_IER_TCIE_MASK |
75 LPSPI_IER_TEIE_MASK | LPSPI_IER_REIE_MASK | LPSPI_IER_DMIE_MASK) /*!< All above interrupts enable.*/
76};
@ kLPSPI_ReceiveErrorInterruptEnable
Definition fsl_lpspi.h:71
@ kLPSPI_FrameCompleteInterruptEnable
Definition fsl_lpspi.h:68
@ kLPSPI_TransmitErrorInterruptEnable
Definition fsl_lpspi.h:70
@ kLPSPI_AllInterruptEnable
Definition fsl_lpspi.h:73
@ kLPSPI_RxInterruptEnable
Definition fsl_lpspi.h:66
@ kLPSPI_TxInterruptEnable
Definition fsl_lpspi.h:65
@ kLPSPI_DataMatchInterruptEnable
Definition fsl_lpspi.h:72
@ kLPSPI_WordCompleteInterruptEnable
Definition fsl_lpspi.h:67
@ kLPSPI_TransferCompleteInterruptEnable
Definition fsl_lpspi.h:69

◆ _lpspi_master_slave_mode

LPSPI master or slave mode configuration.

Enumerator
kLPSPI_Master 

LPSPI peripheral operates in master mode.

kLPSPI_Slave 

LPSPI peripheral operates in slave mode.

Definition at line 86 of file fsl_lpspi.h.

87{
88 kLPSPI_Master = 1U, /*!< LPSPI peripheral operates in master mode.*/
89 kLPSPI_Slave = 0U /*!< LPSPI peripheral operates in slave mode.*/
enum _lpspi_master_slave_mode lpspi_master_slave_mode_t
LPSPI master or slave mode configuration.
@ kLPSPI_Master
Definition fsl_lpspi.h:88
@ kLPSPI_Slave
Definition fsl_lpspi.h:89

◆ _lpspi_match_config

LPSPI Match configuration options.

Enumerator
kLPSI_MatchDisabled 

LPSPI Match Disabled.

kLPSI_1stWordEqualsM0orM1 

LPSPI Match Enabled.

kLPSI_AnyWordEqualsM0orM1 

LPSPI Match Enabled.

kLPSI_1stWordEqualsM0and2ndWordEqualsM1 

LPSPI Match Enabled.

kLPSI_AnyWordEqualsM0andNxtWordEqualsM1 

LPSPI Match Enabled.

kLPSI_1stWordAndM1EqualsM0andM1 

LPSPI Match Enabled.

kLPSI_AnyWordAndM1EqualsM0andM1 

LPSPI Match Enabled.

Definition at line 149 of file fsl_lpspi.h.

150{
151 kLPSI_MatchDisabled = 0x0U, /*!< LPSPI Match Disabled. */
152 kLPSI_1stWordEqualsM0orM1 = 0x2U, /*!< LPSPI Match Enabled. */
153 kLPSI_AnyWordEqualsM0orM1 = 0x3U, /*!< LPSPI Match Enabled. */
154 kLPSI_1stWordEqualsM0and2ndWordEqualsM1 = 0x4U, /*!< LPSPI Match Enabled. */
155 kLPSI_AnyWordEqualsM0andNxtWordEqualsM1 = 0x5U, /*!< LPSPI Match Enabled. */
156 kLPSI_1stWordAndM1EqualsM0andM1 = 0x6U, /*!< LPSPI Match Enabled. */
157 kLPSI_AnyWordAndM1EqualsM0andM1 = 0x7U, /*!< LPSPI Match Enabled. */
enum _lpspi_match_config lpspi_match_config_t
LPSPI Match configuration options.
@ kLPSI_AnyWordAndM1EqualsM0andM1
Definition fsl_lpspi.h:157
@ kLPSI_MatchDisabled
Definition fsl_lpspi.h:151
@ kLPSI_1stWordEqualsM0and2ndWordEqualsM1
Definition fsl_lpspi.h:154
@ kLPSI_1stWordEqualsM0orM1
Definition fsl_lpspi.h:152
@ kLPSI_1stWordAndM1EqualsM0andM1
Definition fsl_lpspi.h:156
@ kLPSI_AnyWordEqualsM0andNxtWordEqualsM1
Definition fsl_lpspi.h:155
@ kLPSI_AnyWordEqualsM0orM1
Definition fsl_lpspi.h:153

◆ _lpspi_pcs_polarity

LPSPI Peripheral Chip Select (PCS) Polarity.

Enumerator
kLPSPI_Pcs0ActiveLow 

Pcs0 Active Low (idles high).

kLPSPI_Pcs1ActiveLow 

Pcs1 Active Low (idles high).

kLPSPI_Pcs2ActiveLow 

Pcs2 Active Low (idles high).

kLPSPI_Pcs3ActiveLow 

Pcs3 Active Low (idles high).

kLPSPI_PcsAllActiveLow 

Pcs0 to Pcs5 Active Low (idles high).

Definition at line 109 of file fsl_lpspi.h.

110{
111 kLPSPI_Pcs0ActiveLow = 1U << 0, /*!< Pcs0 Active Low (idles high). */
112 kLPSPI_Pcs1ActiveLow = 1U << 1, /*!< Pcs1 Active Low (idles high). */
113 kLPSPI_Pcs2ActiveLow = 1U << 2, /*!< Pcs2 Active Low (idles high). */
114 kLPSPI_Pcs3ActiveLow = 1U << 3, /*!< Pcs3 Active Low (idles high). */
115 kLPSPI_PcsAllActiveLow = 0xFU /*!< Pcs0 to Pcs5 Active Low (idles high). */
116};
@ kLPSPI_Pcs0ActiveLow
Definition fsl_lpspi.h:111
@ kLPSPI_Pcs2ActiveLow
Definition fsl_lpspi.h:113
@ kLPSPI_PcsAllActiveLow
Definition fsl_lpspi.h:115
@ kLPSPI_Pcs3ActiveLow
Definition fsl_lpspi.h:114
@ kLPSPI_Pcs1ActiveLow
Definition fsl_lpspi.h:112

◆ _lpspi_pcs_polarity_config

LPSPI Peripheral Chip Select (PCS) Polarity configuration.

Enumerator
kLPSPI_PcsActiveHigh 

PCS Active High (idles low)

kLPSPI_PcsActiveLow 

PCS Active Low (idles high)

Definition at line 102 of file fsl_lpspi.h.

103{
104 kLPSPI_PcsActiveHigh = 1U, /*!< PCS Active High (idles low) */
105 kLPSPI_PcsActiveLow = 0U /*!< PCS Active Low (idles high) */
enum _lpspi_pcs_polarity_config lpspi_pcs_polarity_config_t
LPSPI Peripheral Chip Select (PCS) Polarity configuration.
@ kLPSPI_PcsActiveLow
Definition fsl_lpspi.h:105
@ kLPSPI_PcsActiveHigh
Definition fsl_lpspi.h:104

◆ _lpspi_pin_config

LPSPI pin (SDO and SDI) configuration.

Enumerator
kLPSPI_SdiInSdoOut 

LPSPI SDI input, SDO output.

kLPSPI_SdiInSdiOut 

LPSPI SDI input, SDI output.

kLPSPI_SdoInSdoOut 

LPSPI SDO input, SDO output.

kLPSPI_SdoInSdiOut 

LPSPI SDO input, SDI output.

Definition at line 161 of file fsl_lpspi.h.

162{
163 kLPSPI_SdiInSdoOut = 0U, /*!< LPSPI SDI input, SDO output. */
164 kLPSPI_SdiInSdiOut = 1U, /*!< LPSPI SDI input, SDI output. */
165 kLPSPI_SdoInSdoOut = 2U, /*!< LPSPI SDO input, SDO output. */
166 kLPSPI_SdoInSdiOut = 3U /*!< LPSPI SDO input, SDI output. */
enum _lpspi_pin_config lpspi_pin_config_t
LPSPI pin (SDO and SDI) configuration.
@ kLPSPI_SdiInSdiOut
Definition fsl_lpspi.h:164
@ kLPSPI_SdiInSdoOut
Definition fsl_lpspi.h:163
@ kLPSPI_SdoInSdoOut
Definition fsl_lpspi.h:165
@ kLPSPI_SdoInSdiOut
Definition fsl_lpspi.h:166

◆ _lpspi_shift_direction

LPSPI data shifter direction options.

Enumerator
kLPSPI_MsbFirst 

Data transfers start with most significant bit.

kLPSPI_LsbFirst 

Data transfers start with least significant bit.

Definition at line 135 of file fsl_lpspi.h.

136{
137 kLPSPI_MsbFirst = 0U, /*!< Data transfers start with most significant bit.*/
138 kLPSPI_LsbFirst = 1U /*!< Data transfers start with least significant bit.*/
enum _lpspi_shift_direction lpspi_shift_direction_t
LPSPI data shifter direction options.
@ kLPSPI_MsbFirst
Definition fsl_lpspi.h:137
@ kLPSPI_LsbFirst
Definition fsl_lpspi.h:138

◆ _lpspi_status

Status for the LPSPI driver.

Enumerator
kStatus_LPSPI_Busy 

LPSPI transfer is busy.

kStatus_LPSPI_Error 

LPSPI driver error.

kStatus_LPSPI_Idle 

LPSPI is idle.

kStatus_LPSPI_OutOfRange 

LPSPI transfer out Of range.

Definition at line 37 of file fsl_lpspi.h.

38{
39 kStatus_LPSPI_Busy = MAKE_STATUS(kStatusGroup_LPSPI, 0), /*!< LPSPI transfer is busy.*/
40 kStatus_LPSPI_Error = MAKE_STATUS(kStatusGroup_LPSPI, 1), /*!< LPSPI driver error. */
41 kStatus_LPSPI_Idle = MAKE_STATUS(kStatusGroup_LPSPI, 2), /*!< LPSPI is idle.*/
42 kStatus_LPSPI_OutOfRange = MAKE_STATUS(kStatusGroup_LPSPI, 3) /*!< LPSPI transfer out Of range. */
43};
@ kStatusGroup_LPSPI
Definition fsl_common.h:64
@ kStatus_LPSPI_OutOfRange
Definition fsl_lpspi.h:42
@ kStatus_LPSPI_Error
Definition fsl_lpspi.h:40
@ kStatus_LPSPI_Idle
Definition fsl_lpspi.h:41
@ kStatus_LPSPI_Busy
Definition fsl_lpspi.h:39

◆ _lpspi_transfer_config_flag_for_master

Use this enumeration for LPSPI master transfer configFlags.

Enumerator
kLPSPI_MasterPcs0 

LPSPI master transfer use PCS0 signal

kLPSPI_MasterPcs1 

LPSPI master transfer use PCS1 signal

kLPSPI_MasterPcs2 

LPSPI master transfer use PCS2 signal

kLPSPI_MasterPcs3 

LPSPI master transfer use PCS3 signal

kLPSPI_MasterPcsContinuous 

Is PCS signal continuous

kLPSPI_MasterByteSwap 

Is master swap the byte. For example, when want to send data 1 2 3 4 5 6 7 8 (suppose you set lpspi_shift_direction_t to MSB).

  1. If you set bitPerFrame = 8 , no matter the kLPSPI_MasterByteSwapyou flag is used or not, the waveform is 1 2 3 4 5 6 7 8.
  2. If you set bitPerFrame = 16 : (1) the waveform is 2 1 4 3 6 5 8 7 if you do not use the kLPSPI_MasterByteSwap flag. (2) the waveform is 1 2 3 4 5 6 7 8 if you use the kLPSPI_MasterByteSwap flag.
  3. If you set bitPerFrame = 32 : (1) the waveform is 4 3 2 1 8 7 6 5 if you do not use the kLPSPI_MasterByteSwap flag. (2) the waveform is 1 2 3 4 5 6 7 8 if you use the kLPSPI_MasterByteSwap flag.

Definition at line 196 of file fsl_lpspi.h.

197{
198 kLPSPI_MasterPcs0 = 0U << LPSPI_MASTER_PCS_SHIFT, /*!< LPSPI master transfer use PCS0 signal */
199 kLPSPI_MasterPcs1 = 1U << LPSPI_MASTER_PCS_SHIFT, /*!< LPSPI master transfer use PCS1 signal */
200 kLPSPI_MasterPcs2 = 2U << LPSPI_MASTER_PCS_SHIFT, /*!< LPSPI master transfer use PCS2 signal */
201 kLPSPI_MasterPcs3 = 3U << LPSPI_MASTER_PCS_SHIFT, /*!< LPSPI master transfer use PCS3 signal */
202
203 kLPSPI_MasterPcsContinuous = 1U << 20, /*!< Is PCS signal continuous */
204
206 1U << 22 /*!< Is master swap the byte.
207 * For example, when want to send data 1 2 3 4 5 6 7 8 (suppose you set
208 * lpspi_shift_direction_t to MSB).
209 * 1. If you set bitPerFrame = 8 , no matter the kLPSPI_MasterByteSwapyou flag is used
210 * or not, the waveform is 1 2 3 4 5 6 7 8.
211 * 2. If you set bitPerFrame = 16 :
212 * (1) the waveform is 2 1 4 3 6 5 8 7 if you do not use the kLPSPI_MasterByteSwap flag.
213 * (2) the waveform is 1 2 3 4 5 6 7 8 if you use the kLPSPI_MasterByteSwap flag.
214 * 3. If you set bitPerFrame = 32 :
215 * (1) the waveform is 4 3 2 1 8 7 6 5 if you do not use the kLPSPI_MasterByteSwap flag.
216 * (2) the waveform is 1 2 3 4 5 6 7 8 if you use the kLPSPI_MasterByteSwap flag.
217 */
218};
@ kLPSPI_MasterPcs1
Definition fsl_lpspi.h:199
@ kLPSPI_MasterPcs3
Definition fsl_lpspi.h:201
@ kLPSPI_MasterPcsContinuous
Definition fsl_lpspi.h:203
@ kLPSPI_MasterByteSwap
Definition fsl_lpspi.h:205
@ kLPSPI_MasterPcs2
Definition fsl_lpspi.h:200
@ kLPSPI_MasterPcs0
Definition fsl_lpspi.h:198

◆ _lpspi_transfer_config_flag_for_slave

Use this enumeration for LPSPI slave transfer configFlags.

Enumerator
kLPSPI_SlavePcs0 

LPSPI slave transfer use PCS0 signal

kLPSPI_SlavePcs1 

LPSPI slave transfer use PCS1 signal

kLPSPI_SlavePcs2 

LPSPI slave transfer use PCS2 signal

kLPSPI_SlavePcs3 

LPSPI slave transfer use PCS3 signal

kLPSPI_SlaveByteSwap 

Is slave swap the byte. For example, when want to send data 1 2 3 4 5 6 7 8 (suppose you set lpspi_shift_direction_t to MSB).

  1. If you set bitPerFrame = 8 , no matter the kLPSPI_SlaveByteSwap flag is used or not, the waveform is 1 2 3 4 5 6 7 8.
  2. If you set bitPerFrame = 16 : (1) the waveform is 2 1 4 3 6 5 8 7 if you do not use the kLPSPI_SlaveByteSwap flag. (2) the waveform is 1 2 3 4 5 6 7 8 if you use the kLPSPI_SlaveByteSwap flag.
  3. If you set bitPerFrame = 32 : (1) the waveform is 4 3 2 1 8 7 6 5 if you do not use the kLPSPI_SlaveByteSwap flag. (2) the waveform is 1 2 3 4 5 6 7 8 if you use the kLPSPI_SlaveByteSwap flag.

Definition at line 224 of file fsl_lpspi.h.

225{
226 kLPSPI_SlavePcs0 = 0U << LPSPI_SLAVE_PCS_SHIFT, /*!< LPSPI slave transfer use PCS0 signal */
227 kLPSPI_SlavePcs1 = 1U << LPSPI_SLAVE_PCS_SHIFT, /*!< LPSPI slave transfer use PCS1 signal */
228 kLPSPI_SlavePcs2 = 2U << LPSPI_SLAVE_PCS_SHIFT, /*!< LPSPI slave transfer use PCS2 signal */
229 kLPSPI_SlavePcs3 = 3U << LPSPI_SLAVE_PCS_SHIFT, /*!< LPSPI slave transfer use PCS3 signal */
230
232 1U << 22 /*!< Is slave swap the byte.
233 * For example, when want to send data 1 2 3 4 5 6 7 8 (suppose you set
234 * lpspi_shift_direction_t to MSB).
235 * 1. If you set bitPerFrame = 8 , no matter the kLPSPI_SlaveByteSwap flag is used
236 * or not, the waveform is 1 2 3 4 5 6 7 8.
237 * 2. If you set bitPerFrame = 16 :
238 * (1) the waveform is 2 1 4 3 6 5 8 7 if you do not use the kLPSPI_SlaveByteSwap flag.
239 * (2) the waveform is 1 2 3 4 5 6 7 8 if you use the kLPSPI_SlaveByteSwap flag.
240 * 3. If you set bitPerFrame = 32 :
241 * (1) the waveform is 4 3 2 1 8 7 6 5 if you do not use the kLPSPI_SlaveByteSwap flag.
242 * (2) the waveform is 1 2 3 4 5 6 7 8 if you use the kLPSPI_SlaveByteSwap flag.
243 */
244};
@ kLPSPI_SlavePcs1
Definition fsl_lpspi.h:227
@ kLPSPI_SlaveByteSwap
Definition fsl_lpspi.h:231
@ kLPSPI_SlavePcs3
Definition fsl_lpspi.h:229
@ kLPSPI_SlavePcs0
Definition fsl_lpspi.h:226
@ kLPSPI_SlavePcs2
Definition fsl_lpspi.h:228

◆ _lpspi_transfer_state

LPSPI transfer state, which is used for LPSPI transactional API state machine.

Enumerator
kLPSPI_Idle 

Nothing in the transmitter/receiver.

kLPSPI_Busy 

Transfer queue is not finished.

kLPSPI_Error 

Transfer error.

Definition at line 247 of file fsl_lpspi.h.

248{
249 kLPSPI_Idle = 0x0U, /*!< Nothing in the transmitter/receiver. */
250 kLPSPI_Busy, /*!< Transfer queue is not finished. */
251 kLPSPI_Error /*!< Transfer error. */
252};
@ kLPSPI_Busy
Definition fsl_lpspi.h:250
@ kLPSPI_Error
Definition fsl_lpspi.h:251
@ kLPSPI_Idle
Definition fsl_lpspi.h:249

◆ _lpspi_transfer_width

LPSPI transfer width configuration.

Enumerator
kLPSPI_SingleBitXfer 

1-bit shift at a time, data out on SDO, in on SDI (normal mode)

kLPSPI_TwoBitXfer 

2-bits shift out on SDO/SDI and in on SDO/SDI

kLPSPI_FourBitXfer 

4-bits shift out on SDO/SDI/PCS[3:2] and in on SDO/SDI/PCS[3:2]

Definition at line 177 of file fsl_lpspi.h.

178{
179 kLPSPI_SingleBitXfer = 0U, /*!< 1-bit shift at a time, data out on SDO, in on SDI (normal mode) */
180 kLPSPI_TwoBitXfer = 1U, /*!< 2-bits shift out on SDO/SDI and in on SDO/SDI */
181 kLPSPI_FourBitXfer = 2U /*!< 4-bits shift out on SDO/SDI/PCS[3:2] and in on SDO/SDI/PCS[3:2] */
enum _lpspi_transfer_width lpspi_transfer_width_t
LPSPI transfer width configuration.
@ kLPSPI_SingleBitXfer
Definition fsl_lpspi.h:179
@ kLPSPI_FourBitXfer
Definition fsl_lpspi.h:181
@ kLPSPI_TwoBitXfer
Definition fsl_lpspi.h:180

◆ _lpspi_which_pcs_config

LPSPI Peripheral Chip Select (PCS) configuration (which PCS to configure).

Enumerator
kLPSPI_Pcs0 

PCS[0]

kLPSPI_Pcs1 

PCS[1]

kLPSPI_Pcs2 

PCS[2]

kLPSPI_Pcs3 

PCS[3]

Definition at line 93 of file fsl_lpspi.h.

94{
95 kLPSPI_Pcs0 = 0U, /*!< PCS[0] */
96 kLPSPI_Pcs1 = 1U, /*!< PCS[1] */
97 kLPSPI_Pcs2 = 2U, /*!< PCS[2] */
98 kLPSPI_Pcs3 = 3U /*!< PCS[3] */
enum _lpspi_which_pcs_config lpspi_which_pcs_t
LPSPI Peripheral Chip Select (PCS) configuration (which PCS to configure).
@ kLPSPI_Pcs1
Definition fsl_lpspi.h:96
@ kLPSPI_Pcs2
Definition fsl_lpspi.h:97
@ kLPSPI_Pcs3
Definition fsl_lpspi.h:98
@ kLPSPI_Pcs0
Definition fsl_lpspi.h:95

Function Documentation

◆ LPSPI_CheckTransferArgument()

bool LPSPI_CheckTransferArgument ( lpspi_transfer_t transfer,
uint32_t  bitsPerFrame,
uint32_t  bytesPerFrame 
)

Check the argument for transfer .

Parameters
transferthe transfer struct to be used.
bitPerFrameThe bit size of one frame.
bytePerFrameThe byte size of one frame.
Returns
Return true for right and false for wrong.

brief Check the argument for transfer .

param transfer the transfer struct to be used. param bitPerFrame The bit size of one frame. param bytePerFrame The byte size of one frame. return Return true for right and false for wrong.

Definition at line 713 of file fsl_lpspi.c.

714{
715 assert(transfer);
716
717 /* If the transfer count is zero, then return immediately.*/
718 if (transfer->dataSize == 0)
719 {
720 return false;
721 }
722
723 /* If both send buffer and receive buffer is null */
724 if ((!(transfer->txData)) && (!(transfer->rxData)))
725 {
726 return false;
727 }
728
729 /*The transfer data size should be integer multiples of bytesPerFrame if bytesPerFrame is less than or equal to 4 .
730 *For bytesPerFrame greater than 4 situation:
731 *the transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not integer multiples of 4 ,
732 *otherwise , the transfer data size can be integer multiples of bytesPerFrame.
733 */
734 if (bytesPerFrame <= 4)
735 {
736 if ((transfer->dataSize % bytesPerFrame) != 0)
737 {
738 return false;
739 }
740 }
741 else
742 {
743 if ((bytesPerFrame % 4U) != 0)
744 {
745 if (transfer->dataSize != bytesPerFrame)
746 {
747 return false;
748 }
749 }
750 else
751 {
752 if ((transfer->dataSize % bytesPerFrame) != 0)
753 {
754 return false;
755 }
756 }
757 }
758
759 return true;
760}
uint8_t * rxData
Definition fsl_lpspi.h:339
volatile size_t dataSize
Definition fsl_lpspi.h:340
uint8_t * txData
Definition fsl_lpspi.h:338

Referenced by LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferEDMA(), LPSPI_MasterTransferNonBlocking(), LPSPI_SlaveTransferEDMA(), and LPSPI_SlaveTransferNonBlocking().

Here is the caller graph for this function:

◆ LPSPI_ClearStatusFlags()

static void LPSPI_ClearStatusFlags ( LPSPI_Type *  base,
uint32_t  statusFlags 
)
inlinestatic

Clears the LPSPI status flag.

This function clears the desired status bit by using a write-1-to-clear. The user passes in the base and the desired status flag bit to clear. The list of status flags is defined in the _lpspi_flags. Example usage:

static void LPSPI_ClearStatusFlags(LPSPI_Type *base, uint32_t statusFlags)
Clears the LPSPI status flag.
Definition fsl_lpspi.h:575
Parameters
baseLPSPI peripheral address.
statusFlagsThe status flag used from type _lpspi_flags.

< The status flags are cleared by writing 1 (w1c).

Definition at line 575 of file fsl_lpspi.h.

576{
577 base->SR = statusFlags; /*!< The status flags are cleared by writing 1 (w1c).*/
578}

Referenced by LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferEDMA(), LPSPI_MasterTransferNonBlocking(), LPSPI_SlaveTransferEDMA(), LPSPI_SlaveTransferHandleIRQ(), and LPSPI_SlaveTransferNonBlocking().

Here is the caller graph for this function:

◆ LPSPI_Deinit()

void LPSPI_Deinit ( LPSPI_Type *  base)

De-initializes the LPSPI peripheral. Call this API to disable the LPSPI clock.

Parameters
baseLPSPI peripheral address.

brief De-initializes the LPSPI peripheral. Call this API to disable the LPSPI clock. param base LPSPI peripheral address.

Definition at line 367 of file fsl_lpspi.c.

368{
369 /* Reset to default value */
370 LPSPI_Reset(base);
371
372#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
373
374 uint32_t instance = LPSPI_GetInstance(base);
375 /* Enable LPSPI clock */
377
378#if defined(LPSPI_PERIPH_CLOCKS)
380#endif
381
382#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
383}
static BenchController instance
uint32_t LPSPI_GetInstance(LPSPI_Type *base)
Get instance number for LPSPI module.
Definition fsl_lpspi.c:146
static const clock_ip_name_t s_LpspiPeriphClocks[]
Definition fsl_lpspi.c:129
static const clock_ip_name_t s_lpspiClocks[]
Pointers to lpspi clocks for each instance.
Definition fsl_lpspi.c:126
static void CLOCK_DisableClock(clock_ip_name_t name)
Disable the clock for specific IP.
Definition fsl_clock.h:653
void LPSPI_Reset(LPSPI_Type *base)
Restores the LPSPI peripheral to reset state. Note that this function sets all registers to reset sta...
Definition fsl_lpspi.c:351

Referenced by spi_lld_stop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_DisableDMA()

static void LPSPI_DisableDMA ( LPSPI_Type *  base,
uint32_t  mask 
)
inlinestatic

Disables the LPSPI DMA request.

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

SPI_DisableDMA(base, kLPSPI_TxDmaEnable | kLPSPI_RxDmaEnable);
Parameters
baseLPSPI peripheral address.
maskThe interrupt mask; Use the enum _lpspi_dma_enable.

Definition at line 658 of file fsl_lpspi.h.

659{
660 base->DER &= ~mask;
661}

Referenced by EDMA_LpspiMasterCallback(), EDMA_LpspiSlaveCallback(), LPSPI_MasterTransferAbortEDMA(), LPSPI_MasterTransferEDMA(), LPSPI_SlaveTransferAbortEDMA(), and LPSPI_SlaveTransferEDMA().

Here is the caller graph for this function:

◆ LPSPI_DisableInterrupts()

static void LPSPI_DisableInterrupts ( LPSPI_Type *  base,
uint32_t  mask 
)
inlinestatic

Disables the LPSPI interrupts.

static void LPSPI_DisableInterrupts(LPSPI_Type *base, uint32_t mask)
Disables the LPSPI interrupts.
Definition fsl_lpspi.h:617
Parameters
baseLPSPI peripheral address.
maskThe interrupt mask; Use the enum _lpspi_interrupt_enable.

Definition at line 617 of file fsl_lpspi.h.

618{
619 base->IER &= ~mask;
620}

Referenced by LPSPI_MasterTransferAbort(), LPSPI_MasterTransferComplete(), LPSPI_MasterTransferEDMA(), LPSPI_MasterTransferHandleIRQ(), LPSPI_MasterTransferNonBlocking(), LPSPI_SlaveTransferAbort(), LPSPI_SlaveTransferComplete(), LPSPI_SlaveTransferEDMA(), LPSPI_SlaveTransferHandleIRQ(), and LPSPI_SlaveTransferNonBlocking().

Here is the caller graph for this function:

◆ LPSPI_Enable()

static void LPSPI_Enable ( LPSPI_Type *  base,
bool  enable 
)
inlinestatic

Enables the LPSPI peripheral and sets the MCR MDIS to 0.

Parameters
baseLPSPI peripheral address.
enablePass true to enable module, false to disable module.

Definition at line 491 of file fsl_lpspi.h.

492{
493 if (enable)
494 {
495 base->CR |= LPSPI_CR_MEN_MASK;
496 }
497 else
498 {
499 base->CR &= ~LPSPI_CR_MEN_MASK;
500 }
501}
static void enable(const char *param)
Definition settings.cpp:441

Referenced by LPSPI_MasterInit(), LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferEDMA(), LPSPI_MasterTransferNonBlocking(), LPSPI_SlaveInit(), LPSPI_SlaveTransferEDMA(), and LPSPI_SlaveTransferNonBlocking().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_EnableDMA()

static void LPSPI_EnableDMA ( LPSPI_Type *  base,
uint32_t  mask 
)
inlinestatic

Enables the LPSPI DMA request.

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

static void LPSPI_EnableDMA(LPSPI_Type *base, uint32_t mask)
Enables the LPSPI DMA request.
Definition fsl_lpspi.h:642
Parameters
baseLPSPI peripheral address.
maskThe interrupt mask; Use the enum _lpspi_dma_enable.

Definition at line 642 of file fsl_lpspi.h.

643{
644 base->DER |= mask;
645}

Referenced by LPSPI_MasterTransferEDMA(), and LPSPI_SlaveTransferEDMA().

Here is the caller graph for this function:

◆ LPSPI_EnableInterrupts()

static void LPSPI_EnableInterrupts ( LPSPI_Type *  base,
uint32_t  mask 
)
inlinestatic

Enables the LPSPI interrupts.

This function configures the various interrupt masks of the LPSPI. The parameters are base and an interrupt mask. Note that, for Tx fill and Rx FIFO drain requests, enabling the interrupt request disables the DMA request.

static void LPSPI_EnableInterrupts(LPSPI_Type *base, uint32_t mask)
Enables the LPSPI interrupts.
Definition fsl_lpspi.h:602
Parameters
baseLPSPI peripheral address.
maskThe interrupt mask; Use the enum _lpspi_interrupt_enable.

Definition at line 602 of file fsl_lpspi.h.

603{
604 base->IER |= mask;
605}

Referenced by LPSPI_MasterTransferHandleIRQ(), LPSPI_MasterTransferNonBlocking(), LPSPI_SlaveTransferHandleIRQ(), and LPSPI_SlaveTransferNonBlocking().

Here is the caller graph for this function:

◆ LPSPI_FlushFifo()

static void LPSPI_FlushFifo ( LPSPI_Type *  base,
bool  flushTxFifo,
bool  flushRxFifo 
)
inlinestatic

Flushes the LPSPI FIFOs.

Parameters
baseLPSPI peripheral address.
flushTxFifoFlushes (true) the Tx FIFO, else do not flush (false) the Tx FIFO.
flushRxFifoFlushes (true) the Rx FIFO, else do not flush (false) the Rx FIFO.

Definition at line 743 of file fsl_lpspi.h.

744{
745 base->CR |= ((uint32_t)flushTxFifo << LPSPI_CR_RTF_SHIFT) | ((uint32_t)flushRxFifo << LPSPI_CR_RRF_SHIFT);
746}

Referenced by LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferEDMA(), LPSPI_MasterTransferNonBlocking(), LPSPI_SlaveTransferEDMA(), and LPSPI_SlaveTransferNonBlocking().

Here is the caller graph for this function:

◆ LPSPI_GetRxFifoCount()

static uint32_t LPSPI_GetRxFifoCount ( LPSPI_Type *  base)
inlinestatic

Gets the LPSPI Rx FIFO count.

Parameters
baseLPSPI peripheral address.
Returns
The number of words in the receive FIFO.

Definition at line 557 of file fsl_lpspi.h.

558{
559 return ((base->FSR & LPSPI_FSR_RXCOUNT_MASK) >> LPSPI_FSR_RXCOUNT_SHIFT);
560}

Referenced by EDMA_LpspiMasterCallback(), EDMA_LpspiSlaveCallback(), LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferHandleIRQ(), and LPSPI_SlaveTransferHandleIRQ().

Here is the caller graph for this function:

◆ LPSPI_GetRxFifoSize()

static uint32_t LPSPI_GetRxFifoSize ( LPSPI_Type *  base)
inlinestatic

Gets the LPSPI Rx FIFO size.

Parameters
baseLPSPI peripheral address.
Returns
The LPSPI Rx FIFO size.

Definition at line 537 of file fsl_lpspi.h.

538{
539 return (1U << ((base->PARAM & LPSPI_PARAM_RXFIFO_MASK) >> LPSPI_PARAM_RXFIFO_SHIFT));
540}

Referenced by LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferEDMA(), LPSPI_MasterTransferNonBlocking(), LPSPI_SlaveTransferEDMA(), and LPSPI_SlaveTransferNonBlocking().

Here is the caller graph for this function:

◆ LPSPI_GetRxRegisterAddress()

static uint32_t LPSPI_GetRxRegisterAddress ( LPSPI_Type *  base)
inlinestatic

Gets the LPSPI Receive Data Register address for a DMA operation.

This function gets the LPSPI Receive Data Register address because this value is needed for the DMA operation. This function can be used for either master or slave mode.

Parameters
baseLPSPI peripheral address.
Returns
The LPSPI Receive Data Register address.

Definition at line 688 of file fsl_lpspi.h.

689{
690 return (uint32_t) & (base->RDR);
691}

Referenced by LPSPI_MasterTransferEDMA(), and LPSPI_SlaveTransferEDMA().

Here is the caller graph for this function:

◆ LPSPI_GetStatusFlags()

static uint32_t LPSPI_GetStatusFlags ( LPSPI_Type *  base)
inlinestatic

Gets the LPSPI status flag state.

Parameters
baseLPSPI peripheral address.
Returns
The LPSPI status(in SR register).

Definition at line 517 of file fsl_lpspi.h.

518{
519 return (base->SR);
520}

Referenced by LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferHandleIRQ(), and LPSPI_SlaveTransferHandleIRQ().

Here is the caller graph for this function:

◆ LPSPI_GetTxFifoCount()

static uint32_t LPSPI_GetTxFifoCount ( LPSPI_Type *  base)
inlinestatic

Gets the LPSPI Tx FIFO count.

Parameters
baseLPSPI peripheral address.
Returns
The number of words in the transmit FIFO.

Definition at line 547 of file fsl_lpspi.h.

548{
549 return ((base->FSR & LPSPI_FSR_TXCOUNT_MASK) >> LPSPI_FSR_TXCOUNT_SHIFT);
550}

Referenced by LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferFillUpTxFifo(), LPSPI_MasterTransferHandleIRQ(), LPSPI_MasterTransferNonBlocking(), LPSPI_SlaveTransferFillUpTxFifo(), LPSPI_SlaveTransferHandleIRQ(), and LPSPI_SlaveTransferNonBlocking().

Here is the caller graph for this function:

◆ LPSPI_GetTxFifoSize()

static uint32_t LPSPI_GetTxFifoSize ( LPSPI_Type *  base)
inlinestatic

Gets the LPSPI Tx FIFO size.

Parameters
baseLPSPI peripheral address.
Returns
The LPSPI Tx FIFO size.

Definition at line 527 of file fsl_lpspi.h.

528{
529 return (1U << ((base->PARAM & LPSPI_PARAM_TXFIFO_MASK) >> LPSPI_PARAM_TXFIFO_SHIFT));
530}

◆ LPSPI_GetTxRegisterAddress()

static uint32_t LPSPI_GetTxRegisterAddress ( LPSPI_Type *  base)
inlinestatic

Gets the LPSPI Transmit Data Register address for a DMA operation.

This function gets the LPSPI Transmit Data Register address because this value is needed for the DMA operation. This function can be used for either master or slave mode.

Parameters
baseLPSPI peripheral address.
Returns
The LPSPI Transmit Data Register address.

Definition at line 673 of file fsl_lpspi.h.

674{
675 return (uint32_t) & (base->TDR);
676}

Referenced by LPSPI_MasterTransferEDMA(), and LPSPI_SlaveTransferEDMA().

Here is the caller graph for this function:

◆ LPSPI_IsMaster()

static bool LPSPI_IsMaster ( LPSPI_Type *  base)
inlinestatic

Returns whether the LPSPI module is in master mode.

Parameters
baseLPSPI peripheral address.
Returns
Returns true if the module is in master mode or false if the module is in slave mode.

Definition at line 731 of file fsl_lpspi.h.

732{
733 return (bool)((base->CFGR1) & LPSPI_CFGR1_MASTER_MASK);
734}

Referenced by LPSPI_CommonIRQHandler(), and LPSPI_MasterSetBaudRate().

Here is the caller graph for this function:

◆ LPSPI_MasterGetDefaultConfig()

void LPSPI_MasterGetDefaultConfig ( lpspi_master_config_t masterConfig)

Sets the lpspi_master_config_t structure to default values.

This API initializes the configuration structure for LPSPI_MasterInit(). The initialized structure can remain unchanged in LPSPI_MasterInit(), or can be modified before calling the LPSPI_MasterInit(). Example:

lpspi_master_config_t masterConfig;
void LPSPI_MasterGetDefaultConfig(lpspi_master_config_t *masterConfig)
Sets the lpspi_master_config_t structure to default values.
Definition fsl_lpspi.c:249
LPSPI master configuration structure.
Definition fsl_lpspi.h:256
Parameters
masterConfigpointer to lpspi_master_config_t structure

brief Sets the lpspi_master_config_t structure to default values.

This API initializes the configuration structure for LPSPI_MasterInit(). The initialized structure can remain unchanged in LPSPI_MasterInit(), or can be modified before calling the LPSPI_MasterInit(). Example: code lpspi_master_config_t masterConfig; LPSPI_MasterGetDefaultConfig(&masterConfig); endcode param masterConfig pointer to lpspi_master_config_t structure

Definition at line 249 of file fsl_lpspi.c.

250{
251 assert(masterConfig);
252
253 /* Initializes the configure structure to zero. */
254 memset(masterConfig, 0, sizeof(*masterConfig));
255
256 masterConfig->baudRate = 500000;
257 masterConfig->bitsPerFrame = 8;
258 masterConfig->cpol = kLPSPI_ClockPolarityActiveHigh;
259 masterConfig->cpha = kLPSPI_ClockPhaseFirstEdge;
260 masterConfig->direction = kLPSPI_MsbFirst;
261
262 masterConfig->pcsToSckDelayInNanoSec = 1000000000 / masterConfig->baudRate * 2;
263 masterConfig->lastSckToPcsDelayInNanoSec = 1000000000 / masterConfig->baudRate * 2;
264 masterConfig->betweenTransferDelayInNanoSec = 1000000000 / masterConfig->baudRate * 2;
265
266 masterConfig->whichPcs = kLPSPI_Pcs0;
268
269 masterConfig->pinCfg = kLPSPI_SdiInSdoOut;
270 masterConfig->dataOutConfig = kLpspiDataOutRetained;
271}
lpspi_pcs_polarity_config_t pcsActiveHighOrLow
Definition fsl_lpspi.h:272
lpspi_shift_direction_t direction
Definition fsl_lpspi.h:261
lpspi_data_out_config_t dataOutConfig
Definition fsl_lpspi.h:277
lpspi_clock_phase_t cpha
Definition fsl_lpspi.h:260
uint32_t betweenTransferDelayInNanoSec
Definition fsl_lpspi.h:268
uint32_t lastSckToPcsDelayInNanoSec
Definition fsl_lpspi.h:265
lpspi_which_pcs_t whichPcs
Definition fsl_lpspi.h:271
uint32_t pcsToSckDelayInNanoSec
Definition fsl_lpspi.h:263
lpspi_clock_polarity_t cpol
Definition fsl_lpspi.h:259
lpspi_pin_config_t pinCfg
Definition fsl_lpspi.h:274

Referenced by spi_lld_start().

Here is the caller graph for this function:

◆ LPSPI_MasterInit()

void LPSPI_MasterInit ( LPSPI_Type *  base,
const lpspi_master_config_t masterConfig,
uint32_t  srcClock_Hz 
)

Initializes the LPSPI master.

Parameters
baseLPSPI peripheral address.
masterConfigPointer to structure lpspi_master_config_t.
srcClock_HzModule source input clock in Hertz

brief Initializes the LPSPI master.

param base LPSPI peripheral address. param masterConfig Pointer to structure lpspi_master_config_t. param srcClock_Hz Module source input clock in Hertz

Definition at line 187 of file fsl_lpspi.c.

188{
189 assert(masterConfig);
190
191 uint32_t tcrPrescaleValue = 0;
192
193#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
194
195 uint32_t instance = LPSPI_GetInstance(base);
196 /* Enable LPSPI clock */
198
199#if defined(LPSPI_PERIPH_CLOCKS)
201#endif
202
203#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
204
205 /* Set LPSPI to master */
207
208 /* Set specific PCS to active high or low */
209 LPSPI_SetOnePcsPolarity(base, masterConfig->whichPcs, masterConfig->pcsActiveHighOrLow);
210
211 /* Set Configuration Register 1 related setting.*/
212 base->CFGR1 = (base->CFGR1 & ~(LPSPI_CFGR1_OUTCFG_MASK | LPSPI_CFGR1_PINCFG_MASK | LPSPI_CFGR1_NOSTALL_MASK)) |
213 LPSPI_CFGR1_OUTCFG(masterConfig->dataOutConfig) | LPSPI_CFGR1_PINCFG(masterConfig->pinCfg) |
214 LPSPI_CFGR1_NOSTALL(0);
215
216 /* Set baudrate and delay times*/
217 LPSPI_MasterSetBaudRate(base, masterConfig->baudRate, srcClock_Hz, &tcrPrescaleValue);
218
219 /* Set default watermarks */
221
222 /* Set Transmit Command Register*/
223 base->TCR = LPSPI_TCR_CPOL(masterConfig->cpol) | LPSPI_TCR_CPHA(masterConfig->cpha) |
224 LPSPI_TCR_LSBF(masterConfig->direction) | LPSPI_TCR_FRAMESZ(masterConfig->bitsPerFrame - 1) |
225 LPSPI_TCR_PRESCALE(tcrPrescaleValue) | LPSPI_TCR_PCS(masterConfig->whichPcs);
226
227 LPSPI_Enable(base, true);
228
229 LPSPI_MasterSetDelayTimes(base, masterConfig->pcsToSckDelayInNanoSec, kLPSPI_PcsToSck, srcClock_Hz);
232
233 LPSPI_SetDummyData(base, LPSPI_DUMMY_DATA);
234}
@ kLpspiDefaultTxWatermark
Definition fsl_lpspi.c:28
@ kLpspiDefaultRxWatermark
Definition fsl_lpspi.c:29
static void LPSPI_SetOnePcsPolarity(LPSPI_Type *base, lpspi_which_pcs_t pcs, lpspi_pcs_polarity_config_t activeLowOrHigh)
Configures the LPSPI peripheral chip select polarity.
Definition fsl_lpspi.c:385
static void CLOCK_EnableClock(clock_ip_name_t name)
Enable the clock for specific IP.
Definition fsl_clock.h:641
void LPSPI_SetDummyData(LPSPI_Type *base, uint8_t dummyData)
Set up the dummy data.
Definition fsl_lpspi.c:174
static void LPSPI_SetMasterSlaveMode(LPSPI_Type *base, lpspi_master_slave_mode_t mode)
Configures the LPSPI for either master or slave.
Definition fsl_lpspi.h:720
uint32_t LPSPI_MasterSetDelayTimes(LPSPI_Type *base, uint32_t delayTimeInNanoSec, lpspi_delay_type_t whichDelay, uint32_t srcClock_Hz)
Calculates the delay based on the desired delay input in nanoseconds (module must be disabled to chan...
Definition fsl_lpspi.c:567
uint32_t LPSPI_MasterSetBaudRate(LPSPI_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz, uint32_t *tcrPrescaleValue)
Sets the LPSPI baud rate in bits per second.
Definition fsl_lpspi.c:420
static void LPSPI_Enable(LPSPI_Type *base, bool enable)
Enables the LPSPI peripheral and sets the MCR MDIS to 0.
Definition fsl_lpspi.h:491
static void LPSPI_SetFifoWatermarks(LPSPI_Type *base, uint32_t txWater, uint32_t rxWater)
Sets the transmit and receive FIFO watermark values.
Definition fsl_lpspi.h:759

Referenced by spi_lld_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_MasterSetBaudRate()

uint32_t LPSPI_MasterSetBaudRate ( LPSPI_Type *  base,
uint32_t  baudRate_Bps,
uint32_t  srcClock_Hz,
uint32_t *  tcrPrescaleValue 
)

Sets the LPSPI baud rate in bits per second.

This function takes in the desired bitsPerSec (baud rate) and calculates the nearest possible baud rate without exceeding the desired baud rate and returns the calculated baud rate in bits-per-second. It requires the caller to provide the frequency of the module source clock (in Hertz). Note that the baud rate does not go into effect until the Transmit Control Register (TCR) is programmed with the prescale value. Hence, this function returns the prescale tcrPrescaleValue parameter for later programming in the TCR. The higher level peripheral driver should alert the user of an out of range baud rate input.

Note that the LPSPI module must first be disabled before configuring this. Note that the LPSPI module must be configured for master mode before configuring this.

Parameters
baseLPSPI peripheral address.
baudRate_BpsThe desired baud rate in bits per second.
srcClock_HzModule source input clock in Hertz.
tcrPrescaleValueThe TCR prescale value needed to program the TCR.
Returns
The actual calculated baud rate. This function may also return a "0" if the LPSPI is not configured for master mode or if the LPSPI module is not disabled.

brief Sets the LPSPI baud rate in bits per second.

This function takes in the desired bitsPerSec (baud rate) and calculates the nearest possible baud rate without exceeding the desired baud rate and returns the calculated baud rate in bits-per-second. It requires the caller to provide the frequency of the module source clock (in Hertz). Note that the baud rate does not go into effect until the Transmit Control Register (TCR) is programmed with the prescale value. Hence, this function returns the prescale tcrPrescaleValue parameter for later programming in the TCR. The higher level peripheral driver should alert the user of an out of range baud rate input.

Note that the LPSPI module must first be disabled before configuring this. Note that the LPSPI module must be configured for master mode before configuring this.

param base LPSPI peripheral address. param baudRate_Bps The desired baud rate in bits per second. param srcClock_Hz Module source input clock in Hertz. param tcrPrescaleValue The TCR prescale value needed to program the TCR. return The actual calculated baud rate. This function may also return a "0" if the LPSPI is not configured for master mode or if the LPSPI module is not disabled.

Definition at line 420 of file fsl_lpspi.c.

424{
425 assert(tcrPrescaleValue);
426
427 /* For master mode configuration only, if slave mode detected, return 0.
428 * Also, the LPSPI module needs to be disabled first, if enabled, return 0
429 */
430 if ((!LPSPI_IsMaster(base)) || (base->CR & LPSPI_CR_MEN_MASK))
431 {
432 return 0;
433 }
434
435 uint32_t prescaler, bestPrescaler;
436 uint32_t scaler, bestScaler;
437 uint32_t realBaudrate, bestBaudrate;
438 uint32_t diff, min_diff;
439 uint32_t desiredBaudrate = baudRate_Bps;
440
441 /* find combination of prescaler and scaler resulting in baudrate closest to the
442 * requested value
443 */
444 min_diff = 0xFFFFFFFFU;
445
446 /* Set to maximum divisor value bit settings so that if baud rate passed in is less
447 * than the minimum possible baud rate, then the SPI will be configured to the lowest
448 * possible baud rate
449 */
450 bestPrescaler = 7;
451 bestScaler = 255;
452
453 bestBaudrate = 0; /* required to avoid compilation warning */
454
455 /* In all for loops, if min_diff = 0, the exit for loop*/
456 for (prescaler = 0; (prescaler < 8) && min_diff; prescaler++)
457 {
458 for (scaler = 0; (scaler < 256) && min_diff; scaler++)
459 {
460 realBaudrate = (srcClock_Hz / (s_baudratePrescaler[prescaler] * (scaler + 2U)));
461
462 /* calculate the baud rate difference based on the conditional statement
463 * that states that the calculated baud rate must not exceed the desired baud rate
464 */
465 if (desiredBaudrate >= realBaudrate)
466 {
467 diff = desiredBaudrate - realBaudrate;
468 if (min_diff > diff)
469 {
470 /* a better match found */
471 min_diff = diff;
472 bestPrescaler = prescaler;
473 bestScaler = scaler;
474 bestBaudrate = realBaudrate;
475 }
476 }
477 }
478 }
479
480 /* Write the best baud rate scalar to the CCR.
481 * Note, no need to check for error since we've already checked to make sure the module is
482 * disabled and in master mode. Also, there is a limit on the maximum divider so we will not
483 * exceed this.
484 */
485 base->CCR = (base->CCR & ~LPSPI_CCR_SCKDIV_MASK) | LPSPI_CCR_SCKDIV(bestScaler);
486
487 /* return the best prescaler value for user to use later */
488 *tcrPrescaleValue = bestPrescaler;
489
490 /* return the actual calculated baud rate */
491 return bestBaudrate;
492}
static const uint8_t s_baudratePrescaler[]
Definition fsl_lpspi.c:116
static bool LPSPI_IsMaster(LPSPI_Type *base)
Returns whether the LPSPI module is in master mode.
Definition fsl_lpspi.h:731

Referenced by LPSPI_MasterInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_MasterSetDelayScaler()

void LPSPI_MasterSetDelayScaler ( LPSPI_Type *  base,
uint32_t  scaler,
lpspi_delay_type_t  whichDelay 
)

Manually configures a specific LPSPI delay parameter (module must be disabled to change the delay values).

This function configures the following: SCK to PCS delay, or PCS to SCK delay, or The configurations must occur between the transfer delay.

The delay names are available in type lpspi_delay_type_t.

The user passes the desired delay along with the delay value. This allows the user to directly set the delay values if they have pre-calculated them or if they simply wish to manually increment the value.

Note that the LPSPI module must first be disabled before configuring this. Note that the LPSPI module must be configured for master mode before configuring this.

Parameters
baseLPSPI peripheral address.
scalerThe 8-bit delay value 0x00 to 0xFF (255).
whichDelayThe desired delay to configure, must be of type lpspi_delay_type_t.

brief Manually configures a specific LPSPI delay parameter (module must be disabled to change the delay values).

This function configures the following: SCK to PCS delay, or PCS to SCK delay, or The configurations must occur between the transfer delay.

The delay names are available in type lpspi_delay_type_t.

The user passes the desired delay along with the delay value. This allows the user to directly set the delay values if they have pre-calculated them or if they simply wish to manually increment the value.

Note that the LPSPI module must first be disabled before configuring this. Note that the LPSPI module must be configured for master mode before configuring this.

param base LPSPI peripheral address. param scaler The 8-bit delay value 0x00 to 0xFF (255). param whichDelay The desired delay to configure, must be of type lpspi_delay_type_t.

Definition at line 516 of file fsl_lpspi.c.

517{
518 /*These settings are only relevant in master mode */
519 switch (whichDelay)
520 {
521 case kLPSPI_PcsToSck:
522 base->CCR = (base->CCR & (~LPSPI_CCR_PCSSCK_MASK)) | LPSPI_CCR_PCSSCK(scaler);
523
524 break;
526 base->CCR = (base->CCR & (~LPSPI_CCR_SCKPCS_MASK)) | LPSPI_CCR_SCKPCS(scaler);
527
528 break;
530 base->CCR = (base->CCR & (~LPSPI_CCR_DBT_MASK)) | LPSPI_CCR_DBT(scaler);
531
532 break;
533 default:
534 assert(false);
535 break;
536 }
537}

Referenced by LPSPI_MasterSetDelayTimes().

Here is the caller graph for this function:

◆ LPSPI_MasterSetDelayTimes()

uint32_t LPSPI_MasterSetDelayTimes ( LPSPI_Type *  base,
uint32_t  delayTimeInNanoSec,
lpspi_delay_type_t  whichDelay,
uint32_t  srcClock_Hz 
)

Calculates the delay based on the desired delay input in nanoseconds (module must be disabled to change the delay values).

This function calculates the values for the following: SCK to PCS delay, or PCS to SCK delay, or The configurations must occur between the transfer delay.

The delay names are available in type lpspi_delay_type_t.

The user passes the desired delay and the desired delay value in nano-seconds. The function calculates the value needed for the desired delay parameter and returns the actual calculated delay because an exact delay match may not be possible. In this case, the closest match is calculated without going below the desired delay value input. It is possible to input a very large delay value that exceeds the capability of the part, in which case the maximum supported delay is returned. It is up to the higher level peripheral driver to alert the user of an out of range delay input.

Note that the LPSPI module must be configured for master mode before configuring this. And note that the delayTime = LPSPI_clockSource / (PRESCALE * Delay_scaler).

Parameters
baseLPSPI peripheral address.
delayTimeInNanoSecThe desired delay value in nano-seconds.
whichDelayThe desired delay to configuration, which must be of type lpspi_delay_type_t.
srcClock_HzModule source input clock in Hertz.
Returns
actual Calculated delay value in nano-seconds.

brief Calculates the delay based on the desired delay input in nanoseconds (module must be disabled to change the delay values).

This function calculates the values for the following: SCK to PCS delay, or PCS to SCK delay, or The configurations must occur between the transfer delay.

The delay names are available in type lpspi_delay_type_t.

The user passes the desired delay and the desired delay value in nano-seconds. The function calculates the value needed for the desired delay parameter and returns the actual calculated delay because an exact delay match may not be possible. In this case, the closest match is calculated without going below the desired delay value input. It is possible to input a very large delay value that exceeds the capability of the part, in which case the maximum supported delay is returned. It is up to the higher level peripheral driver to alert the user of an out of range delay input.

Note that the LPSPI module must be configured for master mode before configuring this. And note that the delayTime = LPSPI_clockSource / (PRESCALE * Delay_scaler).

param base LPSPI peripheral address. param delayTimeInNanoSec The desired delay value in nano-seconds. param whichDelay The desired delay to configuration, which must be of type lpspi_delay_type_t. param srcClock_Hz Module source input clock in Hertz. return actual Calculated delay value in nano-seconds.

Definition at line 567 of file fsl_lpspi.c.

571{
572 uint64_t realDelay, bestDelay;
573 uint32_t scaler, bestScaler;
574 uint32_t diff, min_diff;
575 uint64_t initialDelayNanoSec;
576 uint32_t clockDividedPrescaler;
577
578 /* For delay between transfer, an additional scaler value is needed */
579 uint32_t additionalScaler = 0;
580
581 /*As the RM note, the LPSPI baud rate clock is itself divided by the PRESCALE setting, which can vary between
582 * transfers.*/
583 clockDividedPrescaler =
584 srcClock_Hz / s_baudratePrescaler[(base->TCR & LPSPI_TCR_PRESCALE_MASK) >> LPSPI_TCR_PRESCALE_SHIFT];
585
586 /* Find combination of prescaler and scaler resulting in the delay closest to the requested value.*/
587 min_diff = 0xFFFFFFFFU;
588
589 /* Initialize scaler to max value to generate the max delay */
590 bestScaler = 0xFFU;
591
592 /* Calculate the initial (min) delay and maximum possible delay based on the specific delay as
593 * the delay divisors are slightly different based on which delay we are configuring.
594 */
595 if (whichDelay == kLPSPI_BetweenTransfer)
596 {
597 /* First calculate the initial, default delay, note min delay is 2 clock cycles. Due to large size of
598 calculated values (uint64_t), we need to break up the calculation into several steps to ensure
599 accurate calculated results
600 */
601 initialDelayNanoSec = 1000000000U;
602 initialDelayNanoSec *= 2U;
603 initialDelayNanoSec /= clockDividedPrescaler;
604
605 /* Calculate the maximum delay */
606 bestDelay = 1000000000U;
607 bestDelay *= 257U; /* based on DBT+2, or 255 + 2 */
608 bestDelay /= clockDividedPrescaler;
609
610 additionalScaler = 1U;
611 }
612 else
613 {
614 /* First calculate the initial, default delay, min delay is 1 clock cycle. Due to large size of calculated
615 values (uint64_t), we need to break up the calculation into several steps to ensure accurate calculated
616 results.
617 */
618 initialDelayNanoSec = 1000000000U;
619 initialDelayNanoSec /= clockDividedPrescaler;
620
621 /* Calculate the maximum delay */
622 bestDelay = 1000000000U;
623 bestDelay *= 256U; /* based on SCKPCS+1 or PCSSCK+1, or 255 + 1 */
624 bestDelay /= clockDividedPrescaler;
625
626 additionalScaler = 0;
627 }
628
629 /* If the initial, default delay is already greater than the desired delay, then
630 * set the delay to their initial value (0) and return the delay. In other words,
631 * there is no way to decrease the delay value further.
632 */
633 if (initialDelayNanoSec >= delayTimeInNanoSec)
634 {
635 LPSPI_MasterSetDelayScaler(base, 0, whichDelay);
636 return initialDelayNanoSec;
637 }
638
639 /* If min_diff = 0, the exit for loop */
640 for (scaler = 0; (scaler < 256U) && min_diff; scaler++)
641 {
642 /* Calculate the real delay value as we cycle through the scaler values.
643 Due to large size of calculated values (uint64_t), we need to break up the
644 calculation into several steps to ensure accurate calculated results
645 */
646 realDelay = 1000000000U;
647 realDelay *= (scaler + 1 + additionalScaler);
648 realDelay /= clockDividedPrescaler;
649
650 /* calculate the delay difference based on the conditional statement
651 * that states that the calculated delay must not be less then the desired delay
652 */
653 if (realDelay >= delayTimeInNanoSec)
654 {
655 diff = realDelay - delayTimeInNanoSec;
656 if (min_diff > diff)
657 {
658 /* a better match found */
659 min_diff = diff;
660 bestScaler = scaler;
661 bestDelay = realDelay;
662 }
663 }
664 }
665
666 /* write the best scaler value for the delay */
667 LPSPI_MasterSetDelayScaler(base, bestScaler, whichDelay);
668
669 /* return the actual calculated delay value (in ns) */
670 return bestDelay;
671}
void LPSPI_MasterSetDelayScaler(LPSPI_Type *base, uint32_t scaler, lpspi_delay_type_t whichDelay)
Manually configures a specific LPSPI delay parameter (module must be disabled to change the delay val...
Definition fsl_lpspi.c:516

Referenced by LPSPI_MasterInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_MasterTransferAbort()

void LPSPI_MasterTransferAbort ( LPSPI_Type *  base,
lpspi_master_handle_t handle 
)

LPSPI master abort transfer which uses an interrupt method.

This function aborts a transfer which uses an interrupt method.

Parameters
baseLPSPI peripheral address.
handlepointer to lpspi_master_handle_t structure which stores the transfer state.

brief LPSPI master abort transfer which uses an interrupt method.

This function aborts a transfer which uses an interrupt method.

param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state.

Definition at line 1235 of file fsl_lpspi.c.

1236{
1237 assert(handle);
1238
1239 /* Disable interrupt requests*/
1241
1242 LPSPI_Reset(base);
1243
1244 handle->state = kLPSPI_Idle;
1245 handle->txRemainingByteCount = 0;
1246 handle->rxRemainingByteCount = 0;
1247}
volatile uint8_t state
Definition fsl_lpspi.h:375
volatile size_t txRemainingByteCount
Definition fsl_lpspi.h:365
volatile size_t rxRemainingByteCount
Definition fsl_lpspi.h:366
Here is the call graph for this function:

◆ LPSPI_MasterTransferBlocking()

status_t LPSPI_MasterTransferBlocking ( LPSPI_Type *  base,
lpspi_transfer_t transfer 
)

LPSPI master transfer data using a polling method.

This function transfers data using a polling method. This is a blocking function, which does not return until all transfers have been completed.

Note: The transfer data size should be integer multiples of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not integer multiples of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

Parameters
baseLPSPI peripheral address.
transferpointer to lpspi_transfer_t structure.
Returns
status of status_t.

brief LPSPI master transfer data using a polling method.

This function transfers data using a polling method. This is a blocking function, which does not return until all transfers have been completed.

Note: The transfer data size should be integer multiples of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not integer multiples of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

param base LPSPI peripheral address. param transfer pointer to lpspi_transfer_t structure. return status of status_t.

Definition at line 779 of file fsl_lpspi.c.

780{
781 assert(transfer);
782
783 uint32_t bitsPerFrame = ((base->TCR & LPSPI_TCR_FRAMESZ_MASK) >> LPSPI_TCR_FRAMESZ_SHIFT) + 1;
784 uint32_t bytesPerFrame = (bitsPerFrame + 7) / 8;
785 uint32_t temp = 0U;
786 uint8_t dummyData = g_lpspiDummyData[LPSPI_GetInstance(base)];
787
788 if (!LPSPI_CheckTransferArgument(transfer, bitsPerFrame, bytesPerFrame))
789 {
791 }
792
793 /* Check that LPSPI is not busy.*/
795 {
796 return kStatus_LPSPI_Busy;
797 }
798
799 uint8_t *txData = transfer->txData;
800 uint8_t *rxData = transfer->rxData;
801 uint32_t txRemainingByteCount = transfer->dataSize;
802 uint32_t rxRemainingByteCount = transfer->dataSize;
803
804 uint8_t bytesEachWrite;
805 uint8_t bytesEachRead;
806
807 uint32_t readData = 0;
808 uint32_t wordToSend =
809 ((uint32_t)dummyData) | ((uint32_t)dummyData << 8) | ((uint32_t)dummyData << 16) | ((uint32_t)dummyData << 24);
810
811 /*The TX and RX FIFO sizes are always the same*/
812 uint32_t fifoSize = LPSPI_GetRxFifoSize(base);
813
814 uint32_t whichPcs = (transfer->configFlags & LPSPI_MASTER_PCS_MASK) >> LPSPI_MASTER_PCS_SHIFT;
815
816 bool isPcsContinuous = (bool)(transfer->configFlags & kLPSPI_MasterPcsContinuous);
817 bool isRxMask = false;
818 bool isByteSwap = (bool)(transfer->configFlags & kLPSPI_MasterByteSwap);
819
820 LPSPI_FlushFifo(base, true, true);
822
823 if (!rxData)
824 {
825 isRxMask = true;
826 }
827
828 LPSPI_Enable(base, false);
829 base->CFGR1 &= (~LPSPI_CFGR1_NOSTALL_MASK);
830 /* Check if using 3-wire mode and the txData is NULL, set the output pin to tristated. */
831 temp = base->CFGR1;
832 temp &= LPSPI_CFGR1_PINCFG_MASK;
833 if ((temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdiInSdiOut)) || (temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdoInSdoOut)))
834 {
835 if (!txData)
836 {
837 base->CFGR1 |= LPSPI_CFGR1_OUTCFG_MASK;
838 }
839 /* The 3-wire mode can't send and receive data at the same time. */
840 if ((txData) && (rxData))
841 {
843 }
844 }
845 LPSPI_Enable(base, true);
846
847 base->TCR =
848 (base->TCR & ~(LPSPI_TCR_CONT_MASK | LPSPI_TCR_CONTC_MASK | LPSPI_TCR_RXMSK_MASK | LPSPI_TCR_PCS_MASK)) |
849 LPSPI_TCR_CONT(isPcsContinuous) | LPSPI_TCR_CONTC(0) | LPSPI_TCR_RXMSK(isRxMask) | LPSPI_TCR_PCS(whichPcs);
850
851 if (bytesPerFrame <= 4)
852 {
853 bytesEachWrite = bytesPerFrame;
854 bytesEachRead = bytesPerFrame;
855 }
856 else
857 {
858 bytesEachWrite = 4;
859 bytesEachRead = 4;
860 }
861
862 /*Write the TX data until txRemainingByteCount is equal to 0 */
863 while (txRemainingByteCount > 0)
864 {
865 if (txRemainingByteCount < bytesEachWrite)
866 {
867 bytesEachWrite = txRemainingByteCount;
868 }
869
870 /*Wait until TX FIFO is not full*/
871 while (LPSPI_GetTxFifoCount(base) == fifoSize)
872 {
873 }
874
875 if (txData)
876 {
877 wordToSend = LPSPI_CombineWriteData(txData, bytesEachWrite, isByteSwap);
878 txData += bytesEachWrite;
879 }
880
881 LPSPI_WriteData(base, wordToSend);
882 txRemainingByteCount -= bytesEachWrite;
883
884 /*Check whether there is RX data in RX FIFO . Read out the RX data so that the RX FIFO would not overrun.*/
885 if (rxData)
886 {
887 while (LPSPI_GetRxFifoCount(base))
888 {
889 readData = LPSPI_ReadData(base);
890 if (rxRemainingByteCount < bytesEachRead)
891 {
892 bytesEachRead = rxRemainingByteCount;
893 }
894
895 LPSPI_SeparateReadData(rxData, readData, bytesEachRead, isByteSwap);
896 rxData += bytesEachRead;
897
898 rxRemainingByteCount -= bytesEachRead;
899 }
900 }
901 }
902
903 /* After write all the data in TX FIFO , should write the TCR_CONTC to 0 to de-assert the PCS. Note that TCR
904 * register also use the TX FIFO.
905 */
906 while ((LPSPI_GetTxFifoCount(base) == fifoSize))
907 {
908 }
909 base->TCR = (base->TCR & ~(LPSPI_TCR_CONTC_MASK));
910
911 /*Read out the RX data in FIFO*/
912 if (rxData)
913 {
914 while (rxRemainingByteCount > 0)
915 {
916 while (LPSPI_GetRxFifoCount(base))
917 {
918 readData = LPSPI_ReadData(base);
919
920 if (rxRemainingByteCount < bytesEachRead)
921 {
922 bytesEachRead = rxRemainingByteCount;
923 }
924
925 LPSPI_SeparateReadData(rxData, readData, bytesEachRead, isByteSwap);
926 rxData += bytesEachRead;
927
928 rxRemainingByteCount -= bytesEachRead;
929 }
930 }
931 }
932 else
933 {
934 /* If no RX buffer, then transfer is not complete until transfer complete flag sets */
936 {
937 }
938 }
939
940 return kStatus_Success;
941}
static void LPSPI_SeparateReadData(uint8_t *rxData, uint32_t readData, uint32_t bytesEachRead, bool isByteSwap)
Separate the read data for 1 byte to 4 bytes. This is not a public API.
Definition fsl_lpspi.c:1896
static uint32_t LPSPI_CombineWriteData(uint8_t *txData, uint32_t bytesEachWrite, bool isByteSwap)
Combine the write data for 1 byte to 4 bytes. This is not a public API.
Definition fsl_lpspi.c:1812
@ kStatus_Success
Definition fsl_common.h:159
@ kStatus_InvalidArgument
Definition fsl_common.h:163
static uint32_t LPSPI_GetRxFifoSize(LPSPI_Type *base)
Gets the LPSPI Rx FIFO size.
Definition fsl_lpspi.h:537
static void LPSPI_FlushFifo(LPSPI_Type *base, bool flushTxFifo, bool flushRxFifo)
Flushes the LPSPI FIFOs.
Definition fsl_lpspi.h:743
static uint32_t LPSPI_GetStatusFlags(LPSPI_Type *base)
Gets the LPSPI status flag state.
Definition fsl_lpspi.h:517
volatile uint8_t g_lpspiDummyData[ARRAY_SIZE(s_lpspiBases)]
Global variable for dummy data value setting.
Definition fsl_lpspi.c:142
static uint32_t LPSPI_ReadData(LPSPI_Type *base)
Reads data from the data buffer.
Definition fsl_lpspi.h:918
static uint32_t LPSPI_GetTxFifoCount(LPSPI_Type *base)
Gets the LPSPI Tx FIFO count.
Definition fsl_lpspi.h:547
bool LPSPI_CheckTransferArgument(lpspi_transfer_t *transfer, uint32_t bitsPerFrame, uint32_t bytesPerFrame)
Check the argument for transfer .
Definition fsl_lpspi.c:713
static void LPSPI_WriteData(LPSPI_Type *base, uint32_t data)
Writes data into the transmit data buffer.
Definition fsl_lpspi.h:904
static uint32_t LPSPI_GetRxFifoCount(LPSPI_Type *base)
Gets the LPSPI Rx FIFO count.
Definition fsl_lpspi.h:557
uint32_t configFlags
Definition fsl_lpspi.h:343

Referenced by spi_lld_polled_exchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_MasterTransferCreateHandle()

void LPSPI_MasterTransferCreateHandle ( LPSPI_Type *  base,
lpspi_master_handle_t handle,
lpspi_master_transfer_callback_t  callback,
void *  userData 
)

Initializes the LPSPI master handle.

This function initializes the LPSPI handle, which can be used for other LPSPI transactional APIs. Usually, for a specified LPSPI instance, call this API once to get the initialized handle.

Parameters
baseLPSPI peripheral address.
handleLPSPI handle pointer to lpspi_master_handle_t.
callbackDSPI callback.
userDatacallback function parameter.

brief Initializes the LPSPI master handle.

This function initializes the LPSPI handle, which can be used for other LPSPI transactional APIs. Usually, for a specified LPSPI instance, call this API once to get the initialized handle.

param base LPSPI peripheral address. param handle LPSPI handle pointer to lpspi_master_handle_t. param callback DSPI callback. param userData callback function parameter.

Definition at line 686 of file fsl_lpspi.c.

690{
691 assert(handle);
692
693 /* Zero the handle. */
694 memset(handle, 0, sizeof(*handle));
695
696 s_lpspiHandle[LPSPI_GetInstance(base)] = handle;
697
698 /* Set irq handler. */
700
701 handle->callback = callback;
702 handle->userData = userData;
703}
static void * s_lpspiHandle[ARRAY_SIZE(s_lpspiBases)]
Pointers to lpspi handles for each instance.
Definition fsl_lpspi.c:135
static lpspi_master_isr_t s_lpspiMasterIsr
Pointer to master IRQ handler for each instance.
Definition fsl_lpspi.c:138
void LPSPI_MasterTransferHandleIRQ(LPSPI_Type *base, lpspi_master_handle_t *handle)
LPSPI Master IRQ handler function.
Definition fsl_lpspi.c:1257
lpspi_master_transfer_callback_t callback
Definition fsl_lpspi.h:377

Referenced by spi_lld_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_MasterTransferGetCount()

status_t LPSPI_MasterTransferGetCount ( LPSPI_Type *  base,
lpspi_master_handle_t handle,
size_t count 
)

Gets the master transfer remaining bytes.

This function gets the master transfer remaining bytes.

Parameters
baseLPSPI peripheral address.
handlepointer to lpspi_master_handle_t structure which stores the transfer state.
countNumber of bytes transferred so far by the non-blocking transaction.
Returns
status of status_t.

brief Gets the master transfer remaining bytes.

This function gets the master transfer remaining bytes.

param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. return status of status_t.

Definition at line 1195 of file fsl_lpspi.c.

1196{
1197 assert(handle);
1198
1199 if (!count)
1200 {
1202 }
1203
1204 /* Catch when there is not an active transfer. */
1205 if (handle->state != kLPSPI_Busy)
1206 {
1207 *count = 0;
1209 }
1210
1211 size_t remainingByte;
1212
1213 if (handle->rxData)
1214 {
1215 remainingByte = handle->rxRemainingByteCount;
1216 }
1217 else
1218 {
1219 remainingByte = handle->txRemainingByteCount;
1220 }
1221
1222 *count = handle->totalByteCount - remainingByte;
1223
1224 return kStatus_Success;
1225}
@ kStatus_NoTransferInProgress
Definition fsl_common.h:165
uint8_t *volatile rxData
Definition fsl_lpspi.h:364
uint32_t totalByteCount
Definition fsl_lpspi.h:371
uint16_t count
Definition tunerstudio.h:1

◆ LPSPI_MasterTransferHandleIRQ()

void LPSPI_MasterTransferHandleIRQ ( LPSPI_Type *  base,
lpspi_master_handle_t handle 
)

LPSPI Master IRQ handler function.

This function processes the LPSPI transmit and receive IRQ.

Parameters
baseLPSPI peripheral address.
handlepointer to lpspi_master_handle_t structure which stores the transfer state.

brief LPSPI Master IRQ handler function.

This function processes the LPSPI transmit and receive IRQ.

param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state.

Definition at line 1257 of file fsl_lpspi.c.

1258{
1259 assert(handle);
1260
1261 uint32_t readData;
1262
1263 if (handle->rxData != NULL)
1264 {
1265 if (handle->rxRemainingByteCount)
1266 {
1267 /* First, disable the interrupts to avoid potentially triggering another interrupt
1268 * while reading out the RX FIFO as more data may be coming into the RX FIFO. We'll
1269 * re-enable the interrupts based on the LPSPI state after reading out the FIFO.
1270 */
1272
1273 while ((LPSPI_GetRxFifoCount(base)) && (handle->rxRemainingByteCount))
1274 {
1275 /*Read out the data*/
1276 readData = LPSPI_ReadData(base);
1277
1278 /*Decrease the read RX register times.*/
1279 --handle->readRegRemainingTimes;
1280
1281 if (handle->rxRemainingByteCount < handle->bytesEachRead)
1282 {
1283 handle->bytesEachRead = handle->rxRemainingByteCount;
1284 }
1285
1286 LPSPI_SeparateReadData(handle->rxData, readData, handle->bytesEachRead, handle->isByteSwap);
1287 handle->rxData += handle->bytesEachRead;
1288
1289 /*Decrease the remaining RX byte count.*/
1290 handle->rxRemainingByteCount -= handle->bytesEachRead;
1291 }
1292
1293 /* Re-enable the interrupts only if rxCount indicates there is more data to receive,
1294 * else we may get a spurious interrupt.
1295 * */
1296 if (handle->rxRemainingByteCount)
1297 {
1298 /* Set the TDF and RDF interrupt enables simultaneously to avoid race conditions */
1300 }
1301 }
1302
1303 /*Set rxWatermark to (readRegRemainingTimes-1) if readRegRemainingTimes less than rxWatermark. Otherwise there
1304 *is not RX interrupt for the last datas because the RX count is not greater than rxWatermark.
1305 */
1306 if ((handle->readRegRemainingTimes) <= (handle->rxWatermark))
1307 {
1308 base->FCR =
1309 (base->FCR & (~LPSPI_FCR_RXWATER_MASK)) |
1310 LPSPI_FCR_RXWATER((handle->readRegRemainingTimes > 1) ? (handle->readRegRemainingTimes - 1U) : (0U));
1311 }
1312 }
1313
1314 if (handle->txRemainingByteCount)
1315 {
1317 }
1318 else
1319 {
1320 if ((LPSPI_GetTxFifoCount(base) < (handle->fifoSize)))
1321 {
1322 if ((handle->isPcsContinuous) && (handle->writeTcrInIsr))
1323 {
1324 base->TCR = (base->TCR & ~(LPSPI_TCR_CONTC_MASK));
1325 handle->writeTcrInIsr = false;
1326 }
1327 }
1328 }
1329
1330 if ((handle->txRemainingByteCount == 0) && (handle->rxRemainingByteCount == 0) && (!handle->writeTcrInIsr))
1331 {
1332 /* If no RX buffer, then transfer is not complete until transfer complete flag sets */
1333 if (handle->rxData == NULL)
1334 {
1336 {
1337 /* Complete the transfer and disable the interrupts */
1338 LPSPI_MasterTransferComplete(base, handle);
1339 }
1340 else
1341 {
1344 }
1345 }
1346 else
1347 {
1348 /* Complete the transfer and disable the interrupts */
1349 LPSPI_MasterTransferComplete(base, handle);
1350 }
1351 }
1352}
static void LPSPI_MasterTransferComplete(LPSPI_Type *base, lpspi_master_handle_t *handle)
Master finish up a transfer. It would call back if there is callback function and set the state to id...
Definition fsl_lpspi.c:1170
static void LPSPI_MasterTransferFillUpTxFifo(LPSPI_Type *base, lpspi_master_handle_t *handle)
Master fill up the TX FIFO with data. This is not a public API.
Definition fsl_lpspi.c:1110
volatile uint8_t fifoSize
Definition fsl_lpspi.h:356
volatile uint8_t bytesEachRead
Definition fsl_lpspi.h:361
volatile uint8_t rxWatermark
Definition fsl_lpspi.h:358
volatile uint32_t readRegRemainingTimes
Definition fsl_lpspi.h:369
volatile bool writeTcrInIsr
Definition fsl_lpspi.h:352
volatile bool isByteSwap
Definition fsl_lpspi.h:354
volatile bool isPcsContinuous
Definition fsl_lpspi.h:351

Referenced by LPSPI_MasterTransferCreateHandle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_MasterTransferNonBlocking()

status_t LPSPI_MasterTransferNonBlocking ( LPSPI_Type *  base,
lpspi_master_handle_t handle,
lpspi_transfer_t transfer 
)

LPSPI master transfer data using an interrupt method.

This function transfers data using an interrupt method. This is a non-blocking function, which returns right away. When all data is transferred, the callback function is called.

Note: The transfer data size should be integer multiples of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not integer multiples of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

Parameters
baseLPSPI peripheral address.
handlepointer to lpspi_master_handle_t structure which stores the transfer state.
transferpointer to lpspi_transfer_t structure.
Returns
status of status_t.

brief LPSPI master transfer data using an interrupt method.

This function transfers data using an interrupt method. This is a non-blocking function, which returns right away. When all data is transferred, the callback function is called.

Note: The transfer data size should be integer multiples of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not integer multiples of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state. param transfer pointer to lpspi_transfer_t structure. return status of status_t.

Definition at line 961 of file fsl_lpspi.c.

962{
963 assert(handle);
964 assert(transfer);
965
966 uint32_t bitsPerFrame = ((base->TCR & LPSPI_TCR_FRAMESZ_MASK) >> LPSPI_TCR_FRAMESZ_SHIFT) + 1;
967 uint32_t bytesPerFrame = (bitsPerFrame + 7) / 8;
968 uint32_t temp = 0U;
969 uint8_t dummyData = g_lpspiDummyData[LPSPI_GetInstance(base)];
970
971 if (!LPSPI_CheckTransferArgument(transfer, bitsPerFrame, bytesPerFrame))
972 {
974 }
975
976 /* Check that we're not busy.*/
977 if (handle->state == kLPSPI_Busy)
978 {
979 return kStatus_LPSPI_Busy;
980 }
981
982 handle->state = kLPSPI_Busy;
983
984 bool isRxMask = false;
985
986 uint8_t txWatermark;
987
988 uint32_t whichPcs = (transfer->configFlags & LPSPI_MASTER_PCS_MASK) >> LPSPI_MASTER_PCS_SHIFT;
989
990 handle->txData = transfer->txData;
991 handle->rxData = transfer->rxData;
992 handle->txRemainingByteCount = transfer->dataSize;
993 handle->rxRemainingByteCount = transfer->dataSize;
994 handle->totalByteCount = transfer->dataSize;
995
996 handle->writeTcrInIsr = false;
997
998 handle->writeRegRemainingTimes = (transfer->dataSize / bytesPerFrame) * ((bytesPerFrame + 3) / 4);
1000
1001 handle->txBuffIfNull =
1002 ((uint32_t)dummyData) | ((uint32_t)dummyData << 8) | ((uint32_t)dummyData << 16) | ((uint32_t)dummyData << 24);
1003
1004 /*The TX and RX FIFO sizes are always the same*/
1005 handle->fifoSize = LPSPI_GetRxFifoSize(base);
1006
1008 handle->isByteSwap = (bool)(transfer->configFlags & kLPSPI_MasterByteSwap);
1009
1010 /*Set the RX and TX watermarks to reduce the ISR times.*/
1011 if (handle->fifoSize > 1)
1012 {
1013 txWatermark = 1;
1014 handle->rxWatermark = handle->fifoSize - 2;
1015 }
1016 else
1017 {
1018 txWatermark = 0;
1019 handle->rxWatermark = 0;
1020 }
1021
1022 LPSPI_SetFifoWatermarks(base, txWatermark, handle->rxWatermark);
1023
1024 LPSPI_Enable(base, false);
1025 /*Transfers will stall when transmit FIFO is empty or receive FIFO is full. */
1026 base->CFGR1 &= (~LPSPI_CFGR1_NOSTALL_MASK);
1027 /* Check if using 3-wire mode and the txData is NULL, set the output pin to tristated. */
1028 temp = base->CFGR1;
1029 temp &= LPSPI_CFGR1_PINCFG_MASK;
1030 if ((temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdiInSdiOut)) || (temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdoInSdoOut)))
1031 {
1032 if (!handle->txData)
1033 {
1034 base->CFGR1 |= LPSPI_CFGR1_OUTCFG_MASK;
1035 }
1036 /* The 3-wire mode can't send and receive data at the same time. */
1037 if ((handle->txData) && (handle->rxData))
1038 {
1040 }
1041 }
1042 LPSPI_Enable(base, true);
1043
1044 /*Flush FIFO , clear status , disable all the inerrupts.*/
1045 LPSPI_FlushFifo(base, true, true);
1048
1049 /* If there is not rxData , can mask the receive data (receive data is not stored in receive FIFO).
1050 * For master transfer , we'd better not masked the transmit data in TCR since the transfer flow is hard to
1051 * controlled by software.*/
1052 if (handle->rxData == NULL)
1053 {
1054 isRxMask = true;
1055 handle->rxRemainingByteCount = 0;
1056 }
1057
1058 base->TCR =
1059 (base->TCR & ~(LPSPI_TCR_CONT_MASK | LPSPI_TCR_CONTC_MASK | LPSPI_TCR_RXMSK_MASK | LPSPI_TCR_PCS_MASK)) |
1060 LPSPI_TCR_CONT(handle->isPcsContinuous) | LPSPI_TCR_CONTC(0) | LPSPI_TCR_RXMSK(isRxMask) |
1061 LPSPI_TCR_PCS(whichPcs);
1062
1063 /*Calculate the bytes for write/read the TX/RX register each time*/
1064 if (bytesPerFrame <= 4)
1065 {
1066 handle->bytesEachWrite = bytesPerFrame;
1067 handle->bytesEachRead = bytesPerFrame;
1068 }
1069 else
1070 {
1071 handle->bytesEachWrite = 4;
1072 handle->bytesEachRead = 4;
1073 }
1074
1075 /* Enable the NVIC for LPSPI peripheral. Note that below code is useless if the LPSPI interrupt is in INTMUX ,
1076 * and you should also enable the INTMUX interupt in your application.
1077 */
1078 EnableIRQ(s_lpspiIRQ[LPSPI_GetInstance(base)]);
1079
1080 /*TCR is also shared the FIFO , so wait for TCR written.*/
1081 while (LPSPI_GetTxFifoCount(base) != 0)
1082 {
1083 }
1084 /*Fill up the TX data in FIFO */
1086
1087 /* Since SPI is a synchronous interface, we only need to enable the RX interrupt if there is RX data.
1088 * The IRQ handler will get the status of RX and TX interrupt flags.
1089 */
1090 if (handle->rxData)
1091 {
1092 /*Set rxWatermark to (readRegRemainingTimes-1) if readRegRemainingTimes less than rxWatermark. Otherwise there
1093 *is not RX interrupt for the last datas because the RX count is not greater than rxWatermark.
1094 */
1095 if ((handle->readRegRemainingTimes) <= handle->rxWatermark)
1096 {
1097 base->FCR = (base->FCR & (~LPSPI_FCR_RXWATER_MASK)) | LPSPI_FCR_RXWATER(handle->readRegRemainingTimes - 1);
1098 }
1099
1101 }
1102 else
1103 {
1105 }
1106
1107 return kStatus_Success;
1108}
static const IRQn_Type s_lpspiIRQ[]
Pointers to lpspi IRQ number for each instance.
Definition fsl_lpspi.c:122
uint8_t *volatile txData
Definition fsl_lpspi.h:363
volatile uint32_t writeRegRemainingTimes
Definition fsl_lpspi.h:368
volatile uint8_t bytesEachWrite
Definition fsl_lpspi.h:360

Referenced by spi_lld_exchange(), spi_lld_receive(), and spi_lld_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_ReadData()

static uint32_t LPSPI_ReadData ( LPSPI_Type *  base)
inlinestatic

Reads data from the data buffer.

This function reads the data from the Receive Data Register (RDR). This function can be used for either master or slave mode.

Parameters
baseLPSPI peripheral address.
Returns
The data read from the data buffer.

Definition at line 918 of file fsl_lpspi.h.

919{
920 return (base->RDR);
921}

Referenced by EDMA_LpspiMasterCallback(), EDMA_LpspiSlaveCallback(), LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferHandleIRQ(), and LPSPI_SlaveTransferHandleIRQ().

Here is the caller graph for this function:

◆ LPSPI_Reset()

void LPSPI_Reset ( LPSPI_Type *  base)

Restores the LPSPI peripheral to reset state. Note that this function sets all registers to reset state. As a result, the LPSPI module can't work after calling this API.

Parameters
baseLPSPI peripheral address.

brief Restores the LPSPI peripheral to reset state. Note that this function sets all registers to reset state. As a result, the LPSPI module can't work after calling this API. param base LPSPI peripheral address.

Definition at line 351 of file fsl_lpspi.c.

352{
353 /* Reset all internal logic and registers, except the Control Register. Remains set until cleared by software.*/
354 base->CR |= LPSPI_CR_RST_MASK;
355
356 /* Software reset doesn't reset the CR, so manual reset the FIFOs */
357 base->CR |= LPSPI_CR_RRF_MASK | LPSPI_CR_RTF_MASK;
358
359 /* Master logic is not reset and module is disabled.*/
360 base->CR = 0x00U;
361}

Referenced by LPSPI_Deinit(), LPSPI_MasterTransferAbort(), and LPSPI_SlaveTransferAbort().

Here is the caller graph for this function:

◆ LPSPI_SetAllPcsPolarity()

static void LPSPI_SetAllPcsPolarity ( LPSPI_Type *  base,
uint32_t  mask 
)
inlinestatic

Configures all LPSPI peripheral chip select polarities simultaneously.

Note that the CFGR1 should only be written when the LPSPI is disabled (LPSPIx_CR_MEN = 0).

This is an example: PCS0 and PCS1 set to active low and other PCSs set to active high. Note that the number of PCS is device-specific.

static void LPSPI_SetAllPcsPolarity(LPSPI_Type *base, uint32_t mask)
Configures all LPSPI peripheral chip select polarities simultaneously.
Definition fsl_lpspi.h:778
Parameters
baseLPSPI peripheral address.
maskThe PCS polarity mask; Use the enum _lpspi_pcs_polarity.

Definition at line 778 of file fsl_lpspi.h.

779{
780 base->CFGR1 = (base->CFGR1 & ~LPSPI_CFGR1_PCSPOL_MASK) | LPSPI_CFGR1_PCSPOL(~mask);
781}

◆ LPSPI_SetDummyData()

void LPSPI_SetDummyData ( LPSPI_Type *  base,
uint8_t  dummyData 
)

Set up the dummy data.

Parameters
baseLPSPI peripheral address.
dummyDataData to be transferred when tx buffer is NULL. Note: This API has no effect when LPSPI in slave interrupt mode, because driver will set the TXMSK bit to 1 if txData is NULL, no data is loaded from transmit FIFO and output pin is tristated.

brief Set up the dummy data.

param base LPSPI peripheral address. param dummyData Data to be transferred when tx buffer is NULL. Note: This API has no effect when LPSPI in slave interrupt mode, because driver will set the TXMSK bit to 1 if txData is NULL, no data is loaded from transmit FIFO and output pin is tristated.

Definition at line 174 of file fsl_lpspi.c.

175{
176 uint32_t instance = LPSPI_GetInstance(base);
177 g_lpspiDummyData[instance] = dummyData;
178}

Referenced by LPSPI_MasterInit(), and LPSPI_SlaveInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_SetFifoWatermarks()

static void LPSPI_SetFifoWatermarks ( LPSPI_Type *  base,
uint32_t  txWater,
uint32_t  rxWater 
)
inlinestatic

Sets the transmit and receive FIFO watermark values.

This function allows the user to set the receive and transmit FIFO watermarks. The function does not compare the watermark settings to the FIFO size. The FIFO watermark should not be equal to or greater than the FIFO size. It is up to the higher level driver to make this check.

Parameters
baseLPSPI peripheral address.
txWaterThe TX FIFO watermark value. Writing a value equal or greater than the FIFO size is truncated.
rxWaterThe RX FIFO watermark value. Writing a value equal or greater than the FIFO size is truncated.

Definition at line 759 of file fsl_lpspi.h.

760{
761 base->FCR = LPSPI_FCR_TXWATER(txWater) | LPSPI_FCR_RXWATER(rxWater);
762}

Referenced by LPSPI_MasterInit(), LPSPI_MasterTransferEDMA(), LPSPI_MasterTransferNonBlocking(), LPSPI_SlaveInit(), LPSPI_SlaveTransferEDMA(), and LPSPI_SlaveTransferNonBlocking().

Here is the caller graph for this function:

◆ LPSPI_SetFrameSize()

static void LPSPI_SetFrameSize ( LPSPI_Type *  base,
uint32_t  frameSize 
)
inlinestatic

Configures the frame size.

The minimum frame size is 8-bits and the maximum frame size is 4096-bits. If the frame size is less than or equal to 32-bits, the word size and frame size are identical. If the frame size is greater than 32-bits, the word size is 32-bits for each word except the last (the last word contains the remainder bits if the frame size is not divisible by 32). The minimum word size is 2-bits. A frame size of 33-bits (or similar) is not supported.

Note 1: The transmit command register should be initialized before enabling the LPSPI in slave mode, although the command register does not update until after the LPSPI is enabled. After it is enabled, the transmit command register should only be changed if the LPSPI is idle.

Note 2: The transmit and command FIFO is a combined FIFO that includes both transmit data and command words. That means the TCR register should be written to when the Tx FIFO is not full.

Parameters
baseLPSPI peripheral address.
frameSizeThe frame size in number of bits.

Definition at line 802 of file fsl_lpspi.h.

803{
804 base->TCR = (base->TCR & ~LPSPI_TCR_FRAMESZ_MASK) | LPSPI_TCR_FRAMESZ(frameSize - 1);
805}

◆ LPSPI_SetMasterSlaveMode()

static void LPSPI_SetMasterSlaveMode ( LPSPI_Type *  base,
lpspi_master_slave_mode_t  mode 
)
inlinestatic

Configures the LPSPI for either master or slave.

Note that the CFGR1 should only be written when the LPSPI is disabled (LPSPIx_CR_MEN = 0).

Parameters
baseLPSPI peripheral address.
modeMode setting (master or slave) of type lpspi_master_slave_mode_t.

Definition at line 720 of file fsl_lpspi.h.

721{
722 base->CFGR1 = (base->CFGR1 & (~LPSPI_CFGR1_MASTER_MASK)) | LPSPI_CFGR1_MASTER(mode);
723}

Referenced by LPSPI_MasterInit(), and LPSPI_SlaveInit().

Here is the caller graph for this function:

◆ LPSPI_SlaveGetDefaultConfig()

void LPSPI_SlaveGetDefaultConfig ( lpspi_slave_config_t slaveConfig)

Sets the lpspi_slave_config_t structure to default values.

This API initializes the configuration structure for LPSPI_SlaveInit(). The initialized structure can remain unchanged in LPSPI_SlaveInit() or can be modified before calling the LPSPI_SlaveInit(). Example:

void LPSPI_SlaveGetDefaultConfig(lpspi_slave_config_t *slaveConfig)
Sets the lpspi_slave_config_t structure to default values.
Definition fsl_lpspi.c:326
LPSPI slave configuration structure.
Definition fsl_lpspi.h:283
Parameters
slaveConfigpointer to lpspi_slave_config_t structure.

brief Sets the lpspi_slave_config_t structure to default values.

This API initializes the configuration structure for LPSPI_SlaveInit(). The initialized structure can remain unchanged in LPSPI_SlaveInit() or can be modified before calling the LPSPI_SlaveInit(). Example: code lpspi_slave_config_t slaveConfig; LPSPI_SlaveGetDefaultConfig(&slaveConfig); endcode param slaveConfig pointer to lpspi_slave_config_t structure.

< Bits per frame, minimum 8, maximum 4096.

< Clock polarity.

< Clock phase.

< MSB or LSB data shift direction.

< Desired Peripheral Chip Select (pcs)

< Desired PCS active high or low

Definition at line 326 of file fsl_lpspi.c.

327{
328 assert(slaveConfig);
329
330 /* Initializes the configure structure to zero. */
331 memset(slaveConfig, 0, sizeof(*slaveConfig));
332
333 slaveConfig->bitsPerFrame = 8; /*!< Bits per frame, minimum 8, maximum 4096.*/
334 slaveConfig->cpol = kLPSPI_ClockPolarityActiveHigh; /*!< Clock polarity. */
335 slaveConfig->cpha = kLPSPI_ClockPhaseFirstEdge; /*!< Clock phase. */
336 slaveConfig->direction = kLPSPI_MsbFirst; /*!< MSB or LSB data shift direction. */
337
338 slaveConfig->whichPcs = kLPSPI_Pcs0; /*!< Desired Peripheral Chip Select (pcs) */
339 slaveConfig->pcsActiveHighOrLow = kLPSPI_PcsActiveLow; /*!< Desired PCS active high or low */
340
341 slaveConfig->pinCfg = kLPSPI_SdiInSdoOut;
343}
lpspi_clock_phase_t cpha
Definition fsl_lpspi.h:286
lpspi_shift_direction_t direction
Definition fsl_lpspi.h:287
lpspi_pcs_polarity_config_t pcsActiveHighOrLow
Definition fsl_lpspi.h:290
lpspi_data_out_config_t dataOutConfig
Definition fsl_lpspi.h:295
uint32_t bitsPerFrame
Definition fsl_lpspi.h:284
lpspi_clock_polarity_t cpol
Definition fsl_lpspi.h:285
lpspi_which_pcs_t whichPcs
Definition fsl_lpspi.h:289
lpspi_pin_config_t pinCfg
Definition fsl_lpspi.h:292

Referenced by spi_lld_start().

Here is the caller graph for this function:

◆ LPSPI_SlaveInit()

void LPSPI_SlaveInit ( LPSPI_Type *  base,
const lpspi_slave_config_t slaveConfig 
)

LPSPI slave configuration.

Parameters
baseLPSPI peripheral address.
slaveConfigPointer to a structure lpspi_slave_config_t.

brief LPSPI slave configuration.

param base LPSPI peripheral address. param slaveConfig Pointer to a structure lpspi_slave_config_t.

Definition at line 279 of file fsl_lpspi.c.

280{
281 assert(slaveConfig);
282
283#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
284
285 uint32_t instance = LPSPI_GetInstance(base);
286 /* Enable LPSPI clock */
288
289#if defined(LPSPI_PERIPH_CLOCKS)
291#endif
292
293#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
294
296
297 LPSPI_SetOnePcsPolarity(base, slaveConfig->whichPcs, slaveConfig->pcsActiveHighOrLow);
298
299 base->CFGR1 = (base->CFGR1 & ~(LPSPI_CFGR1_OUTCFG_MASK | LPSPI_CFGR1_PINCFG_MASK)) |
300 LPSPI_CFGR1_OUTCFG(slaveConfig->dataOutConfig) | LPSPI_CFGR1_PINCFG(slaveConfig->pinCfg);
301
303
304 base->TCR = LPSPI_TCR_CPOL(slaveConfig->cpol) | LPSPI_TCR_CPHA(slaveConfig->cpha) |
305 LPSPI_TCR_LSBF(slaveConfig->direction) | LPSPI_TCR_FRAMESZ(slaveConfig->bitsPerFrame - 1);
306
307 /* This operation will set the dummy data for edma transfer, no effect in interrupt way. */
308 LPSPI_SetDummyData(base, LPSPI_DUMMY_DATA);
309
310 LPSPI_Enable(base, true);
311}

Referenced by spi_lld_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_SlaveTransferAbort()

void LPSPI_SlaveTransferAbort ( LPSPI_Type *  base,
lpspi_slave_handle_t handle 
)

LPSPI slave aborts a transfer which uses an interrupt method.

This function aborts a transfer which uses an interrupt method.

Parameters
baseLPSPI peripheral address.
handlepointer to lpspi_slave_handle_t structure which stores the transfer state.

brief LPSPI slave aborts a transfer which uses an interrupt method.

This function aborts a transfer which uses an interrupt method.

param base LPSPI peripheral address. param handle pointer to lpspi_slave_handle_t structure which stores the transfer state.

Definition at line 1669 of file fsl_lpspi.c.

1670{
1671 assert(handle);
1672
1673 /* Disable interrupt requests*/
1675
1676 LPSPI_Reset(base);
1677
1678 handle->state = kLPSPI_Idle;
1679 handle->txRemainingByteCount = 0;
1680 handle->rxRemainingByteCount = 0;
1681}
volatile uint8_t state
Definition fsl_lpspi.h:404
volatile size_t txRemainingByteCount
Definition fsl_lpspi.h:396
volatile size_t rxRemainingByteCount
Definition fsl_lpspi.h:397
Here is the call graph for this function:

◆ LPSPI_SlaveTransferCreateHandle()

void LPSPI_SlaveTransferCreateHandle ( LPSPI_Type *  base,
lpspi_slave_handle_t handle,
lpspi_slave_transfer_callback_t  callback,
void *  userData 
)

Initializes the LPSPI slave handle.

This function initializes the LPSPI handle, which can be used for other LPSPI transactional APIs. Usually, for a specified LPSPI instance, call this API once to get the initialized handle.

Parameters
baseLPSPI peripheral address.
handleLPSPI handle pointer to lpspi_slave_handle_t.
callbackDSPI callback.
userDatacallback function parameter.

brief Initializes the LPSPI slave handle.

This function initializes the LPSPI handle, which can be used for other LPSPI transactional APIs. Usually, for a specified LPSPI instance, call this API once to get the initialized handle.

param base LPSPI peripheral address. param handle LPSPI handle pointer to lpspi_slave_handle_t. param callback DSPI callback. param userData callback function parameter.

Definition at line 1366 of file fsl_lpspi.c.

1370{
1371 assert(handle);
1372
1373 /* Zero the handle. */
1374 memset(handle, 0, sizeof(*handle));
1375
1376 s_lpspiHandle[LPSPI_GetInstance(base)] = handle;
1377
1378 /* Set irq handler. */
1380
1381 handle->callback = callback;
1382 handle->userData = userData;
1383}
static lpspi_slave_isr_t s_lpspiSlaveIsr
Pointer to slave IRQ handler for each instance.
Definition fsl_lpspi.c:140
void LPSPI_SlaveTransferHandleIRQ(LPSPI_Type *base, lpspi_slave_handle_t *handle)
LPSPI Slave IRQ handler function.
Definition fsl_lpspi.c:1691
lpspi_slave_transfer_callback_t callback
Definition fsl_lpspi.h:408

Referenced by spi_lld_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_SlaveTransferGetCount()

status_t LPSPI_SlaveTransferGetCount ( LPSPI_Type *  base,
lpspi_slave_handle_t handle,
size_t count 
)

Gets the slave transfer remaining bytes.

This function gets the slave transfer remaining bytes.

Parameters
baseLPSPI peripheral address.
handlepointer to lpspi_slave_handle_t structure which stores the transfer state.
countNumber of bytes transferred so far by the non-blocking transaction.
Returns
status of status_t.

brief Gets the slave transfer remaining bytes.

This function gets the slave transfer remaining bytes.

param base LPSPI peripheral address. param handle pointer to lpspi_slave_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. return status of status_t.

Definition at line 1629 of file fsl_lpspi.c.

1630{
1631 assert(handle);
1632
1633 if (!count)
1634 {
1636 }
1637
1638 /* Catch when there is not an active transfer. */
1639 if (handle->state != kLPSPI_Busy)
1640 {
1641 *count = 0;
1643 }
1644
1645 size_t remainingByte;
1646
1647 if (handle->rxData)
1648 {
1649 remainingByte = handle->rxRemainingByteCount;
1650 }
1651 else
1652 {
1653 remainingByte = handle->txRemainingByteCount;
1654 }
1655
1656 *count = handle->totalByteCount - remainingByte;
1657
1658 return kStatus_Success;
1659}
uint8_t *volatile rxData
Definition fsl_lpspi.h:394
uint32_t totalByteCount
Definition fsl_lpspi.h:402

◆ LPSPI_SlaveTransferHandleIRQ()

void LPSPI_SlaveTransferHandleIRQ ( LPSPI_Type *  base,
lpspi_slave_handle_t handle 
)

LPSPI Slave IRQ handler function.

This function processes the LPSPI transmit and receives an IRQ.

Parameters
baseLPSPI peripheral address.
handlepointer to lpspi_slave_handle_t structure which stores the transfer state.

brief LPSPI Slave IRQ handler function.

This function processes the LPSPI transmit and receives an IRQ.

param base LPSPI peripheral address. param handle pointer to lpspi_slave_handle_t structure which stores the transfer state.

Definition at line 1691 of file fsl_lpspi.c.

1692{
1693 assert(handle);
1694
1695 uint32_t readData; /* variable to store word read from RX FIFO */
1696 uint32_t wordToSend; /* variable to store word to write to TX FIFO */
1697
1698 if (handle->rxData != NULL)
1699 {
1700 if (handle->rxRemainingByteCount > 0)
1701 {
1702 while (LPSPI_GetRxFifoCount(base))
1703 {
1704 /*Read out the data*/
1705 readData = LPSPI_ReadData(base);
1706
1707 /*Decrease the read RX register times.*/
1708 --handle->readRegRemainingTimes;
1709
1710 if (handle->rxRemainingByteCount < handle->bytesEachRead)
1711 {
1712 handle->bytesEachRead = handle->rxRemainingByteCount;
1713 }
1714
1715 LPSPI_SeparateReadData(handle->rxData, readData, handle->bytesEachRead, handle->isByteSwap);
1716 handle->rxData += handle->bytesEachRead;
1717
1718 /*Decrease the remaining RX byte count.*/
1719 handle->rxRemainingByteCount -= handle->bytesEachRead;
1720
1721 if ((handle->txRemainingByteCount > 0) && (handle->txData != NULL))
1722 {
1723 if (handle->txRemainingByteCount < handle->bytesEachWrite)
1724 {
1725 handle->bytesEachWrite = handle->txRemainingByteCount;
1726 }
1727
1728 wordToSend = LPSPI_CombineWriteData(handle->txData, handle->bytesEachWrite, handle->isByteSwap);
1729 handle->txData += handle->bytesEachWrite;
1730
1731 /*Decrease the remaining TX byte count.*/
1732 handle->txRemainingByteCount -= handle->bytesEachWrite;
1733
1734 /*Write the word to TX register*/
1735 LPSPI_WriteData(base, wordToSend);
1736 }
1737
1738 if (handle->rxRemainingByteCount == 0)
1739 {
1740 break;
1741 }
1742 }
1743 }
1744
1745 /*Set rxWatermark to (readRegRemainingTimes-1) if readRegRemainingTimes less than rxWatermark. Otherwise there
1746 *is not RX interrupt for the last datas because the RX count is not greater than rxWatermark.
1747 */
1748 if ((handle->readRegRemainingTimes) <= (handle->rxWatermark))
1749 {
1750 base->FCR =
1751 (base->FCR & (~LPSPI_FCR_RXWATER_MASK)) |
1752 LPSPI_FCR_RXWATER((handle->readRegRemainingTimes > 1) ? (handle->readRegRemainingTimes - 1U) : (0U));
1753 }
1754 }
1755 else if ((handle->txRemainingByteCount) && (handle->txData != NULL))
1756 {
1757 LPSPI_SlaveTransferFillUpTxFifo(base, handle);
1758 }
1759 else
1760 {
1761 __NOP();
1762 }
1763
1764 if ((handle->txRemainingByteCount == 0) && (handle->rxRemainingByteCount == 0))
1765 {
1766 /* If no RX buffer, then transfer is not complete until transfer complete flag sets and the TX FIFO empty*/
1767 if (handle->rxData == NULL)
1768 {
1770 {
1771 /* Complete the transfer and disable the interrupts */
1772 LPSPI_SlaveTransferComplete(base, handle);
1773 }
1774 else
1775 {
1779 }
1780 }
1781 else
1782 {
1783 /* Complete the transfer and disable the interrupts */
1784 LPSPI_SlaveTransferComplete(base, handle);
1785 }
1786 }
1787
1788 /* Catch tx fifo underflow conditions, service only if tx under flow interrupt enabled */
1789 if ((LPSPI_GetStatusFlags(base) & kLPSPI_TransmitErrorFlag) && (base->IER & LPSPI_IER_TEIE_MASK))
1790 {
1792 /* Change state to error and clear flag */
1793 if (handle->txData)
1794 {
1795 handle->state = kLPSPI_Error;
1796 }
1797 handle->errorCount++;
1798 }
1799 /* Catch rx fifo overflow conditions, service only if rx over flow interrupt enabled */
1800 if ((LPSPI_GetStatusFlags(base) & kLPSPI_ReceiveErrorFlag) && (base->IER & LPSPI_IER_REIE_MASK))
1801 {
1803 /* Change state to error and clear flag */
1804 if (handle->txData)
1805 {
1806 handle->state = kLPSPI_Error;
1807 }
1808 handle->errorCount++;
1809 }
1810}
static void LPSPI_SlaveTransferFillUpTxFifo(LPSPI_Type *base, lpspi_slave_handle_t *handle)
Slave fill up the TX FIFO with data. This is not a public API.
Definition fsl_lpspi.c:1564
static void LPSPI_SlaveTransferComplete(LPSPI_Type *base, lpspi_slave_handle_t *handle)
Slave finish up a transfer. It would call back if there is callback function and set the state to idl...
Definition fsl_lpspi.c:1593
volatile uint8_t rxWatermark
Definition fsl_lpspi.h:388
volatile uint8_t bytesEachRead
Definition fsl_lpspi.h:391
volatile uint32_t errorCount
Definition fsl_lpspi.h:406
volatile uint32_t readRegRemainingTimes
Definition fsl_lpspi.h:400
volatile uint8_t bytesEachWrite
Definition fsl_lpspi.h:390
uint8_t *volatile txData
Definition fsl_lpspi.h:393
volatile bool isByteSwap
Definition fsl_lpspi.h:384

Referenced by LPSPI_SlaveTransferCreateHandle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_SlaveTransferNonBlocking()

status_t LPSPI_SlaveTransferNonBlocking ( LPSPI_Type *  base,
lpspi_slave_handle_t handle,
lpspi_transfer_t transfer 
)

LPSPI slave transfer data using an interrupt method.

This function transfer data using an interrupt method. This is a non-blocking function, which returns right away. When all data is transferred, the callback function is called.

Note: The transfer data size should be integer multiples of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not an integer multiple of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

Parameters
baseLPSPI peripheral address.
handlepointer to lpspi_slave_handle_t structure which stores the transfer state.
transferpointer to lpspi_transfer_t structure.
Returns
status of status_t.

brief LPSPI slave transfer data using an interrupt method.

This function transfer data using an interrupt method. This is a non-blocking function, which returns right away. When all data is transferred, the callback function is called.

Note: The transfer data size should be integer multiples of bytesPerFrame if bytesPerFrame is less than or equal to 4. For bytesPerFrame greater than 4: The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not an integer multiple of 4. Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.

param base LPSPI peripheral address. param handle pointer to lpspi_slave_handle_t structure which stores the transfer state. param transfer pointer to lpspi_transfer_t structure. return status of status_t.

Definition at line 1403 of file fsl_lpspi.c.

1404{
1405 assert(handle);
1406 assert(transfer);
1407
1408 uint32_t bitsPerFrame = ((base->TCR & LPSPI_TCR_FRAMESZ_MASK) >> LPSPI_TCR_FRAMESZ_SHIFT) + 1;
1409 uint32_t bytesPerFrame = (bitsPerFrame + 7) / 8;
1410 uint32_t temp = 0U;
1411
1412 if (!LPSPI_CheckTransferArgument(transfer, bitsPerFrame, bytesPerFrame))
1413 {
1415 }
1416
1417 /* Check that we're not busy.*/
1418 if (handle->state == kLPSPI_Busy)
1419 {
1420 return kStatus_LPSPI_Busy;
1421 }
1422 handle->state = kLPSPI_Busy;
1423
1424 bool isRxMask = false;
1425 bool isTxMask = false;
1426
1427 uint32_t whichPcs = (transfer->configFlags & LPSPI_SLAVE_PCS_MASK) >> LPSPI_SLAVE_PCS_SHIFT;
1428
1429 handle->txData = transfer->txData;
1430 handle->rxData = transfer->rxData;
1431 handle->txRemainingByteCount = transfer->dataSize;
1432 handle->rxRemainingByteCount = transfer->dataSize;
1433 handle->totalByteCount = transfer->dataSize;
1434
1435 handle->writeRegRemainingTimes = (transfer->dataSize / bytesPerFrame) * ((bytesPerFrame + 3) / 4);
1437
1438 /*The TX and RX FIFO sizes are always the same*/
1439 handle->fifoSize = LPSPI_GetRxFifoSize(base);
1440
1441 handle->isByteSwap = (bool)(transfer->configFlags & kLPSPI_SlaveByteSwap);
1442
1443 /*Set the RX and TX watermarks to reduce the ISR times.*/
1444 uint8_t txWatermark;
1445 if (handle->fifoSize > 1)
1446 {
1447 txWatermark = 1;
1448 handle->rxWatermark = handle->fifoSize - 2;
1449 }
1450 else
1451 {
1452 txWatermark = 0;
1453 handle->rxWatermark = 0;
1454 }
1455 LPSPI_SetFifoWatermarks(base, txWatermark, handle->rxWatermark);
1456
1457 /* Check if using 3-wire mode and the txData is NULL, set the output pin to tristated. */
1458 temp = base->CFGR1;
1459 temp &= LPSPI_CFGR1_PINCFG_MASK;
1460 if ((temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdiInSdiOut)) || (temp == LPSPI_CFGR1_PINCFG(kLPSPI_SdoInSdoOut)))
1461 {
1462 if (!handle->txData)
1463 {
1464 LPSPI_Enable(base, false);
1465 base->CFGR1 |= LPSPI_CFGR1_OUTCFG_MASK;
1466 LPSPI_Enable(base, true);
1467 }
1468 /* The 3-wire mode can't send and receive data at the same time. */
1469 if ((handle->txData) && (handle->rxData))
1470 {
1472 }
1473 }
1474
1475 /*Flush FIFO , clear status , disable all the inerrupts.*/
1476 LPSPI_FlushFifo(base, true, true);
1479
1480 /*If there is not rxData , can mask the receive data (receive data is not stored in receive FIFO).*/
1481 if (handle->rxData == NULL)
1482 {
1483 isRxMask = true;
1484 handle->rxRemainingByteCount = 0;
1485 }
1486
1487 /*If there is not txData , can mask the transmit data (no data is loaded from transmit FIFO and output pin
1488 * is tristated).
1489 */
1490 if (handle->txData == NULL)
1491 {
1492 isTxMask = true;
1493 handle->txRemainingByteCount = 0;
1494 }
1495
1496 base->TCR = (base->TCR &
1497 ~(LPSPI_TCR_CONT_MASK | LPSPI_TCR_CONTC_MASK | LPSPI_TCR_RXMSK_MASK | LPSPI_TCR_TXMSK_MASK |
1498 LPSPI_TCR_PCS_MASK)) |
1499 LPSPI_TCR_CONT(0) | LPSPI_TCR_CONTC(0) | LPSPI_TCR_RXMSK(isRxMask) | LPSPI_TCR_TXMSK(isTxMask) |
1500 LPSPI_TCR_PCS(whichPcs);
1501
1502 /*Calculate the bytes for write/read the TX/RX register each time*/
1503 if (bytesPerFrame <= 4)
1504 {
1505 handle->bytesEachWrite = bytesPerFrame;
1506 handle->bytesEachRead = bytesPerFrame;
1507 }
1508 else
1509 {
1510 handle->bytesEachWrite = 4;
1511 handle->bytesEachRead = 4;
1512 }
1513
1514 /* Enable the NVIC for LPSPI peripheral. Note that below code is useless if the LPSPI interrupt is in INTMUX ,
1515 * and you should also enable the INTMUX interupt in your application.
1516 */
1517 EnableIRQ(s_lpspiIRQ[LPSPI_GetInstance(base)]);
1518
1519 /*TCR is also shared the FIFO , so wait for TCR written.*/
1520 while (LPSPI_GetTxFifoCount(base) != 0)
1521 {
1522 }
1523
1524 /*Fill up the TX data in FIFO */
1525 if (handle->txData)
1526 {
1527 LPSPI_SlaveTransferFillUpTxFifo(base, handle);
1528 }
1529
1530 /* Since SPI is a synchronous interface, we only need to enable the RX interrupt if there is RX data.
1531 * The IRQ handler will get the status of RX and TX interrupt flags.
1532 */
1533 if (handle->rxData)
1534 {
1535 /*Set rxWatermark to (readRegRemainingTimes-1) if readRegRemainingTimes less than rxWatermark. Otherwise there
1536 *is not RX interrupt for the last datas because the RX count is not greater than rxWatermark.
1537 */
1538 if ((handle->readRegRemainingTimes) <= handle->rxWatermark)
1539 {
1540 base->FCR = (base->FCR & (~LPSPI_FCR_RXWATER_MASK)) | LPSPI_FCR_RXWATER(handle->readRegRemainingTimes - 1);
1541 }
1542
1544 }
1545 else
1546 {
1548 }
1549
1550 if (handle->rxData)
1551 {
1552 /* RX FIFO overflow request enable */
1554 }
1555 if (handle->txData)
1556 {
1557 /* TX FIFO underflow request enable */
1559 }
1560
1561 return kStatus_Success;
1562}
volatile uint8_t fifoSize
Definition fsl_lpspi.h:386
volatile uint32_t writeRegRemainingTimes
Definition fsl_lpspi.h:399

Referenced by spi_lld_exchange(), spi_lld_receive(), and spi_lld_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LPSPI_WriteData()

static void LPSPI_WriteData ( LPSPI_Type *  base,
uint32_t  data 
)
inlinestatic

Writes data into the transmit data buffer.

This function writes data passed in by the user to the Transmit Data Register (TDR). The user can pass up to 32-bits of data to load into the TDR. If the frame size exceeds 32-bits, the user has to manage sending the data one 32-bit word at a time. Any writes to the TDR result in an immediate push to the transmit FIFO. This function can be used for either master or slave modes.

Parameters
baseLPSPI peripheral address.
dataThe data word to be sent.

Definition at line 904 of file fsl_lpspi.h.

905{
906 base->TDR = data;
907}

Referenced by LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferFillUpTxFifo(), LPSPI_SlaveTransferFillUpTxFifo(), and LPSPI_SlaveTransferHandleIRQ().

Here is the caller graph for this function:

Variable Documentation

◆ g_lpspiDummyData

volatile uint8_t g_lpspiDummyData[]
extern

Global variable for dummy data value setting.

Definition at line 142 of file fsl_lpspi.c.

142{0};

Referenced by LPSPI_MasterTransferBlocking(), LPSPI_MasterTransferEDMA(), LPSPI_MasterTransferNonBlocking(), LPSPI_SetDummyData(), and LPSPI_SlaveTransferEDMA().