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 Bus speed routine.
RL-ARM User's Guide: spi.BusSpeed Library Routine
This is the original NXP Bus Speed Routine:
/* Set an SPI clock to required baud rate. */
static BOOL BusSpeed (U32 kbaud) {
U32 div;
div = (__PCLK/1000 + kbaud - 1) / kbaud;
if (div == 0) {
div = 0x02;
}
if (div & 1) {
div++;
}
if (div > 0xFE) {
div = 0xFE;
}
SSPCPSR = div;
return (__TRUE);
}
I am not able to write a Kinetis Routine, because there is no PreScaler in the K60 registers. What else can I do to full fill the requirements of this routine?