Porting SPI Driver to Keil RL-ARM System: RecBuf

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Porting SPI Driver to Keil RL-ARM System: RecBuf

576 Views
tfrauenrath
Contributor III

My task is to port a NXP SPI driver delivered with Keil RL-ARM to my Kinetis K60 system. Finlay I want to talk to SD cards in SPI mode. I do this step by step. My next task is the Send routine.

RL-ARM User's Guide: spi.RecBuf Library Routine

This is the original NXP Send:

/* Receive SPI data to buffer. */

static BOOL RecBuf (U8 *buf, U32 sz) {

  U32 i;

  for (i = 0; i < sz; i++) {

  SSPDR = 0xFF;

  while (!(SSPSR & RNE)); /* Wait while Rx FIFO is empty. */

  buf[i] = SSPDR;

  }

  return (__TRUE);

}

This my first trial for the Kinetis RecBuf

/*--------------------------- RecBuf ----------------------------------------*/

/* Receive SPI data to buffer. */

static BOOL RecBuf (U8 *buf, U32 sz) {

  U32 i;

  for (i = 0; i < sz; i++)   buf[i] = SPI2->POPR;

  return (__TRUE);

  }

Do you think this is applicable for SD card access via SPI?

I will discuss the other routines in other threads because of a better overview. I will post the final driver, because Keil provides only samples for SDHC mode for memory cards for the Kinetis system.

Thank you





Labels (1)
0 Kudos
0 Replies