98 #define MICROSECONDS 1000000
108 const uint8_t * sendBuffer,
109 uint8_t * receiveBuffer,
110 uint16_t transferByteCount);
238 uint32_t delaySCKtoPCS, uint32_t delayPCStoSCK)
245 uint32_t realDelayBetwenTransfers, realDelaySCKtoPCS, realDelayPCStoSCK;
259 if (realDelayBetwenTransfers > (uint32_t)257U)
261 realDelayBetwenTransfers = (uint32_t)257U;
263 if(realDelaySCKtoPCS > (uint32_t)256U)
265 realDelaySCKtoPCS = (uint32_t)256U;
267 if(realDelayPCStoSCK > (uint32_t)256U)
269 realDelayPCStoSCK = (uint32_t)256U;
271 if (realDelayBetwenTransfers < (uint32_t)2U)
273 realDelayBetwenTransfers = (uint32_t)2U;
275 if(realDelaySCKtoPCS == (uint32_t)0)
277 realDelaySCKtoPCS = (uint32_t)1U;
279 if(realDelayPCStoSCK == (uint32_t)0U)
281 realDelayPCStoSCK = (uint32_t)1U;
313 uint32_t * calculatedBaudRate)
325 uint32_t tcrPrescaleValue;
373 if (baudRate == (uint32_t)0)
379 if (calculatedBaudRate != NULL)
381 *calculatedBaudRate = baudRate;
395 .preDiv = tcrPrescaleValue,
421 const uint8_t * sendBuffer,
422 uint8_t * receiveBuffer,
423 uint16_t transferByteCount,
433 if (transferByteCount == (uint16_t)0)
499 const uint8_t * sendBuffer,
500 uint8_t * receiveBuffer,
501 uint16_t transferByteCount)
506 if (transferByteCount == (uint16_t)0)
541 if (bytesRemained != NULL)
543 *bytesRemained = lpspiState->
rxCount;
585 const uint8_t * sendBuffer,
586 uint8_t * receiveBuffer,
587 uint16_t transferByteCount)
614 if ((transferByteCount % lpspiState->
bytesPerFrame) != (uint16_t)0)
637 lpspiState->
txBuff = (
const uint8_t *)sendBuffer;
638 lpspiState->
rxBuff = (uint8_t *)receiveBuffer;
641 lpspiState->
txCount = transferByteCount;
654 if (lpspiState->
rxBuff == NULL)
663 lpspiState->
rxCount = transferByteCount;
671 if (receiveBuffer == NULL)
677 lpspiState->
rxCount = transferByteCount;
690 (uint32_t)sendBuffer, (uint32_t)(&(base->
TDR)), dmaTransferSize, (uint32_t)1U<<(uint8_t)(dmaTransferSize));
697 if(receiveBuffer != NULL)
700 (uint32_t)(&(base->
RDR)),(uint32_t)receiveBuffer, dmaTransferSize, (uint32_t)1U<<(uint8_t)(dmaTransferSize));
722 if (receiveBuffer!=NULL)
773 uint32_t instance = (uint32_t)parameter;
786 uint32_t instance = (uint32_t)parameter;
804 uint16_t txCount, rxCount;
836 if (txCount == (uint16_t)0)
842 if (rxCount == (uint16_t)0)
volatile uint16_t rxFrameCnt
#define LPSPI_INSTANCE_COUNT
volatile uint16_t txFrameCnt
Runtime state structure for the LPSPI master driver.
static void LPSPI_HAL_SetTxWatermarks(LPSPI_Type *base, uint32_t txWater)
Sets the TX FIFO watermark values.
Data structure containing information about a device on the SPI bus.
void LPSPI_DRV_ReadRXBuffer(uint32_t instance)
The function LPSPI_DRV_ReadRXBuffer reads data from RX hardware buffer and writes this data in RX sof...
void LPSPI_HAL_GetFifoSizes(const LPSPI_Type *base, uint8_t *txFifoSize, uint8_t *rxFifoSize)
Gets the TX and RX FIFO sizes of the LPSPI module.
static const uint32_t s_baudratePrescaler[]
status_t OSIF_SemaDestroy(const semaphore_t *const pSem)
Destroys a previously created semaphore.
lpspi_signal_polarity_t pcsPolarity
static void LPSPI_HAL_ClearContCBit(LPSPI_Type *base)
Clear CONTC bit form TCR Register.
status_t LPSPI_DRV_MasterDeinit(uint32_t instance)
Shuts down a LPSPI instance.
Chip specific module features.
lpspi_transfer_type transferType
lpspi_transfer_type transferType
#define LPSPI_DMA_INSTANCE
lpspi_state_t * g_lpspiStatePtr[LPSPI_INSTANCE_COUNT]
void LPSPI_HAL_SetFlushFifoCmd(LPSPI_Type *base, bool flushTxFifo, bool flushRxFifo)
Flushes the LPSPI FIFOs.
static void LPSPI_DRV_MasterCompleteTransfer(uint32_t instance)
Finish up a transfer. Cleans up after a transfer is complete. Interrupts are disabled, and the LPSPI module is disabled. This is not a public API as it is called from other driver functions.
status_t LPSPI_HAL_SetDelay(LPSPI_Type *base, lpspi_delay_type_t whichDelay, uint32_t delay)
Manually configures a specific LPSPI delay parameter (module must be disabled to change the delay val...
void EDMA_HAL_TCDSetMajorCount(DMA_Type *base, uint32_t channel, uint32_t count)
Sets the major iteration count according to minor loop channel link setting.
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...
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.
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.
lpspi_prescaler_t
Prescaler values for LPSPI clock source. Implements : lpspi_prescaler_t_Class.
status_t OSIF_SemaCreate(semaphore_t *const pSem, const uint8_t initValue)
Creates a semaphore with a given value.
status_t LPSPI_DRV_MasterGetTransferStatus(uint32_t instance, uint32_t *bytesRemained)
Returns whether the previous interrupt driven transfer is completed.
status_t LPSPI_HAL_SetPinConfigMode(LPSPI_Type *base, lpspi_pin_config_t pinCfg, lpspi_data_out_config_t dataOutConfig, bool pcs3and2Enable)
Configures the LPSPI SDO/SDI pin configuration mode.
static void LPSPI_HAL_SetTxDmaCmd(LPSPI_Type *base, bool enable)
Sets the LPSPI Transmit Data DMA configuration (enable or disable).
void LPSPI_DRV_FillupTxBuffer(uint32_t instance)
The function LPSPI_DRV_FillupTxBuffer writes data in TX hardware buffer depending on driver state and...
void INT_SYS_DisableIRQ(IRQn_Type irqNumber)
Disables an interrupt for a given IRQ number.
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_state_t st...
edma_chn_status_t
Channel status for eDMA channel.
status_t LPSPI_HAL_SetPcsPolarityMode(LPSPI_Type *base, lpspi_which_pcs_t whichPcs, lpspi_signal_polarity_t pcsPolarity)
Configures the desired LPSPI PCS polarity.
lpspi_clock_phase_t clkPhase
volatile uint16_t txCount
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.
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.
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
IRQn_Type g_lpspiIrqId[LPSPI_INSTANCE_COUNT]
Table to save LPSPI IRQ enumeration numbers defined in the CMSIS header file.
uint32_t LPSPI_HAL_SetBaudRate(LPSPI_Type *base, uint32_t bitsPerSec, uint32_t sourceClockInHz, uint32_t *tcrPrescaleValue)
Sets the LPSPI baud rate in bits per second.
static void LPSPI_HAL_Enable(LPSPI_Type *base)
Enables the LPSPI module.
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...
edma_transfer_size_t
eDMA transfer configuration Implements : edma_transfer_size_t_Class
static void LPSPI_HAL_SetRxDmaCmd(LPSPI_Type *base, bool enable)
Sets the LPSPI Receive Data DMA configuration (enable or disable).
static void LPSPI_HAL_SetIntMode(LPSPI_Type *base, lpspi_status_flag_t interruptSrc, bool enable)
Configures the LPSPI interrupts.
static lpspi_prescaler_t LPSPI_HAL_GetClockPrescaler(const LPSPI_Type *base)
Get the clock prescaler used for all LPSPI master logic.
static status_t LPSPI_DRV_MasterStartTransfer(uint32_t instance, const uint8_t *sendBuffer, uint8_t *receiveBuffer, uint16_t transferByteCount)
static void EDMA_HAL_TCDSetDisableDmaRequestAfterTCDDoneCmd(DMA_Type *base, uint32_t channel, bool disable)
Disables/Enables the DMA request after the major loop completes for the TCD.
status_t OSIF_SemaWait(semaphore_t *const pSem, const uint32_t timeout)
Decrement a semaphore with timeout.
void LPSPI_HAL_Init(LPSPI_Type *base)
Resets the LPSPI internal logic and registers to their default settings.
status_t EDMA_DRV_StartChannel(uint8_t channel)
Starts an eDMA channel.
status_t LPSPI_HAL_ClearStatusFlag(LPSPI_Type *base, lpspi_status_flag_t statusFlag)
Clears the LPSPI status flag.
static void LPSPI_HAL_SetRxWatermarks(LPSPI_Type *base, uint32_t rxWater)
Sets the RX FIFO watermark values.
lpspi_which_pcs_t whichPcs
static void LPSPI_DRV_MasterCompleteDMATransfer(void *parameter, edma_chn_status_t status)
Finish up a transfer DMA. The main purpose of this function is to create a function compatible with D...
volatile bool isTransferInProgress
LPSPI Transmit Command Register configuration structure.
status_t OSIF_SemaPost(semaphore_t *const pSem)
Increment a semaphore.
DMA_Type *const g_edmaBase[DMA_INSTANCE_COUNT]
Array for the eDMA module register base address.
static void LPSPI_HAL_SetContCBit(LPSPI_Type *base)
Set CONTC bit form TCR Register.
void INT_SYS_EnableIRQ(IRQn_Type irqNumber)
Enables an interrupt for a given IRQ number.
status_t LPSPI_DRV_MasterAbortTransfer(uint32_t instance)
Terminates an interrupt driven asynchronous transfer early.
lpspi_sck_polarity_t clkPolarity
LPSPI_Type * g_lpspiBase[LPSPI_INSTANCE_COUNT]
Table of base pointers for SPI instances.
status_t EDMA_DRV_ConfigSingleBlockTransfer(uint8_t channel, edma_transfer_type_t type, uint32_t srcAddr, uint32_t destAddr, edma_transfer_size_t transferSize, uint32_t dataBufferSize)
Configures a simple single block data transfer with DMA.
void LPSPI_HAL_SetTxCommandReg(LPSPI_Type *base, const lpspi_tx_cmd_config_t *txCmdCfgSet)
Sets the Transmit Command Register (TCR) parameters.
status_t LPSPI_HAL_Disable(LPSPI_Type *base)
Disables the LPSPI module.
status_t LPSPI_HAL_SetMasterSlaveMode(LPSPI_Type *base, lpspi_master_slave_mode_t mode)
Configures the LPSPI for master or slave.
status_t EDMA_DRV_InstallCallback(uint8_t channel, edma_callback_t callback, void *parameter)
Registers the callback function and the parameter for eDMA channel.
semaphore_t lpspiSemaphore
static void LPSPI_DRV_MasterClearCountinuous(void *parameter, edma_chn_status_t status)
Clear the continuous mode. The main purpose of this function is to clear continuous mode...
static bool LPSPI_HAL_GetStatusFlag(const LPSPI_Type *base, lpspi_status_flag_t statusFlag)
Gets the LPSPI status flag state.