I am wondering how exactly a code for the Continuous Transfer looks like.
void receiveBytes(uint8_t address, uint8_t *buffer, uint8_t numBytes)
{
uint8_t i;
address = address|0x40; // multibyte enabled
address = address|0x80; // write enabled
while((LPSPI0->SR & LPSPI_SR_TDF_MASK)>>LPSPI_SR_TDF_SHIFT==0) {}
LPSPI0->TDR = LPSPI_TDR_DATA(address) ;
LPSPI0->SR |= LPSPI_SR_TDF_MASK; /* Clear TDF flag */
while((LPSPI0->SR & LPSPI_SR_RDF_MASK)>>LPSPI_SR_RDF_SHIFT==0){}
LPSPI0->RDR ;
LPSPI0->SR |= LPSPI_SR_RDF_MASK; /* Clear RDF flag */
for (i = 0 ; i < numBytes; ++i) {
while ((LPSPI0->SR & LPSPI_SR_TDF_MASK) >> LPSPI_SR_TDF_SHIFT == 0) {}
LPSPI0->TDR = LPSPI_TDR_DATA(0x00);
while ((LPSPI0->SR & LPSPI_SR_RDF_MASK) >> LPSPI_SR_RDF_SHIFT == 0) {}
*buffer++ = LPSPI0->RDR;
}
LPSPI0->SR |= LPSPI_SR_RDF_MASK; /* Clear RDF flag */
}
I have this code here, and I would like to receive the bytes after one another with the CS staying low all the time.
I tried controlling the CS pin but the clock was then always working as seen on the scope even if the CS pin was high.
And if I wanna use the Continuous Transfer mode, do I also need to add a few SPI settings or just add the lines iin the transfer and receive functions?
Thanks in advance!