74 #include "lpspi_hw_access.h"
107 const LPSPI_Type *base = g_lpspiBase[instance];
109 if (LPSPI_IsMaster(base))
131 uint32_t wordToSend = 0;
133 uint8_t availableSpace = (uint8_t)(lpspiState->
fifoSize - (uint8_t)LPSPI_ReadTxCount(base));
136 while(availableSpace != 0U)
143 LPSPI_ClearContCBit(base);
159 if (lpspiState->
txBuff != NULL)
164 wordToSend = *((
const uint8_t *)(lpspiState->
txBuff));
165 lpspiState->
txBuff +=
sizeof(uint8_t);
168 wordToSend = *((
const uint16_t *)(lpspiState->
txBuff));
169 lpspiState->
txBuff +=
sizeof(uint16_t);
172 wordToSend = *((
const uint32_t *)(lpspiState->
txBuff));
173 lpspiState->
txBuff +=
sizeof(uint32_t);
178 LPSPI_WriteData(base, wordToSend);
180 lpspiState->
txCount = (uint16_t)(lpspiState->
txCount - numOfBytes);
186 availableSpace = (uint8_t)(availableSpace - 1U);
198 const LPSPI_Type *base = g_lpspiBase[instance];
199 uint32_t receivedWord;
203 uint8_t filledSpace = (uint8_t)LPSPI_ReadRxCount(base);
204 while (filledSpace!= 0U)
206 receivedWord = LPSPI_ReadData(base);
220 for (j = numOfBytes; j > 0U; j--)
222 lpspiState->
rxBuff[index] = (uint8_t)(receivedWord >> ((j - 1U) * 8U));
233 for (j = 0; j < numOfBytes; j++)
235 *(lpspiState->
rxBuff) = (uint8_t)(receivedWord >> (j * 8U));
242 lpspiState->
rxCount = (uint16_t)(lpspiState->
rxCount - numOfBytes);
248 filledSpace = (uint8_t)(filledSpace - 1U);
260 LPSPI_SetIntMode(base, LPSPI_TRANSMIT_ERROR,
false);
261 LPSPI_SetIntMode(base, LPSPI_RECEIVE_ERROR,
false);
262 (void)LPSPI_ClearStatusFlag(base, LPSPI_TRANSMIT_ERROR);
263 (void)LPSPI_ClearStatusFlag(base, LPSPI_RECEIVE_ERROR);
volatile uint16_t rxFrameCnt
#define LPSPI_INSTANCE_COUNT
volatile uint16_t txFrameCnt
Runtime state structure for the LPSPI master driver.
void LPSPI_DRV_ReadRXBuffer(uint32_t instance)
Read all data from RX FIFO This function will read all data from RX FIFO and will transfer this infro...
LPSPI_Type * g_lpspiBase[LPSPI_INSTANCE_COUNT]
Table of base pointers for SPI instances.
void LPSPI_DRV_FillupTxBuffer(uint32_t instance)
Fill up the TX FIFO with data. This function fills up the TX FIFO with data based on the bytes/frame...
volatile uint16_t rxCount
void LPSPI_DRV_MasterIRQHandler(uint32_t instance)
Interrupt handler for LPSPI master mode. This handler uses the buffers stored in the lpspi_master_sta...
volatile uint16_t txCount
IRQn_Type
Defines the Interrupt Numbers definitions.
void LPSPI_DRV_IRQHandler(uint32_t instance)
The function LPSPI_DRV_IRQHandler passes IRQ control to either the master or slave driver...
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...
lpspi_state_t * g_lpspiStatePtr[LPSPI_INSTANCE_COUNT]
#define FEATURE_LPSPI_STATE_STRUCTURES_NULL
void LPSPI_DRV_SlaveIRQHandler(uint32_t instance)
Interrupt handler for LPSPI slave mode. This handler uses the buffers stored in the lpspi_master_stat...
IRQn_Type g_lpspiIrqId[LPSPI_INSTANCE_COUNT]
Table to save LPSPI IRQ enumeration numbers defined in the CMSIS header file.