![]() |
Kinetis Bootloader
2.0.0
Common bootloader for Kinetis devices
|
Collaboration diagram for LPSPI Peripheral driver:Data Structures | |
| struct | lpspi_master_config_t |
| LPSPI master config structure. More... | |
| struct | lpspi_slave_config_t |
| LPSPI slave config structure. More... | |
| struct | lpspi_transfer_t |
| LPSPI master/slave transfer structure. More... | |
| struct | lpspi_master_handle_t |
| LPSPI master transfer handle structure used for transactional API. More... | |
| struct | lpspi_slave_handle_t |
| LPSPI slave transfer handle structure used for transactional API. More... | |
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. More... | |
| 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. More... | |
Enumerations | |
| 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_t { kLPSPI_Master = 1U, kLPSPI_Slave = 0U } |
| LPSPI master or slave mode configuration. More... | |
| enum | lpspi_which_pcs_t { 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_t { 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_t { kLPSPI_ClockPolarityActiveHigh = 0U, kLPSPI_ClockPolarityActiveLow = 1U } |
| LPSPI clock polarity configuration. More... | |
| enum | lpspi_clock_phase_t { kLPSPI_ClockPhaseFirstEdge = 0U, kLPSPI_ClockPhaseSecondEdge = 1U } |
| LPSPI clock phase configuration. More... | |
| enum | lpspi_shift_direction_t { kLPSPI_MsbFirst = 0U, kLPSPI_LsbFirst = 1U } |
| LPSPI data shifter direction options. More... | |
| enum | lpspi_host_request_select_t { kLPSPI_HostReqExtPin = 0U, kLPSPI_HostReqInternalTrigger = 1U } |
| LPSPI Host Request select configuration. More... | |
| enum | lpspi_match_config_t { 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_t { kLPSPI_SdiInSdoOut = 0U, kLPSPI_SdoInSdoOut = 1U, kLPSPI_SdiInSdiOut = 2U, kLPSPI_SdoInSdiOut = 3U } |
| LPSPI pin (SDO and SDI) configuration. More... | |
| enum | lpspi_data_out_config_t { kLpspiDataOutRetained = 0U, kLpspiDataOutTristate = 1U } |
| LPSPI data output configuration. More... | |
| enum | lpspi_transfer_width_t { kLPSPI_SingleBitXfer = 0U, kLPSPI_TwoBitXfer = 1U, kLPSPI_FourBitXfer = 2U } |
| LPSPI transfer width configuration. More... | |
| enum | lpspi_delay_type_t { 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 = 1U << 22 } |
| Can use this enum 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 = 1U << 22 } |
| Can use this enum 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 transactiaonl APIs' state machine. More... | |
Initialization and deinitialization | |
| void | LPSPI_MasterInit (LPSPI_Type *base, const lpspi_master_config_t *masterConfig, uint32_t srcClock_Hz) |
| LPSPI master Init. More... | |
| void | LPSPI_MasterGetDefaultConfig (lpspi_master_config_t *masterConfig) |
| Set the lpspi_master_config_t structure to default values. More... | |
| void | LPSPI_SlaveInit (LPSPI_Type *base, const lpspi_slave_config_t *slaveConfig) |
| LPSPI slave configuration. More... | |
| void | LPSPI_SlaveGetDefaultConfig (lpspi_slave_config_t *slaveConfig) |
| Set the lpspi_slave_config_t structure to default values. More... | |
| void | LPSPI_Deinit (LPSPI_Type *base) |
| De-initialize the LPSPI peripheral, call this API to disbale the lpspi clock. More... | |
| void | LPSPI_Reset (LPSPI_Type *base) |
| Restores the LPSPI peripheral to reset state, notice that this function will set all the registers to reset state so the LPSPI module can not work after calling this API. More... | |
| static void | LPSPI_Enable (LPSPI_Type *base, bool enable) |
| Enables the LPSPI peripheral and sets the MCR MDIS to 0. More... | |
Status | |
| static uint32_t | LPSPI_GetStatusFlags (LPSPI_Type *base) |
| Gets the LPSPI status flag state. More... | |
| static uint32_t | LPSPI_GetTxFifoSize (LPSPI_Type *base) |
| Gets the LPSPI Tx FIFO size. More... | |
| static uint32_t | LPSPI_GetRxFifoSize (LPSPI_Type *base) |
| Gets the LPSPI Rx FIFO size. More... | |
| static uint32_t | LPSPI_GetTxFifoCount (LPSPI_Type *base) |
| Gets the LPSPI Tx FIFO count. More... | |
| static uint32_t | LPSPI_GetRxFifoCount (LPSPI_Type *base) |
| Gets the LPSPI Rx FIFO count. More... | |
| static void | LPSPI_ClearStatusFlags (LPSPI_Type *base, uint32_t statusFlags) |
| Clears the LPSPI status flag. More... | |
Interrupts | |
| static void | LPSPI_EnableInterrupts (LPSPI_Type *base, uint32_t mask) |
| Enable the LPSPI interrupts. More... | |
| static void | LPSPI_DisableInterrupts (LPSPI_Type *base, uint32_t mask) |
| Disable the LPSPI interrupts. More... | |
DMA Control | |
| static void | LPSPI_EnableDMA (LPSPI_Type *base, uint32_t mask) |
| Enable the LPSPI DMA request. More... | |
| static void | LPSPI_DisableDMA (LPSPI_Type *base, uint32_t mask) |
| Disable the LPSPI DMA request. More... | |
| static uint32_t | LPSPI_GetTxRegisterAddress (LPSPI_Type *base) |
| Gets the LPSPI Transmit Data Register address for DMA operation. More... | |
| static uint32_t | LPSPI_GetRxRegisterAddress (LPSPI_Type *base) |
| Gets the LPSPI Receive Data Register address for DMA operation. More... | |
Bus Operations | |
| static void | LPSPI_SetMasterSlaveMode (LPSPI_Type *base, lpspi_master_slave_mode_t mode) |
| Configures the LPSPI for master or slave. More... | |
| static bool | LPSPI_IsMaster (LPSPI_Type *base) |
| Returns whether the LPSPI module is in master mode. More... | |
| static void | LPSPI_FlushFifo (LPSPI_Type *base, bool flushTxFifo, bool flushRxFifo) |
| Flushes the LPSPI FIFOs. More... | |
| static void | LPSPI_SetFifoWatermarks (LPSPI_Type *base, uint32_t txWater, uint32_t rxWater) |
| Sets the transmit and receive FIFO watermark values. More... | |
| static void | LPSPI_SetAllPcsPolarity (LPSPI_Type *base, uint32_t mask) |
| Configures all the LPSPI peripheral chip select polarity simultaneously. More... | |
| static void | LPSPI_SetFrameSize (LPSPI_Type *base, uint32_t frameSize) |
| Configures the frame size . More... | |
| 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. More... | |
| 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). More... | |
| 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). More... | |
| static void | LPSPI_WriteDataNonBlocking (LPSPI_Type *base, uint32_t data) |
| Writes data into the transmit data buffer. More... | |
| static uint32_t | LPSPI_ReadDataNonBlocking (LPSPI_Type *base) |
| Reads data from the data buffer. More... | |
| status_t | LPSPI_MasterTransferBlocking (LPSPI_Type *base, lpspi_transfer_t *transfer) |
| LPSPI master transfer data using polling. More... | |
Transactional | |
| void | LPSPI_MasterCreateHandle (LPSPI_Type *base, lpspi_master_handle_t *handle, lpspi_master_transfer_callback_t callback, void *userData) |
| Initialize the lpspi master handle. More... | |
| status_t | LPSPI_MasterTransferNonBlocking (LPSPI_Type *base, lpspi_master_handle_t *handle, lpspi_transfer_t *transfer) |
| LPSPI master transfer data using interrupt. More... | |
| status_t | LPSPI_MasterGetTransferCount (LPSPI_Type *base, lpspi_master_handle_t *handle, size_t *count) |
| Get the master transfer remaining bytes. More... | |
| void | LPSPI_MasterAbortTransfer (LPSPI_Type *base, lpspi_master_handle_t *handle) |
| LPSPI master abort transfer which using interrupt. More... | |
| void | LPSPI_MasterHandleInterrupt (LPSPI_Type *base, lpspi_master_handle_t *handle) |
| LPSPI Master IRQ handler function. More... | |
| void | LPSPI_SlaveCreateHandle (LPSPI_Type *base, lpspi_slave_handle_t *handle, lpspi_slave_transfer_callback_t callback, void *userData) |
| Initialize the lpspi slave handle. More... | |
| status_t | LPSPI_SlaveTransferNonBlocking (LPSPI_Type *base, lpspi_slave_handle_t *handle, lpspi_transfer_t *transfer) |
| LPSPI slave transfer data using interrupt. More... | |
| status_t | LPSPI_SlaveGetTransferCount (LPSPI_Type *base, lpspi_slave_handle_t *handle, size_t *count) |
| Get the slave transfer remaining bytes. More... | |
| void | LPSPI_SlaveAbortTransfer (LPSPI_Type *base, lpspi_slave_handle_t *handle) |
| LPSPI slave abort transfer which using interrupt. More... | |
| void | LPSPI_SlaveHandleInterrupt (LPSPI_Type *base, lpspi_slave_handle_t *handle) |
| LPSPI Slave IRQ handler function. More... | |
This section describes the programming interface of the LPSPI Peripheral driver. The LPSPI driver configures LPSPI module, provides the functional and transactional interfaces to build the LPSPI application.
This function group initializes the default configuration structure for master and slave, initializes the LPSPI master with a master configuration, initializes the LPSPI slave with a slave configuration, and de-initializes the LPSPI module.
This function group enables/disables the LPSPI module both interrupt and DMA, gets the data register address for the DMA transfer, sets master and slave, starts and stops the transfer, and so on.
This function group controls the transfer, master send/receive data, and slave send/receive data.
This function group gets/clears the LPSPI status.
This function group transfers a block of data, gets the transfer status, and aborts the transfer.
| struct lpspi_master_config_t |
LPSPI master config structure.
| Data Fields | ||
|---|---|---|
| uint32_t | baudRate |
Baud Rate for lpspi. |
| uint32_t | betweenTransferDelayInNanoSec |
After SCK delay time with nanosecond , set to 0 will set the minimum delay.It woulde set the boundary value if out of range that can be set. |
| uint32_t | bitsPerFrame |
Bits per frame, minimum 8, maximum 4096. |
| lpspi_clock_phase_t | cpha |
Clock phase. |
| lpspi_clock_polarity_t | cpol |
Clock polarity. |
| lpspi_data_out_config_t | dataOutConfig |
Configures if the output data is tristated between accesses (LPSPI_PCS is negated). |
| lpspi_shift_direction_t | direction |
MSB or LSB data shift direction. |
| uint32_t | lastSckToPcsDelayInNanoSec |
Last SCK to PCS delay time with nanosecond , set to 0 will set the minimum delay.It woulde set the boundary value if out of range that can be set. |
| lpspi_pcs_polarity_config_t | pcsActiveHighOrLow |
Desired PCS active high or low |
| uint32_t | pcsToSckDelayInNanoSec |
PCS to SCK delay time with nanosecond , set to 0 will set the minimum delay. It woulde set the boundary value if out of range that can be set. |
| lpspi_pin_config_t | pinCfg |
Configures which pins are used for input and output data during single bit transfers. |
| lpspi_which_pcs_t | whichPcs |
Desired Peripheral Chip Select (pcs) |
| struct lpspi_slave_config_t |
LPSPI slave config structure.
| Data Fields | ||
|---|---|---|
| uint32_t | bitsPerFrame |
Bits per frame, minimum 8, maximum 4096. |
| lpspi_clock_phase_t | cpha |
Clock phase. |
| lpspi_clock_polarity_t | cpol |
Clock polarity. |
| lpspi_data_out_config_t | dataOutConfig |
Configures if the output data is tristated between accesses (LPSPI_PCS is negated). |
| lpspi_shift_direction_t | direction |
MSB or LSB data shift direction. |
| lpspi_pcs_polarity_config_t | pcsActiveHighOrLow |
Desired PCS active high or low |
| lpspi_pin_config_t | pinCfg |
Configures which pins are used for input and output data during single bit transfers. |
| lpspi_which_pcs_t | whichPcs |
Desired Peripheral Chip Select (pcs) |
| struct lpspi_transfer_t |
LPSPI master/slave transfer structure.
| struct _lpspi_master_handle |
LPSPI master transfer handle structure used for transactional API.
Forward declaration of the _lpspi_master_handle typedefs.
| Data Fields | ||
|---|---|---|
| LPSPI_Type * | base |
LPSPI base address. |
| volatile uint8_t | bytesEachRead |
Bytes for each read RDR . |
| volatile uint8_t | bytesEachWrite |
Bytes for each write TDR . |
| lpspi_master_transfer_callback_t | callback |
Completion callback. |
| volatile uint8_t | fifoSize |
Fifo dataSize. |
| volatile bool | isByteSwap |
A flag that whether should byte swap. |
| volatile bool | isPcsContinuous |
Is PCS continuous in transfer. |
| volatile uint32_t | readRegRemainingTimes |
read RDR register remaining times . |
| uint8_t *volatile | rxData |
Receive buffer. |
| volatile size_t | rxRemainingByteCount |
Number of bytes remaining to receive. |
| volatile uint8_t | rxWatermark |
Rx watermark. |
| volatile uint8_t | state |
LPSPI transfer state , _lpspi_transfer_state. |
| uint32_t | totalByteCount |
Number of transfer bytes |
| uint32_t | txBuffIfNull |
Used if there is not txData for DMA purpose. |
| uint8_t *volatile | txData |
Send buffer. |
| volatile size_t | txRemainingByteCount |
Number of bytes remaining to send. |
| void * | userData |
Callback user data. |
| volatile uint32_t | writeRegRemainingTimes |
write TDR register remaining times . |
| volatile bool | writeTcrInIsr |
A flag that whether should write TCR in ISR. |
| struct _lpspi_slave_handle |
LPSPI slave transfer handle structure used for transactional API.
Forward declaration of the _lpspi_slave_handle typedefs.
| Data Fields | ||
|---|---|---|
| LPSPI_Type * | base |
LPSPI base address. |
| volatile uint8_t | bytesEachRead |
Bytes for each read RDR . |
| volatile uint8_t | bytesEachWrite |
Bytes for each write TDR . |
| lpspi_slave_transfer_callback_t | callback |
Completion callback. |
| volatile uint32_t | errorCount |
Error count for slave transfer. |
| volatile uint8_t | fifoSize |
Fifo dataSize. |
| volatile bool | isByteSwap |
A flag that whether should byte swap. |
| volatile uint32_t | readRegRemainingTimes |
read RDR register remaining times . |
| uint8_t *volatile | rxData |
Receive buffer. |
| volatile size_t | rxRemainingByteCount |
Number of bytes remaining to receive. |
| volatile uint8_t | rxWatermark |
Rx watermark. |
| volatile uint8_t | state |
LPSPI transfer state , _lpspi_transfer_state. |
| uint32_t | totalByteCount |
Number of transfer bytes |
| uint8_t *volatile | txData |
Send buffer. |
| volatile size_t | txRemainingByteCount |
Number of bytes remaining to send. |
| void * | userData |
Callback user data. |
| volatile uint32_t | writeRegRemainingTimes |
write TDR register remaining times . |
| 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.
| base | LPSPI peripheral address. |
| handle | Pointer to the handle for the LPSPI master. |
| status | Success or error code describing whether the transfer completed. |
| userData | Arbitrary pointer-dataSized value passed from the application. |
| 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.
| base | LPSPI peripheral address. |
| handle | Pointer to the handle for the LPSPI slave. |
| status | Success or error code describing whether the transfer completed. |
| userData | Arbitrary pointer-dataSized value passed from the application. |
| enum _lpspi_dma_enable |
| enum _lpspi_flags |
LPSPI status flags in SPIx_SR register.
LPSPI interrupt source.
| enum _lpspi_pcs_polarity |
LPSPI Peripheral Chip Select (Pcs) Polarity.
| enum _lpspi_status |
Can use this enum for LPSPI master transfer configFlags.
Can use this enum for LPSPI slave transfer configFlags.
| enum lpspi_clock_phase_t |
| enum lpspi_delay_type_t |
| enum lpspi_match_config_t |
LPSPI Match configuration options.
| enum lpspi_pin_config_t |
| enum lpspi_which_pcs_t |
|
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:
| base | LPSPI peripheral address. |
| statusFlags | The status flag , used from type _lpspi_flags. |
< The status flags are cleared by writing 1 (w1c).
| void LPSPI_Deinit | ( | LPSPI_Type * | base | ) |
De-initialize the LPSPI peripheral, call this API to disbale the lpspi clock.
| base | LPSPI peripheral address. |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Enables the LPSPI peripheral and sets the MCR MDIS to 0.
| base | LPSPI peripheral address. |
| enable | pass true to enable module, false to disable module. |
|
inlinestatic |
|
inlinestatic |
Enable the LPSPI interrupts.
This function configures the various interrupt masks of the LPSPI. The parameters are base, interrupt mask. Note, for Tx Fill and Rx FIFO Drain requests, enable the interrupt request will disable the DMA request in the meanwhile.
| base | LPSPI peripheral address. |
| mask | The interrupt mask, can use the enum _lpspi_interrupt_enable. |
|
inlinestatic |
Flushes the LPSPI FIFOs.
| base | LPSPI peripheral address. |
| flushTxFifo | Flushes (true) the Tx FIFO, else do not flush (false) the Tx FIFO |
| flushRxFifo | Flushes (true) the Rx FIFO, else do not flush (false) the Rx FIFO |
|
inlinestatic |
Gets the LPSPI Rx FIFO count.
| base | LPSPI peripheral address. |
|
inlinestatic |
Gets the LPSPI Rx FIFO size.
| base | LPSPI peripheral address. |
|
inlinestatic |
Gets the LPSPI Receive Data Register address for DMA operation.
This function gets the LPSPI Receive Data Register address as this value is needed for the DMA operation. This function can be used for either master or slave mode.
| base | LPSPI peripheral address. |
|
inlinestatic |
Gets the LPSPI status flag state.
| base | LPSPI peripheral address. |
|
inlinestatic |
Gets the LPSPI Tx FIFO count.
| base | LPSPI peripheral address. |
|
inlinestatic |
Gets the LPSPI Tx FIFO size.
| base | LPSPI peripheral address. |
|
inlinestatic |
Gets the LPSPI Transmit Data Register address for DMA operation.
This function gets the LPSPI Transmit Data Register address as this value is needed for the DMA operation. This function can be used for either master or slave mode.
| base | LPSPI peripheral address. |
|
inlinestatic |
Returns whether the LPSPI module is in master mode.
| base | LPSPI peripheral address. |
| void LPSPI_MasterAbortTransfer | ( | LPSPI_Type * | base, |
| lpspi_master_handle_t * | handle | ||
| ) |
LPSPI master abort transfer which using interrupt.
This function abort transfer which using interrupt.
| base | LPSPI peripheral address. |
| handle | pointer to lpspi_master_handle_t structure which stores the transfer state. |
| void LPSPI_MasterCreateHandle | ( | LPSPI_Type * | base, |
| lpspi_master_handle_t * | handle, | ||
| lpspi_master_transfer_callback_t | callback, | ||
| void * | userData | ||
| ) |
Initialize 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, user need only call this API once to get the initialized handle.
| base | LPSPI peripheral address. |
| handle | LPSPI handle pointer to lpspi_master_handle_t. |
| callback | dspi callback. |
| userData | callback function parameter. |
| void LPSPI_MasterGetDefaultConfig | ( | lpspi_master_config_t * | masterConfig | ) |
Set the lpspi_master_config_t structure to default values.
The purpose of this API is to get the config structure initialized for LPSPI_MasterInit(). User may use the initialized structure unchanged in LPSPI_MasterInit(), or modify some fields of the structure before calling LPSPI_MasterInit(). Example:
| masterConfig | pointer to lpspi_master_config_t structure |
| status_t LPSPI_MasterGetTransferCount | ( | LPSPI_Type * | base, |
| lpspi_master_handle_t * | handle, | ||
| size_t * | count | ||
| ) |
Get the master transfer remaining bytes.
This function get the master transfer remaining bytes.
| base | LPSPI peripheral address. |
| handle | pointer to lpspi_master_handle_t structure which stores the transfer state. |
| count | Number of bytes transferred so far by the non-blocking transaction. |
| void LPSPI_MasterHandleInterrupt | ( | LPSPI_Type * | base, |
| lpspi_master_handle_t * | handle | ||
| ) |
LPSPI Master IRQ handler function.
This function process the LPSPI transmit and receive IRQ.
| base | LPSPI peripheral address. |
| handle | pointer to lpspi_master_handle_t structure which stores the transfer state. |
| void LPSPI_MasterInit | ( | LPSPI_Type * | base, |
| const lpspi_master_config_t * | masterConfig, | ||
| uint32_t | srcClock_Hz | ||
| ) |
LPSPI master Init.
| base | LPSPI peripheral address. |
| masterConfig | Pointer to structure lpspi_master_config_t. |
| srcClock_Hz | Module source input clock in Hertz |
| 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 that the caller also provide the frequency of the module source clock (in Hertz). Also 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.
| base | LPSPI peripheral address. |
| baudRate_Bps | The desired baud rate in bits per second |
| srcClock_Hz | Module source input clock in Hertz |
| tcrPrescaleValue | The TCR prescale value, needed by user to program the TCR |
| 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.
| base | LPSPI peripheral address. |
| scaler | The 8-bit delay value 0x00 to 0xFF (255) |
| whichDelay | The desired delay to configure, must be of type lpspi_delay_type_t |
| 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 first be disabled before configuring this. Note that the LPSPI module must be configured for master mode before configuring this.
| base | LPSPI peripheral address. |
| delayTimeInNanoSec | The desired delay value in nano-seconds. |
| whichDelay | The desired delay to configure, must be of type lpspi_delay_type_t |
| srcClock_Hz | Module source input clock in Hertz |
| status_t LPSPI_MasterTransferBlocking | ( | LPSPI_Type * | base, |
| lpspi_transfer_t * | transfer | ||
| ) |
LPSPI master transfer data using polling.
This function transfer data with polling, this is blocking function, will not return until all transfer 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 situation: 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 integer multiples of bytesPerFrame.
| base | LPSPI peripheral address. |
| transfer | pointer to lpspi_transfer_t structure. |
| status_t LPSPI_MasterTransferNonBlocking | ( | LPSPI_Type * | base, |
| lpspi_master_handle_t * | handle, | ||
| lpspi_transfer_t * | transfer | ||
| ) |
LPSPI master transfer data using interrupt.
This function transfer data using interrupt , this is non-blocking function, will return right away, when all data have been transfer, the callback function will be 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 situation: 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 integer multiples of bytesPerFrame.
| base | LPSPI peripheral address. |
| handle | pointer to lpspi_master_handle_t structure which stores the transfer state. |
| transfer | pointer to lpspi_transfer_t structure. |
|
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.
| base | LPSPI peripheral address. |
| void LPSPI_Reset | ( | LPSPI_Type * | base | ) |
Restores the LPSPI peripheral to reset state, notice that this function will set all the registers to reset state so the LPSPI module can not work after calling this API.
| base | LPSPI peripheral address. |
|
inlinestatic |
Configures all the LPSPI peripheral chip select polarity simultaneously.
Note that the CFGR1 should only be written when the LPSPI is disabled (LPSPIx_CR_MEN = 0).
This is an example: PCS0,PCS1 set to active low and other PCS set to active high. Please note that the number of PCS is specific to the device.
| base | LPSPI peripheral address. |
| mask | The PCS polarity mask , can use the enum _lpspi_pcs_polarity. |
|
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 setting 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.
| base | LPSPI peripheral address. |
| txWater | The TX FIFO watermark value . Writing a value equal or greater than the FIFO size will be truncated. |
| rxWater | The RX FIFO watermark value . Writing a value equal or greater than the FIFO size will be truncated. |
|
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, then 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 will not update until after the LPSPI is enabled. Once 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 shoule be write when the Tx Fifo is not full.
| base | LPSPI peripheral address. |
| frameSize | The frame size in number of bits. |
|
inlinestatic |
Configures the LPSPI for master or slave.
Note that the CFGR1 should only be written when the LPSPI is disabled (LPSPIx_CR_MEN = 0).
| base | LPSPI peripheral address. |
| mode | Mode setting (master or slave) of type lpspi_master_slave_mode_t. |
| void LPSPI_SlaveAbortTransfer | ( | LPSPI_Type * | base, |
| lpspi_slave_handle_t * | handle | ||
| ) |
LPSPI slave abort transfer which using interrupt.
This function abort transfer which using interrupt.
| base | LPSPI peripheral address. |
| handle | pointer to lpspi_slave_handle_t structure which stores the transfer state. |
| void LPSPI_SlaveCreateHandle | ( | LPSPI_Type * | base, |
| lpspi_slave_handle_t * | handle, | ||
| lpspi_slave_transfer_callback_t | callback, | ||
| void * | userData | ||
| ) |
Initialize 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, user need only call this API once to get the initialized handle.
| base | LPSPI peripheral address. |
| handle | LPSPI handle pointer to lpspi_slave_handle_t. |
| callback | dspi callback. |
| userData | callback function parameter. |
| void LPSPI_SlaveGetDefaultConfig | ( | lpspi_slave_config_t * | slaveConfig | ) |
Set the lpspi_slave_config_t structure to default values.
The purpose of this API is to get the config structure initialized for LPSPI_SlaveInit(). User may use the initialized structure unchanged in LPSPI_SlaveInit(), or modify some fields of the structure before calling LPSPI_SlaveInit(). Example:
| slaveConfig | pointer to lpspi_slave_config_t structure. |
< Bits per frame, minimum 4, maximum 16.
< Clock polarity.
< Clock phase.
< MSB or LSB data shift direction.
< Desired Peripheral Chip Select (pcs)
< Desired PCS active high or low
| status_t LPSPI_SlaveGetTransferCount | ( | LPSPI_Type * | base, |
| lpspi_slave_handle_t * | handle, | ||
| size_t * | count | ||
| ) |
Get the slave transfer remaining bytes.
This function get the slave transfer remaining bytes.
| base | LPSPI peripheral address. |
| handle | pointer to lpspi_slave_handle_t structure which stores the transfer state. |
| count | Number of bytes transferred so far by the non-blocking transaction. |
| void LPSPI_SlaveHandleInterrupt | ( | LPSPI_Type * | base, |
| lpspi_slave_handle_t * | handle | ||
| ) |
LPSPI Slave IRQ handler function.
This function process the LPSPI transmit and receive IRQ.
| base | LPSPI peripheral address. |
| handle | pointer to lpspi_slave_handle_t structure which stores the transfer state. |
| void LPSPI_SlaveInit | ( | LPSPI_Type * | base, |
| const lpspi_slave_config_t * | slaveConfig | ||
| ) |
LPSPI slave configuration.
| base | LPSPI peripheral address. |
| slaveConfig | Pointer to structure lpspi_slave_config_t. |
| status_t LPSPI_SlaveTransferNonBlocking | ( | LPSPI_Type * | base, |
| lpspi_slave_handle_t * | handle, | ||
| lpspi_transfer_t * | transfer | ||
| ) |
LPSPI slave transfer data using interrupt.
This function transfer data using interrupt , this is non-blocking function, will return right away, when all data have been transfer, the callback function will be 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 situation: 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 integer multiples of bytesPerFrame.
| base | LPSPI peripheral address. |
| handle | pointer to lpspi_slave_handle_t structure which stores the transfer state. |
| transfer | pointer to lpspi_transfer_t structure. |
|
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.
| base | LPSPI peripheral address. |
| data | The data word to be sent |