S32 SDK

Detailed Description

Low Power Serial Peripheral Interface Peripheral Driver.

Data Structures

struct  lpspi_master_config_t
 Data structure containing information about a device on the SPI bus. More...
 
struct  lpspi_state_t
 Runtime state structure for the LPSPI master driver. More...
 
struct  lpspi_slave_config_t
 User configuration structure for the SPI slave driver. Implements : lpspi_slave_config_t_Class. More...
 

Enumerations

enum  lpspi_which_pcs_t { LPSPI_PCS0 = 0U, LPSPI_PCS1 = 1U, LPSPI_PCS2 = 2U, LPSPI_PCS3 = 3U }
 LPSPI Peripheral Chip Select (PCS) configuration (which PCS to configure). Implements : lpspi_which_pcs_t_Class. More...
 
enum  lpspi_signal_polarity_t { LPSPI_ACTIVE_HIGH = 1U, LPSPI_ACTIVE_LOW = 0U }
 LPSPI Signal (PCS and Host Request) Polarity configuration. Implements : lpspi_signal_polarity_t_Class. More...
 
enum  lpspi_clock_phase_t { LPSPI_CLOCK_PHASE_1ST_EDGE = 0U, LPSPI_CLOCK_PHASE_2ND_EDGE = 1U }
 LPSPI clock phase configuration. Implements : lpspi_clock_phase_t_Class. More...
 
enum  lpspi_sck_polarity_t { LPSPI_SCK_ACTIVE_HIGH = 0U, LPSPI_SCK_ACTIVE_LOW = 1U }
 LPSPI Clock Signal (SCK) Polarity configuration. Implements : lpspi_sck_polarity_t_Class. More...
 
enum  lpspi_transfer_type { LPSPI_USING_DMA = 0, LPSPI_USING_INTERRUPTS }
 Type of LPSPI transfer (based on interrupts or DMA). Implements : lpspi_transfer_type_Class. More...
 
enum  transfer_status_t { LPSPI_TRANSFER_OK = 0U, LPSPI_TRANSMIT_FAIL, LPSPI_RECEIVE_FAIL }
 Type of error reported by LPSPI. More...
 

Functions

void LPSPI_DRV_IRQHandler (uint32_t instance)
 The function LPSPI_DRV_IRQHandler passes IRQ control to either the master or slave driver. More...
 
void LPSPI_DRV_FillupTxBuffer (uint32_t instance)
 The function LPSPI_DRV_FillupTxBuffer writes data in TX hardware buffer depending on driver state and number of bytes remained to send. More...
 
void LPSPI_DRV_ReadRXBuffer (uint32_t instance)
 The function LPSPI_DRV_ReadRXBuffer reads data from RX hardware buffer and writes this data in RX software buffer. More...
 
void LPSPI_DRV_DisableTEIEInterrupts (uint32_t instance)
 Disable the TEIE interrupts at the end of a transfer. Disable the interrupts and clear the status for transmit/receive errors. More...
 
void LPSPI0_IRQHandler (void)
 This function is the implementation of LPSPI0 handler named in startup code. More...
 
void LPSPI1_IRQHandler (void)
 This function is the implementation of LPSPI1 handler named in startup code. More...
 
void LPSPI2_IRQHandler (void)
 This function is the implementation of LPSPI2 handler named in startup code. More...
 

Variables

LPSPI_Typeg_lpspiBase [LPSPI_INSTANCE_COUNT]
 Table of base pointers for SPI instances. More...
 
IRQn_Type g_lpspiIrqId [LPSPI_INSTANCE_COUNT]
 Table to save LPSPI IRQ enumeration numbers defined in the CMSIS header file. More...
 
lpspi_state_tg_lpspiStatePtr [LPSPI_INSTANCE_COUNT]
 

Initialization and shutdown

status_t LPSPI_DRV_MasterInit (uint32_t instance, lpspi_state_t *lpspiState, const lpspi_master_config_t *spiConfig)
 Initializes a LPSPI instance for interrupt driven master mode operation. More...
 
status_t LPSPI_DRV_MasterDeinit (uint32_t instance)
 Shuts down a LPSPI instance. More...
 
status_t LPSPI_DRV_MasterSetDelay (uint32_t instance, uint32_t delayBetwenTransfers, uint32_t delaySCKtoPCS, uint32_t delayPCStoSCK)
 Configures the LPSPI master mode bus timing delay options. More...
 

Bus configuration

status_t LPSPI_DRV_MasterConfigureBus (uint32_t instance, const lpspi_master_config_t *spiConfig, uint32_t *calculatedBaudRate)
 Configures the LPSPI port physical parameters to access a device on the bus when the LSPI instance is configured for interrupt operation. More...
 

Blocking transfers

status_t LPSPI_DRV_MasterTransferBlocking (uint32_t instance, const uint8_t *sendBuffer, uint8_t *receiveBuffer, uint16_t transferByteCount, uint32_t timeout)
 Performs an interrupt driven blocking SPI master mode transfer. More...
 

Non-blocking transfers

status_t LPSPI_DRV_MasterTransfer (uint32_t instance, const uint8_t *sendBuffer, uint8_t *receiveBuffer, uint16_t transferByteCount)
 Performs an interrupt driven non-blocking SPI master mode transfer. More...
 
status_t LPSPI_DRV_MasterGetTransferStatus (uint32_t instance, uint32_t *bytesRemained)
 Returns whether the previous interrupt driven transfer is completed. More...
 
status_t LPSPI_DRV_MasterAbortTransfer (uint32_t instance)
 Terminates an interrupt driven asynchronous transfer early. More...
 
void LPSPI_DRV_MasterIRQHandler (uint32_t instance)
 Interrupt handler for LPSPI master mode. This handler uses the buffers stored in the lpspi_master_state_t structs to transfer data. More...
 

Initialization and shutdown

status_t LPSPI_DRV_SlaveInit (uint32_t instance, lpspi_state_t *lpspiState, const lpspi_slave_config_t *slaveConfig)
 Initializes a LPSPI instance for a slave mode operation, using interrupt mechanism. More...
 
status_t LPSPI_DRV_SlaveDeinit (uint32_t instance)
 Shuts down an LPSPI instance interrupt mechanism. More...
 

Blocking transfers

status_t LPSPI_DRV_SlaveTransferBlocking (uint32_t instance, const uint8_t *sendBuffer, uint8_t *receiveBuffer, uint16_t transferByteCount, uint32_t timeout)
 Transfers data on LPSPI bus using interrupt and a blocking call. More...
 

Non-blocking transfers

void LPSPI_DRV_SlaveIRQHandler (uint32_t instance)
 Interrupt handler for LPSPI slave mode. This handler uses the buffers stored in the lpspi_master_state_t structs to transfer data. More...
 
status_t LPSPI_DRV_SlaveTransfer (uint32_t instance, const uint8_t *sendBuffer, uint8_t *receiveBuffer, uint16_t transferByteCount)
 Starts the transfer data on LPSPI bus using an interrupt and a non-blocking call. More...
 
status_t LPSPI_DRV_SlaveAbortTransfer (uint32_t instance)
 Aborts the transfer that started by a non-blocking call transfer function. More...
 
status_t LPSPI_DRV_SlaveGetTransferStatus (uint32_t instance, uint32_t *bytesRemained)
 Returns whether the previous transfer is finished. More...
 

Enumeration Type Documentation

LPSPI clock phase configuration. Implements : lpspi_clock_phase_t_Class.

Enumerator
LPSPI_CLOCK_PHASE_1ST_EDGE 

Data captured on SCK 1st edge, changed on 2nd.

LPSPI_CLOCK_PHASE_2ND_EDGE 

Data changed on SCK 1st edge, captured on 2nd.

Definition at line 83 of file lpspi_shared_function.h.

LPSPI Clock Signal (SCK) Polarity configuration. Implements : lpspi_sck_polarity_t_Class.

Enumerator
LPSPI_SCK_ACTIVE_HIGH 

Signal is Active High (idles low).

LPSPI_SCK_ACTIVE_LOW 

Signal is Active Low (idles high).

Definition at line 92 of file lpspi_shared_function.h.

LPSPI Signal (PCS and Host Request) Polarity configuration. Implements : lpspi_signal_polarity_t_Class.

Enumerator
LPSPI_ACTIVE_HIGH 

Signal is Active High (idles low).

LPSPI_ACTIVE_LOW 

Signal is Active Low (idles high).

Definition at line 74 of file lpspi_shared_function.h.

Type of LPSPI transfer (based on interrupts or DMA). Implements : lpspi_transfer_type_Class.

Enumerator
LPSPI_USING_DMA 

The driver will use DMA to perform SPI transfer

LPSPI_USING_INTERRUPTS 

The driver will use interrupts to perform SPI transfer

Definition at line 102 of file lpspi_shared_function.h.

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

Enumerator
LPSPI_PCS0 

PCS[0]

LPSPI_PCS1 

PCS[1]

LPSPI_PCS2 

PCS[2]

LPSPI_PCS3 

PCS[3]

Definition at line 63 of file lpspi_shared_function.h.

Type of error reported by LPSPI.

Enumerator
LPSPI_TRANSFER_OK 

Transfer OK

LPSPI_TRANSMIT_FAIL 

Error during transmission

LPSPI_RECEIVE_FAIL 

Error during reception

Definition at line 110 of file lpspi_shared_function.h.

Function Documentation

void LPSPI0_IRQHandler ( void  )

This function is the implementation of LPSPI0 handler named in startup code.

It passes the instance to the shared LPSPI IRQ handler.

Definition at line 109 of file lpspi_irq.c.

void LPSPI1_IRQHandler ( void  )

This function is the implementation of LPSPI1 handler named in startup code.

It passes the instance to the shared LPSPI IRQ handler.

Definition at line 119 of file lpspi_irq.c.

void LPSPI2_IRQHandler ( void  )

This function is the implementation of LPSPI2 handler named in startup code.

It passes the instance to the shared LPSPI IRQ handler.

Definition at line 129 of file lpspi_irq.c.

void LPSPI_DRV_DisableTEIEInterrupts ( uint32_t  instance)

Disable the TEIE interrupts at the end of a transfer. Disable the interrupts and clear the status for transmit/receive errors.

Definition at line 261 of file lpspi_shared_function.c.

void LPSPI_DRV_FillupTxBuffer ( uint32_t  instance)

The function LPSPI_DRV_FillupTxBuffer writes data in TX hardware buffer depending on driver state and number of bytes remained to send.

The function LPSPI_DRV_FillupTxBuffer writes data in TX hardware buffer depending on driver state and number of bytes remained to send.

Definition at line 122 of file lpspi_shared_function.c.

void LPSPI_DRV_IRQHandler ( uint32_t  instance)

The function LPSPI_DRV_IRQHandler passes IRQ control to either the master or slave driver.

The address of the IRQ handlers are checked to make sure they are non-zero before they are called. If the IRQ handler's address is zero, it means that driver was not present in the link (because the IRQ handlers are marked as weak). This would actually be a program error, because it means the master/slave config for the IRQ was set incorrectly.

Definition at line 99 of file lpspi_shared_function.c.

status_t LPSPI_DRV_MasterAbortTransfer ( uint32_t  instance)

Terminates an interrupt driven asynchronous transfer early.

During an a-sync (non-blocking) transfer, the user has the option to terminate the transfer early if the transfer is still in progress.

Parameters
instanceThe instance number of the LPSPI peripheral.
Returns
STATUS_SUCCESS The transfer was successful, or LPSPI_STATUS_NO_TRANSFER_IN_PROGRESS No transfer is currently in progress.

Definition at line 560 of file lpspi_master_driver.c.

status_t LPSPI_DRV_MasterConfigureBus ( uint32_t  instance,
const lpspi_master_config_t spiConfig,
uint32_t *  calculatedBaudRate 
)

Configures the LPSPI port physical parameters to access a device on the bus when the LSPI instance is configured for interrupt operation.

In this function, the term "spiConfig" is used to indicate the SPI device for which the LPSPI master is communicating. This is an optional function as the spiConfig parameters are normally configured in the initialization function or the transfer functions, where these various functions would call the configure bus function. This is an example to set up the lpspi_master_config_t structure to call the LPSPI_DRV_MasterConfigureBus function by passing in these parameters:

1 lpspi_master_config_t spiConfig1; You can also declare spiConfig2, spiConfig3, etc
2 spiConfig1.bitsPerSec = 500000;
3 spiConfig1.whichPcs = LPSPI_PCS0;
4 spiConfig1.pcsPolarity = LPSPI_ACTIVE_LOW;
5 spiConfig1.isPcsContinuous = false;
6 spiConfig1.bitCount = 16;
7 spiConfig1.clkPhase = LPSPI_CLOCK_PHASE_1ST_EDGE;
8 spiConfig1.clkPolarity = LPSPI_ACTIVE_HIGH;
9 spiConfig1.lsbFirst= false;
10 spiConfig.transferType = LPSPI_USING_INTERRUPTS;
Parameters
instanceThe instance number of the LPSPI peripheral.
spiConfigPointer to the spiConfig structure. This structure contains the settings for the SPI bus configuration. The SPI device parameters are the desired baud rate (in bits-per-sec), bits-per-frame, chip select attributes, clock attributes, and data shift direction.
calculatedBaudRateThe calculated baud rate passed back to the user to determine if the calculated baud rate is close enough to meet the needs. The baud rate never exceeds the desired baud rate.
Returns
STATUS_SUCCESS The transfer has completed successfully, or STATUS_ERROR if driver is error and needs to clean error.

Definition at line 311 of file lpspi_master_driver.c.

status_t LPSPI_DRV_MasterDeinit ( uint32_t  instance)

Shuts down a LPSPI instance.

This function resets the LPSPI peripheral, gates its clock, and disables the interrupt to the core. It first checks to see if a transfer is in progress and if so returns an error status.

Parameters
instanceThe instance number of the LPSPI peripheral.
Returns
STATUS_SUCCESS The transfer has completed successfully, or STATUS_BUSY The transfer is still in progress. STATUS_ERROR if driver is error and needs to clean error.

Definition at line 191 of file lpspi_master_driver.c.

status_t LPSPI_DRV_MasterGetTransferStatus ( uint32_t  instance,
uint32_t *  bytesRemained 
)

Returns whether the previous interrupt driven transfer is completed.

When performing an a-sync (non-blocking) transfer, the user can call this function to ascertain the state of the current transfer: in progress (or busy) or complete (success). In addition, if the transfer is still in progress, the user can get the number of words that have been transferred up to now.

Parameters
instanceThe instance number of the LPSPI peripheral.
bytesRemainedPointer to a value that is filled in with the number of bytes that must be received.
Returns
STATUS_SUCCESS The transfer has completed successfully, or STATUS_BUSY The transfer is still in progress. framesTransferred is filled with the number of words that have been transferred so far.

Definition at line 532 of file lpspi_master_driver.c.

status_t LPSPI_DRV_MasterInit ( uint32_t  instance,
lpspi_state_t lpspiState,
const lpspi_master_config_t spiConfig 
)

Initializes a LPSPI instance for interrupt driven master mode operation.

This function uses an interrupt-driven method for transferring data. In this function, the term "spiConfig" is used to indicate the SPI device for which the LPSPI master is communicating. This function initializes the run-time state structure to track the ongoing transfers, un-gates the clock to the LPSPI module, resets the LPSPI module, configures the IRQ state structure, enables the module-level interrupt to the core, and enables the LPSPI module. This is an example to set up the lpspi_master_state_t and call the LPSPI_DRV_MasterInit function by passing in these parameters:

1 lpspi_master_state_t lpspiMasterState; <- the user allocates memory for this structure
2 lpspi_master_config_t spiConfig; Can declare more configs for use in transfer functions
3 spiConfig.bitsPerSec = 500000;
4 spiConfig.whichPcs = LPSPI_PCS0;
5 spiConfig.pcsPolarity = LPSPI_ACTIVE_LOW;
6 spiConfig.isPcsContinuous = false;
7 spiConfig.bitCount = 16;
8 spiConfig.clkPhase = LPSPI_CLOCK_PHASE_1ST_EDGE;
9 spiConfig.clkPolarity = LPSPI_ACTIVE_HIGH;
10 spiConfig.lsbFirst= false;
11 spiConfig.transferType = LPSPI_USING_INTERRUPTS;
12 LPSPI_DRV_MasterInit(masterInstance, &lpspiMasterState, &spiConfig);
Parameters
instanceThe instance number of the LPSPI peripheral.
lpspiStateThe pointer to the LPSPI master driver state structure. The user passes the memory for this run-time state structure. The LPSPI master driver populates the members. This run-time state structure keeps track of the transfer in progress.
spiConfigThe data structure containing information about a device on the SPI bus
Returns
An error code or STATUS_SUCCESS.

Definition at line 140 of file lpspi_master_driver.c.

void LPSPI_DRV_MasterIRQHandler ( uint32_t  instance)

Interrupt handler for LPSPI master mode. This handler uses the buffers stored in the lpspi_master_state_t structs to transfer data.

Parameters
instanceThe instance number of the LPSPI peripheral.

Interrupt handler for LPSPI master mode. This handler uses the buffers stored in the lpspi_master_state_t structs to transfer data.

Definition at line 795 of file lpspi_master_driver.c.

status_t LPSPI_DRV_MasterSetDelay ( uint32_t  instance,
uint32_t  delayBetwenTransfers,
uint32_t  delaySCKtoPCS,
uint32_t  delayPCStoSCK 
)

Configures the LPSPI master mode bus timing delay options.

This function involves the LPSPI module's delay options to "fine tune" some of the signal timings and match the timing needs of a slower peripheral device. This is an optional function that can be called after the LPSPI module has been initialized for master mode. The timings are adjusted in terms of cycles of the baud rate clock. The bus timing delays that can be adjusted are listed below:

SCK to PCS Delay: Adjustable delay option between the last edge of SCK to the de-assertion of the PCS signal.

PCS to SCK Delay: Adjustable delay option between the assertion of the PCS signal to the first SCK edge.

Delay between Transfers: Adjustable delay option between the de-assertion of the PCS signal for a frame to the assertion of the PCS signal for the next frame.

Parameters
instanceThe instance number of the LPSPI peripheral.
delayBetwenTransfersMinimum delay between 2 transfers in microseconds
delaySCKtoPCSMinimum delay between SCK and PCS
delayPCStoSCKMinimum delay between PCS and SCK
Returns
STATUS_SUCCESS The transfer has completed successfully, or STATUS_ERROR if driver is error and needs to clean error.

Definition at line 237 of file lpspi_master_driver.c.

status_t LPSPI_DRV_MasterTransfer ( uint32_t  instance,
const uint8_t *  sendBuffer,
uint8_t *  receiveBuffer,
uint16_t  transferByteCount 
)

Performs an interrupt driven non-blocking SPI master mode transfer.

This function simultaneously sends and receives data on the SPI bus, as SPI is naturally a full-duplex bus. The function returns immediately after initiating the transfer. The user needs to check whether the transfer is complete using the LPSPI_DRV_MasterGetTransferStatus function. This function allows the user to optionally pass in a SPI configuration structure which allows the user to change the SPI bus attributes in conjunction with initiating a SPI transfer. The difference between passing in the SPI configuration structure here as opposed to the configure bus function is that the configure bus function returns the calculated baud rate where this function does not. The user can also call the configure bus function prior to the transfer in which case the user would simply pass in a NULL to the transfer function's device structure parameter.

Parameters
instanceThe instance number of the LPSPI peripheral.
spiConfigPointer to the SPI configuration structure. This structure contains the settings for the SPI bus configuration in this transfer. You may pass NULL for this parameter, in which case the current bus configuration is used unmodified. The device can be configured separately by calling the LPSPI_DRV_MasterConfigureBus function.
sendBufferThe pointer to the data buffer of the data to send. You may pass NULL for this parameter and bytes with a value of 0 (zero) is sent.
receiveBufferPointer to the buffer where the received bytes are stored. If you pass NULL for this parameter, the received bytes are ignored.
transferByteCountThe number of bytes to send and receive.
Returns
STATUS_SUCCESS The transfer was successful, or STATUS_BUSY Cannot perform transfer because a transfer is already in progress

Definition at line 495 of file lpspi_master_driver.c.

status_t LPSPI_DRV_MasterTransferBlocking ( uint32_t  instance,
const uint8_t *  sendBuffer,
uint8_t *  receiveBuffer,
uint16_t  transferByteCount,
uint32_t  timeout 
)

Performs an interrupt driven blocking SPI master mode transfer.

This function simultaneously sends and receives data on the SPI bus, as SPI is naturally a full-duplex bus. The function does not return until the transfer is complete. This function allows the user to optionally pass in a SPI configuration structure which allows the user to change the SPI bus attributes in conjunction with initiating a SPI transfer. The difference between passing in the SPI configuration structure here as opposed to the configure bus function is that the configure bus function returns the calculated baud rate where this function does not. The user can also call the configure bus function prior to the transfer in which case the user would simply pass in a NULL to the transfer function's device structure parameter.

Parameters
instanceThe instance number of the LPSPI peripheral.
sendBufferThe pointer to the data buffer of the data to send. You may pass NULL for this parameter and bytes with a value of 0 (zero) is sent.
receiveBufferPointer to the buffer where the received bytes are stored. If you pass NULL for this parameter, the received bytes are ignored.
transferByteCountThe number of bytes to send and receive.
timeoutA timeout for the transfer in milliseconds. If the transfer takes longer than this amount of time, the transfer is aborted and a STATUS_TIMEOUT error returned.
Returns
STATUS_SUCCESS The transfer was successful, or STATUS_BUSY Cannot perform transfer because a transfer is already in progress, or STATUS_TIMEOUT The transfer timed out and was aborted.

Definition at line 417 of file lpspi_master_driver.c.

void LPSPI_DRV_ReadRXBuffer ( uint32_t  instance)

The function LPSPI_DRV_ReadRXBuffer reads data from RX hardware buffer and writes this data in RX software buffer.

The function LPSPI_DRV_ReadRXBuffer reads data from RX hardware buffer and writes this data in RX software buffer.

Definition at line 200 of file lpspi_shared_function.c.

status_t LPSPI_DRV_SlaveAbortTransfer ( uint32_t  instance)

Aborts the transfer that started by a non-blocking call transfer function.

This function stops the transfer which was started by the calling the SPI_DRV_SlaveTransfer() function.

Parameters
instanceThe instance number of SPI peripheral
Returns
STATUS_SUCCESS if everything is OK.

Definition at line 432 of file lpspi_slave_driver.c.

status_t LPSPI_DRV_SlaveDeinit ( uint32_t  instance)

Shuts down an LPSPI instance interrupt mechanism.

Disables the LPSPI module, gates its clock, and changes the LPSPI slave driver state to NonInit for the LPSPI slave module which is initialized with interrupt mechanism. After de-initialization, the user can re-initialize the LPSPI slave module with other mechanisms.

Parameters
instanceThe instance number of the LPSPI peripheral.
Returns
STATUS_SUCCESS if driver starts to send/receive data successfully. STATUS_ERROR if driver is error and needs to clean error. STATUS_BUSY if a transfer is in progress

Definition at line 175 of file lpspi_slave_driver.c.

status_t LPSPI_DRV_SlaveGetTransferStatus ( uint32_t  instance,
uint32_t *  bytesRemained 
)

Returns whether the previous transfer is finished.

When performing an a-sync transfer, the user can call this function to ascertain the state of the current transfer: in progress (or busy) or complete (success). In addition, if the transfer is still in progress, the user can get the number of words that have been transferred up to now.

Parameters
instanceThe instance number of the LPSPI peripheral.
bytesRemainedPointer to value that is filled in with the number of frames that have been sent in the active transfer. A frame is defined as the number of bits per frame.
Returns
STATUS_SUCCESS The transfer has completed successfully, or STATUS_BUSY The transfer is still in progress. STATUS_ERROR if driver is error and needs to clean error.

Definition at line 468 of file lpspi_slave_driver.c.

status_t LPSPI_DRV_SlaveInit ( uint32_t  instance,
lpspi_state_t lpspiState,
const lpspi_slave_config_t slaveConfig 
)

Initializes a LPSPI instance for a slave mode operation, using interrupt mechanism.

This function un-gates the clock to the LPSPI module, initializes the LPSPI for slave mode. After it is initialized, the LPSPI module is configured in slave mode and the user can start transmitting and receiving data by calling send, receive, and transfer functions. This function indicates LPSPI slave uses an interrupt mechanism.

Parameters
instanceThe instance number of the LPSPI peripheral.
lpspiStateThe pointer to the LPSPI slave driver state structure.
slaveConfigThe configuration structure lpspi_slave_user_config_t which configures the data bus format.
Returns
An error code or STATUS_SUCCESS.

Definition at line 103 of file lpspi_slave_driver.c.

void LPSPI_DRV_SlaveIRQHandler ( uint32_t  instance)

Interrupt handler for LPSPI slave mode. This handler uses the buffers stored in the lpspi_master_state_t structs to transfer data.

Parameters
instanceThe instance number of the LPSPI peripheral.

Definition at line 371 of file lpspi_slave_driver.c.

status_t LPSPI_DRV_SlaveTransfer ( uint32_t  instance,
const uint8_t *  sendBuffer,
uint8_t *  receiveBuffer,
uint16_t  transferByteCount 
)

Starts the transfer data on LPSPI bus using an interrupt and a non-blocking call.

Parameters
instanceThe instance number of LPSPI peripheral
sendBufferThe pointer to data that user wants to transmit.
receiveBufferThe pointer to data that user wants to store received data.
transferByteCountThe number of bytes to send and receive.
Returns
STATUS_SUCCESS if driver starts to send/receive data successfully. STATUS_ERROR if driver is error and needs to clean error. STATUS_BUSY if a transfer is in progress

Definition at line 241 of file lpspi_slave_driver.c.

status_t LPSPI_DRV_SlaveTransferBlocking ( uint32_t  instance,
const uint8_t *  sendBuffer,
uint8_t *  receiveBuffer,
uint16_t  transferByteCount,
uint32_t  timeout 
)

Transfers data on LPSPI bus using interrupt and a blocking call.

This function checks the driver status and mechanism, and transmits/receives data through the LPSPI bus. If the sendBuffer is NULL, the transmit process is ignored. If the receiveBuffer is NULL, the receive process is ignored. If both the receiveBuffer and the sendBuffer are available, the transmit and the receive progress is processed. If only the receiveBuffer is available, the receive is processed. Otherwise, the transmit is processed. This function only returns when the processes are completed. This function uses an interrupt mechanism.

Parameters
instanceThe instance number of LPSPI peripheral
sendBufferThe pointer to data that user wants to transmit.
receiveBufferThe pointer to data that user wants to store received data.
transferByteCountThe number of bytes to send and receive.
timeoutThe maximum number of milliseconds that function waits before timed out reached.
Returns
STATUS_SUCCESS if driver starts to send/receive data successfully. STATUS_ERROR if driver is error and needs to clean error. STATUS_BUSY if a transfer is in progress STATUS_TIMEOUT if time out reached while transferring is in progress.

Definition at line 203 of file lpspi_slave_driver.c.

Variable Documentation

Table of base pointers for SPI instances.

Definition at line 77 of file lpspi_shared_function.c.

Table to save LPSPI IRQ enumeration numbers defined in the CMSIS header file.

Definition at line 80 of file lpspi_shared_function.c.

Definition at line 83 of file lpspi_shared_function.c.