Part Number: TMS570LC4357
We are working on a project which requires SPI communication and as such to meet the data communication protocol as specified in the datasheet we are referring, we may need to change the auto- generated APIs.
And so, we needed some material or insights to refer to, to do the same.
Some of our questions:
1) Is CS_HOLD same as CS for SPI communication? (We had this doubt because on the forum we saw a code initializing CS_HOLD to FALSE, and after in the if statement inside the while loop, we are again making CS_HOLD to 0)
2) What is Chip_Select_Hold? (active low/ active high)
2) What is the task of WDEL (some delay factor we are assuming) and CSNR ?
And lastly if we were to modify this particular API to transmit the data first and then only start receiving, how should we proceed? (Currently we are making use of a combination of spiTransmitData and spiReceiveData)
uint32 spiTransmitAndReceiveData(spiBASE_t *spi, spiDAT1_t *dataconfig_t, uint32 blocksize, uint16 * srcbuff, uint16 * destbuff)
{
uint16 Tx_Data;
uint32 Chip_Select_Hold = (dataconfig_t->CS_HOLD) ? 0x10000000U : 0U;
uint32 WDelay = (dataconfig_t->WDEL) ? 0x04000000U : 0U;
SPIDATAFMT_t DataFormat = dataconfig_t->DFSEL;
uint8 ChipSelect = dataconfig_t->CSNR;
/* USER CODE BEGIN (14) */
/* USER CODE END */
while(blocksize != 0U)
{
if((spi->FLG & 0x000000FFU) != 0U)
{
break;
}
if(blocksize == 1U)
{
Chip_Select_Hold = 0U;
}
/*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
Tx_Data = *srcbuff;
spi->DAT1 =((uint32)DataFormat << 24U) |
((uint32)ChipSelect << 16U) |
(WDelay) |
(Chip_Select_Hold) |
(uint32)Tx_Data;
/*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
srcbuff++;
/*SAFETYMCUSW 28 D MR:NA <APPROVED> "Hardware status bit read check" */
while((spi->FLG & 0x00000100U) != 0x00000100U)
{
} /* Wait */
/*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
*destbuff = (uint16)spi->BUF;
/*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
destbuff++;
blocksize--;
}
/* USER CODE BEGIN (15) */
/* USER CODE END */
return (spi->FLG & 0xFFU);
}
