58 #include "HL_reg_spi.h"
60 #include "HL_sys_common.h"
71 #define SPI_FLAG_REGISTER_TRANSMISSION_ERRORS (0x5Fu)
87 uint16_t txDummy[1] = {0x00};
119 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
123 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
127 uint32_t spiRetval = spiTransmitData(pSpiInterface->
pNode, pSpiInterface->
pConfig, frameLength, pTxBuff);
149 uint32 frameLength) {
176 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
180 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
185 spiTransmitAndReceiveData(pSpiInterface->
pNode, pSpiInterface->
pConfig, frameLength, pTxBuff, pRxBuff);
207 uint32 frameLength) {
213 (void)spiTransmitAndReceiveData(pSpiInterface->
pNode, pSpiInterface->
pConfig, frameLength, pTxBuff, pRxBuff);
220 uint32_t frameLength) {
246 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
250 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
255 uint32 Chip_Select_Hold = 0u;
256 if (pSpiInterface->
pConfig->CS_HOLD == TRUE) {
259 Chip_Select_Hold = 0U;
262 if (pSpiInterface->
pConfig->WDEL == TRUE) {
267 SPIDATAFMT_t DataFormat = pSpiInterface->
pConfig->DFSEL;
268 uint8 ChipSelect = pSpiInterface->
pConfig->CSNR;
279 (uint32_t)(&pTxBuff[1u]);
285 ((frameLength - 2u) << 16U) | 1U;
288 dmaRAMREG->PCP[(dmaChannel_t)
dma_spiDmaChannels[spiIndex].rxChannel].IDADDR = (uint32_t)pRxBuff;
290 dmaRAMREG->PCP[(dmaChannel_t)
dma_spiDmaChannels[spiIndex].rxChannel].ITCOUNT = (frameLength << 16U) | 1U;
294 dmaSetChEnable((dmaChannel_t)
dma_spiDmaChannels[spiIndex].txChannel, (dmaTriggerType_t)DMA_HW);
295 dmaSetChEnable((dmaChannel_t)
dma_spiDmaChannels[spiIndex].rxChannel, (dmaTriggerType_t)DMA_HW);
303 uint32_t txBuffer = pTxBuff[0u];
304 txBuffer |= ((uint32)DataFormat << 24U) | ((uint32)ChipSelect << 16U) | (WDelay) | (Chip_Select_Hold);
310 pSpiInterface->
pNode->DAT1 = txBuffer;
313 (timeoutIterations > 0u)) {
353 extern void SPI_SetFunctional(spiBASE_t *pNode,
enum spiPinSelect bit,
bool hardwareControlled) {
358 spi_config_reg_t configRegisterBuffer = {0};
359 if (pNode == spiREG1) {
360 spi1GetConfigValue(&configRegisterBuffer, CurrentValue);
361 }
else if (pNode == spiREG2) {
362 spi2GetConfigValue(&configRegisterBuffer, CurrentValue);
363 }
else if (pNode == spiREG3) {
364 spi3GetConfigValue(&configRegisterBuffer, CurrentValue);
365 }
else if (pNode == spiREG4) {
366 spi4GetConfigValue(&configRegisterBuffer, CurrentValue);
367 }
else if (pNode == spiREG5) {
368 spi5GetConfigValue(&configRegisterBuffer, CurrentValue);
373 uint32_t newPc0 = configRegisterBuffer.CONFIG_PC0;
375 if (hardwareControlled ==
false) {
377 newPc0 &= ~(uint32_t)((uint32_t)1u << (uint8_t)(bit));
380 newPc0 |= (uint32_t)((uint32_t)1u << (uint8_t)(bit));
384 spiSetFunctional(pNode, newPc0);
391 uint32_t frameLength) {
414 (frameLength << 16U) | 1U;
421 (frameLength << 16U) | 1U;
437 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
439 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
462 const SpiDataStatus_t spiStatus = SpiTxStatus(pNode);
464 if (spiStatus == SPI_PENDING) {
472 uint8_t spiIndex = 0u;
474 if (pNode == spiREG1) {
476 }
else if (pNode == spiREG2) {
478 }
else if (pNode == spiREG3) {
480 }
else if (pNode == spiREG4) {
482 }
else if (pNode == spiREG5) {
Headers for the driver for the DMA module.
spiBASE_t * dma_spiInterfaces[DMA_NUMBER_SPI_INTERFACES]
DMA_CHANNEL_CONFIG_s dma_spiDmaChannels[DMA_NUMBER_SPI_INTERFACES]
#define DMA_NUMBER_SPI_INTERFACES
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
#define NULL_PTR
Null pointer.
Function to switch between user mode and privilege mode.
#define FSYS_SwitchToUserMode()
Switch back to user mode.
long FSYS_RaisePrivilege(void)
raise privilege
#define UNIT_TEST_WEAK_IMPL
void IO_PinSet(volatile uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
void IO_PinReset(volatile uint32_t *pRegisterAddress, uint32_t pin)
Reset pin by writing in pin output register.
Header for the driver for the IO module.
void MCU_Delay_us(uint32_t delay_us)
Wait blocking a certain time in microseconds.
#define LARGEST_PIN_NUMBER
largest pin number that exists in TMS570LC4357
Declaration of the OS wrapper interface.
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
STD_RETURN_TYPE_e SPI_TransmitReceiveDataDma(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength)
Transmits and receives data on SPI with DMA.
void SPI_SetFunctional(spiBASE_t *pNode, enum spiPinSelect bit, bool hardwareControlled)
Sets the functional of a SPI pin.
STD_RETURN_TYPE_e SPI_CheckInterfaceAvailable(spiBASE_t *pNode)
Returns STD_OK if the SPI interface can be used again.
void SPI_DmaSendLastByte(uint8_t spiIndex)
Used to send last byte per SPI.
STD_RETURN_TYPE_e SPI_TransmitDummyByte(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint32_t delay)
Sends a dummy byte to wake up the SPI interface.
void SPI_FramTransmitReceiveData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint16 *pRxBuff, uint32 frameLength)
Transmits and receives data on SPI without DMA, wrappe for FRAM.
STD_RETURN_TYPE_e SPI_Lock(uint8_t spi)
Locks SPI interfaces.
STD_RETURN_TYPE_e SPI_SlaveSetReceiveDataDma(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength)
Transmits and receives data on SPI with DMA.
void SPI_Unlock(uint8_t spi)
Unlocks SPI interfaces.
STD_RETURN_TYPE_e SPI_TransmitData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint32 frameLength)
Transmits data on SPI without DMA.
void UNIT_TEST_WEAK_IMPL spiNotification(spiBASE_t *spi, uint32 flags)
STD_RETURN_TYPE_e SPI_TransmitReceiveData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint16 *pRxBuff, uint32 frameLength)
Transmits and receives data on SPI without DMA.
uint8_t SPI_GetSpiIndex(spiBASE_t *pNode)
Returns index of SPI node.
#define SPI_FLAG_REGISTER_TRANSMISSION_ERRORS
static uint32_t spi_txLastWord[DMA_NUMBER_SPI_INTERFACES]
Headers for the driver for the SPI module.
SPI_BUSY_STATE_e spi_busyFlags[]
const uint8_t spi_nrBusyFlags
#define SPI_HARDWARE_CHIP_SELECT_FIELD_POSITION
#define SPI_DATA_FORMAT_FIELD_POSITION
#define SPI_TX_EMPTY_TIMEOUT_ITERATIONS
#define SPI_MAX_NUMBER_HW_CS
#define SPI_TX_BUFFER_EMPTY_FLAG_POSITION
#define SPI_PC0_CLEAR_HW_CS_MASK
@ SPI_CHIP_SELECT_SOFTWARE
@ SPI_CHIP_SELECT_HARDWARE
SPI_CHIP_SELECT_TYPE_e csType
volatile uint32_t * pGioPort