标题: SD卡调试遇到的问题 [打印本页] 作者: 西子枫林 时间: 2010-7-19 18:21 标题: SD卡调试遇到的问题 void xmit_spi(BYTE dat)
{
char temp;
while(!(SPI0SR_SPTEF)); /* wait until write is permissible */
SPI0DRL = dat; /* output the byte to the SPI */
while(!(SPI0SR_SPIF)); /* wait until write operation is complete */
temp=SPI0SR;
temp=SPI0DRL; // clear the spif flag.
}
static
BYTE rcvr_spi(void)
{
unsigned char te;
while(!(SPI0SR_SPTEF)); /* wait until write is permissible */
SPI0DRL = 0xFF; /* trigger 8 SCK pulses to shift in data */
while(!(SPI0SR_SPIF)); /* wait until a byte has been shifted in */
te=SPI0SR;
te=SPI0DRL; // clear the spif flag.
return te; /* return the character */
}