|
MSP430芯片SPI的驱动程序,存储器用的芯片AT45DB161D 编译时找不到头文件include "AT45DB161D.h"
[复制链接]
我写的程序是关于MSP430的SPI驱动,实现数据的简单读写,但在编译时总提示 找不到头文件 include "AT45DB161D.h"的源文件,下面是我写的程序:
#include
#include "AT45DB161D.h"
#define NOP() { _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); }
sbit SPI45DB161D_CS =P1^5;
sbit SPI45DB161D_SCK =P3^3;
sbit SPI45DB161D_SI =P3^1;
sbit SPI45DB161D_SO =P3^2;
delay(unsigned int t)
{
while(t--);
}
SPI45DB161D_WriteBits(unsigned char byte,unsigned char num_of_bits)
{
unsigned char count;
byte=byte<<(8-num_of_bits);
for(count=0;count
{
SPI45DB161D_SCK=0;
byte<<=1;
NOP();
SPI45DB161D_SI=CY;
NOP();
SPI45DB161D_SCK=1;
NOP();
}
}
unsigned char SPI45DB161D_ReadByte()
{
unsigned char count,byte;
for(count=0;count<8;count++)
{
SPI45DB161D_SCK=1;
NOP();
byte<<=1;
SPI45DB161D_SCK=0;
NOP();
if(SPI45DB161D_SO) byte++;
NOP();
}
return(byte);
}
void WriteToBuffer1(unsigned int data)
{
SPI45DB161D_SCK=1;
NOP();
SPI45DB161D_CS=0;
NOP();
SPI45DB161D_WriteBits(0x84,8);
SPI45DB161D_WriteBits(0x00,7);
SPI45DB161D_WriteBits(0x00,7);
SPI45DB161D_WriteBits( (unsigned char)(data>>8) , 2 );
SPI45DB161D_WriteBits( (unsigned char)(data) , 8 );
SPI45DB161D_CS=1; // end
delay(200);
}
unsigned char ReadDataFromBuffer1(unsigned int address)
{
unsigned char dat;
SPI45DB161D_SCK=1;
NOP();
SPI45DB161D_CS=0;
NOP();
//send 8 bit opcode:0xD4
SPI45DB161D_WriteBits(0xD4,8);
SPI45DB161D_WriteBits(0x00,7);
SPI45DB161D_WriteBits(0x00,7);//send 10 bit address to 45D081 buffer1
SPI45DB161D_WriteBits( (unsigned char)(address>>8) ,2 );
SPI45DB161D_WriteBits( (unsigned char)(address) , 8 );//fill 8 bits blank
SPI45DB161D_WriteBits( 0x00 , 8 );// receive data
dat=SPI45DB161D_ReadByte() ;
SPI45DB161D_CS=1; // end
return(dat);
|
|