57 #include "HL_reg_spi.h"
59 #include "HL_sys_common.h"
71 #define SPI_FLAG_REGISTER_TRANSMISSION_ERRORS (0x5Fu)
85 uint16_t txDummy[1] = {0x00};
117 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
121 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
125 uint32_t spiRetval = spiTransmitData(pSpiInterface->
pNode, pSpiInterface->
pConfig, frameLength, pTxBuff);
147 uint32 frameLength) {
174 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
178 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
183 spiTransmitAndReceiveData(pSpiInterface->
pNode, pSpiInterface->
pConfig, frameLength, pTxBuff, pRxBuff);
205 uint32 frameLength) {
211 (void)spiTransmitAndReceiveData(pSpiInterface->
pNode, pSpiInterface->
pConfig, frameLength, pTxBuff, pRxBuff);
218 uint32_t frameLength) {
237 uint32 Chip_Select_Hold = 0u;
238 if (pSpiInterface->
pConfig->CS_HOLD == TRUE) {
241 Chip_Select_Hold = 0U;
244 if (pSpiInterface->
pConfig->WDEL == TRUE) {
249 SPIDATAFMT_t DataFormat = pSpiInterface->
pConfig->DFSEL;
250 uint8 ChipSelect = pSpiInterface->
pConfig->CSNR;
262 (uint32_t)(&pTxBuff[1u]);
268 ((frameLength - 2u) << 16U) | 1U;
275 (frameLength << 16U) | 1U;
281 (dmaTriggerType_t)DMA_HW);
284 (dmaTriggerType_t)DMA_HW);
292 uint32_t txBuffer = pTxBuff[0u];
293 txBuffer |= ((uint32)DataFormat << 24U) | ((uint32)ChipSelect << 16U) | (WDelay) | (Chip_Select_Hold);
299 pSpiInterface->
pNode->DAT1 = txBuffer;
302 (timeoutIterations > 0u)) {
338 extern void SPI_SetFunctional(spiBASE_t *pNode,
enum spiPinSelect bit,
bool hardwareControlled) {
343 spi_config_reg_t configRegisterBuffer = {0};
344 if (pNode == spiREG1) {
345 spi1GetConfigValue(&configRegisterBuffer, CurrentValue);
346 }
else if (pNode == spiREG2) {
347 spi2GetConfigValue(&configRegisterBuffer, CurrentValue);
348 }
else if (pNode == spiREG3) {
349 spi3GetConfigValue(&configRegisterBuffer, CurrentValue);
350 }
else if (pNode == spiREG4) {
351 spi4GetConfigValue(&configRegisterBuffer, CurrentValue);
352 }
else if (pNode == spiREG5) {
353 spi5GetConfigValue(&configRegisterBuffer, CurrentValue);
358 uint32_t newPc0 = configRegisterBuffer.CONFIG_PC0;
360 if (hardwareControlled ==
false) {
362 newPc0 &= ~(uint32_t)((uint32_t)1u << (uint8_t)(bit));
365 newPc0 |= (uint32_t)((uint32_t)1u << (uint8_t)(bit));
369 spiSetFunctional(pNode, newPc0);
376 uint32_t frameLength) {
399 (frameLength << 16U) | 1U;
406 (frameLength << 16U) | 1U;
422 if (((pSpiInterface->
pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
424 pSpiInterface->
pNode->PC0 |= (uint32_t)1u << csNumber;
447 const SpiDataStatus_t spiStatus = SpiTxStatus(pNode);
449 if (spiStatus == SPI_PENDING) {
457 uint8_t spiIndex = 0u;
459 if (pNode == spiREG1) {
461 }
else if (pNode == spiREG2) {
463 }
else if (pNode == spiREG3) {
465 }
else if (pNode == spiREG4) {
467 }
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.
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
Function to switch between user mode and privilege mode.
#define FSYS_SwitchToUserMode()
Switch back to user mode.
long FSYS_RaisePrivilege(void)
raise privilege
#define LARGEST_PIN_NUMBER
largest pin number that exists in TMS570LC4357
#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.
Headers for the driver for the MCU module.
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
@ SPI_CHIP_SELECT_SOFTWARE
@ SPI_CHIP_SELECT_HARDWARE
#define SPI_MAX_NUMBER_HW_CS
#define SPI_TX_BUFFER_EMPTY_FLAG_POSITION
#define SPI_PC0_CLEAR_HW_CS_MASK
SPI_CHIP_SELECT_TYPE_e csType
volatile uint32_t * pGioPort