at45db161驅(qū)動 作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對面交流海量資料庫查詢 收藏 void AT45Buffer2Write(unsigned int addrs,unsigned char *dat,unsigned int lenght){spi_cs(0);SPI_Send_Data(0X87);SPI_Send_Data(0x00);SPI_Send_Data(addrs>>8);SPI_Send_Data(addrs);while(lenght){SPI_Send_Data(*dat);dat++;lenght--;}spi_cs(1);}void AT45Buffer2Read(unsigned int addrs,unsigned char *dat,unsigned int lenght){spi_cs(0);SPI_Send_Data(0Xd3);SPI_Send_Data(0x00);SPI_Send_Data(addrs>>8);SPI_Send_Data(addrs);while(lenght){*dat = SPI_Send_Data(0xff);dat++;lenght--;}spi_cs(1);}void MainToBuffer2AT45(unsigned int page){spi_cs(0);SPI_Send_Data(0X55);SPI_Send_Data((page>>7));SPI_Send_Data(page<<1);SPI_Send_Data(0x00);spi_cs(1);}void ChipErase(void){spi_cs(0);SPI_Send_Data(0Xc7);SPI_Send_Data(0x94);SPI_Send_Data(0x80);SPI_Send_Data(0x9a);spi_cs(1);}void PowerOfPage256(void){spi_cs(0);SPI_Send_Data(0X3d);SPI_Send_Data(0x2a);SPI_Send_Data(0x80);SPI_Send_Data(0xa6);spi_cs(1);}void test_at45xx(void){unsigned char status,i;unsigned int n;unsigned char rx_dat[153];const unsigned char leab[10]={0x00,0x01,0x02,0x03,0x55,0xaa,0x88,0x99,0x88,0xaa};status = AT45XX_ID();SCI_Send_dat(status);//ChipErase();do{status = AT45DBXX_STATUS();SCI_Send_dat(status);}while((status&0x80)==0);ContinuousArrayLowRead(0,1, rx_dat,100);//0x03for(i=0;i<100;i++){SCI_Send_dat(rx_dat[i]);rx_dat[i]=0;}/*for(n=0;n<512;n++){AT45Buffer1Write(n,&n,1);//0x84 0x87status = AT45DBXX_STATUS();//SCI_Send_dat(status);while((status&0x80)==0);}AT45Buffer1Read(0x00,rx_dat,10);for(i=0;i<10;i++){SCI_Send_dat(rx_dat[i]);rx_dat[i]=0;}do{status = AT45DBXX_STATUS();SCI_Send_dat(status);}while((status&0x80)==0);Buffer1ToMainWithErase(0);do{status = AT45DBXX_STATUS();SCI_Send_dat(status);}while((status&0x80)==0);MainToBuffer1AT45(0);//0x53do{status = AT45DBXX_STATUS();SCI_Send_dat(status);}while((status&0x80)==0);AT45Buffer1Read(0x00,rx_dat,150);for(i=0;i<150;i++)SCI_Send_dat(rx_dat[i]);*/} 上一頁 1 2 下一頁
評論