📄 spi.c
字号:
//************************************************//
//** file: spi.c
//** target: ADSP-BF533
//** creat time: 2008-8-19
#include <ccblkfn.h>
#include <cdefBF533.h>
#include "sys_func.h"
//SPI interface funtion
void SPI_Init(void)
{
*pSPI_BAUD = (unsigned short)(GetSCLK() / (2 * 5000000)); // 5MHz
//SPI enable,master mode,CPHA=1(control by software),
//16 bit,Start transfer with write of SPI_TDBR
*pSPI_CTL = 0x5501;
*pSPI_FLG = 0xFF20; // SPISEL5 enabled
}
//SPI send a word function
void SPI_send_data(unsigned short data)
{
*pSPI_TDBR = data;
while ((*pSPI_STAT & 0x0001) == 0) ;
Delay(1000);
}
//SPI receive a word function
unsigned short SPI_receive_data(void)
{
SPI_send_data(0xFFFF);
return (*pSPI_RDBR);
}
//SPI RDBR clear
void SPI_RDBR_Clr(void)
{
unsigned char buf;
while (*pSPI_STAT & 0x0020)
buf = *pSPI_RDBR;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -