58 #include "HL_reg_spi.h"
60 #include "HL_sys_common.h"
71 #define SPI_FLAG_REGISTER_TRANSMISSION_ERRORS (0x5Fu)
90 uint16_t txDummy[1] = {0x00};
122 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
126 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
130 uint32_t spiRetval = spiTransmitData(pSpiInterface->
pNode, pSpiInterface->
pConfig, frameLength, pTxBuff);
152 uint32 frameLength) {
179 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
183 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
188 spiTransmitAndReceiveData(pSpiInterface->
pNode, pSpiInterface->
pConfig, frameLength, pTxBuff, pRxBuff);
210 uint32 frameLength) {
216 (void)spiTransmitAndReceiveData(pSpiInterface->
pNode, pSpiInterface->
pConfig, frameLength, pTxBuff, pRxBuff);
223 uint32_t frameLength) {
249 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
253 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
258 uint32 Chip_Select_Hold = 0u;
259 if (pSpiInterface->
pConfig->CS_HOLD == TRUE) {
262 Chip_Select_Hold = 0U;
265 if (pSpiInterface->
pConfig->WDEL == TRUE) {
270 SPIDATAFMT_t DataFormat = pSpiInterface->
pConfig->DFSEL;
271 uint8 ChipSelect = pSpiInterface->
pConfig->CSNR;
282 (uint32_t)(&pTxBuff[1u]);
288 ((frameLength - 2u) << 16U) | 1U;
291 dmaRAMREG->PCP[(dmaChannel_t)
dma_spiDmaChannels[spiIndex].rxChannel].IDADDR = (uint32_t)pRxBuff;
293 dmaRAMREG->PCP[(dmaChannel_t)
dma_spiDmaChannels[spiIndex].rxChannel].ITCOUNT = (frameLength << 16U) | 1U;
297 dmaSetChEnable((dmaChannel_t)
dma_spiDmaChannels[spiIndex].txChannel, (dmaTriggerType_t)DMA_HW);
298 dmaSetChEnable((dmaChannel_t)
dma_spiDmaChannels[spiIndex].rxChannel, (dmaTriggerType_t)DMA_HW);
306 uint32_t txBuffer = pTxBuff[0u];
307 txBuffer |= ((uint32)DataFormat << 24U) | ((uint32)ChipSelect << 16U) | (WDelay) | (Chip_Select_Hold);
313 pSpiInterface->
pNode->DAT1 = txBuffer;
316 (timeoutIterations > 0u)) {
356 extern void SPI_SetFunctional(spiBASE_t *pNode,
enum spiPinSelect bit,
bool hardwareControlled) {
361 spi_config_reg_t configRegisterBuffer = {0};
362 if (pNode == spiREG1) {
363 spi1GetConfigValue(&configRegisterBuffer, CurrentValue);
364 }
else if (pNode == spiREG2) {
365 spi2GetConfigValue(&configRegisterBuffer, CurrentValue);
366 }
else if (pNode == spiREG3) {
367 spi3GetConfigValue(&configRegisterBuffer, CurrentValue);
368 }
else if (pNode == spiREG4) {
369 spi4GetConfigValue(&configRegisterBuffer, CurrentValue);
370 }
else if (pNode == spiREG5) {
371 spi5GetConfigValue(&configRegisterBuffer, CurrentValue);
376 uint32_t newPc0 = configRegisterBuffer.CONFIG_PC0;
378 if (hardwareControlled ==
false) {
380 newPc0 &= ~(uint32_t)((uint32_t)1u << (uint8_t)(bit));
383 newPc0 |= (uint32_t)((uint32_t)1u << (uint8_t)(bit));
387 spiSetFunctional(pNode, newPc0);
394 uint32_t frameLength) {
413 SPIDATAFMT_t DataFormat = pSpiInterface->
pConfig->DFSEL;
421 (frameLength << 16U) | 1U;
428 (frameLength << 16U) | 1U;
444 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
446 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
475 const SpiDataStatus_t spiStatus = SpiTxStatus(pNode);
477 if (spiStatus == SPI_PENDING) {
485 uint8_t spiIndex = 0u;
487 if (pNode == spiREG1) {
489 }
else if (pNode == spiREG2) {
491 }
else if (pNode == spiREG3) {
493 }
else if (pNode == spiREG4) {
495 }
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_SWITCH_TO_USER_MODE()
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 MCU_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)
SPI Interrupt callback.
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