亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 45db041.c

?? 提供DataFlash(AT45DB041)的底層讀寫驅(qū)動函數(shù)
?? C
字號:
/**************************************************
Name:   45DB041.C
Func:   Provide some operations of AT45DB041B-SC
        (ATMEL Inc. DataFlash, 4M bits, SPI interface)  
Author: Pan.L.F
Date:   2005-11-6
---------------------------------------------------*/

#include <intrins.h>
#include "45DB041.h"
#include "main.h"




/*-----------------------------------------------------
             SPI_WriteByte()

Func:      Send a byte of data to the device using
           SPI interface. 
Input:     the data(one byte) you want to send.
Output:    No.
Attention: MODE-->Inactive Clock Polarity High 
           and SPI Mode 3
--------------------------------------------------------*/
void SPI_WriteByte(tByte spi_write_data)
{
   tByte temp,i;
   temp=spi_write_data;

   //AT45DB041_CS=0; /CS should not be control here    
   
   for(i=0;i<8;i++)  //send 8 bits
   {
     AT45DB041_SCK=0;      
     AT45DB041_SI=(bit)((temp & 0x80)>>7);//MSB first
     temp=temp<<1;
     _nop_();
     AT45DB041_SCK=1; 
     _nop_();
   }
}  
   


/*-----------------------------------------------------
             SPI_ReadByte()

Func:      Read a byte of data from the device using
           SPI interface. 
Input:     No.
Output:    the data(one byte) read.
Attention: MODE-->Inactive Clock Polarity High 
           and SPI Mode 3
--------------------------------------------------------*/
tByte SPI_ReadByte(void)
{
  tByte i,temp;
  bit bit_in;

  temp=0x00;//initialize the data output
   
  for(i=0;i<8;i++) 
  {
     AT45DB041_SCK=0;
     _nop_();
     _nop_();
     AT45DB041_SCK=1;
     bit_in=AT45DB041_SO;
     
     if(bit_in) temp=temp | 0x01;
     if(i<7) temp=temp << 1; 
  }
  return (temp);
}


/*-------------------------------------------------------
            AT45_Write_Buffer()

Func:      Write a block of data to buffer 1 or 2 of 
           the device AT45DB041B.  
Input:     (1)0: choice buffer 1; 
              1: choice buffer 2.
           (2)address of the buffer(0~263,nine bits:BFA8~BFA0).
           (3)a pointer poited to the first address of an array; 
                  
Output:    No.
Attention: (1)the data stream load to the device before
              you write user_data into the device is:
            
           1000 0100  (for buffer 1)
           1000 0111  xxxx xxxx  xxxx xxxBFA8  BFA7~BFA0 
           (2) the end of the data array you want to load
               into the device must be '\n'. 
           (3) 1 buffer=264 bytes
---------------------------------------------------------*/
void AT45_Write_Buffer(bit buffer_choice,tWord address,const char * const string)
{
  tWord i; 
  
  AT45DB041_CS=0; //active the device
  
  if(buffer_choice)
  {
     SPI_WriteByte(0x87);   //buffer 2
  }
  else SPI_WriteByte(0x84); //buffer 1
  
  SPI_WriteByte(0x11);      //xxxx xxxx don’t care bits

  if(address>255)
  {
     SPI_WriteByte(0x11);   //BFA8=1
  }
  else SPI_WriteByte(0x10); //BFA8=0 

  
  SPI_WriteByte((tByte)(address & 0x00ff)); //BFA7~BFA0

  //now send the user_data
  i=0;
  while((string[i]!='\n')&(i<0xffff))  /*when i>263,write the data from the 
                                       beginning of the buffer meaning only the
                                       last 264 bytes will be stored in the 
                                       buffer. More detail in the datasheet.*/
  {
    SPI_WriteByte(string[i]);
    i++;
  } 
    
  AT45DB041_CS=1; //inactive the device
}




/*-----------------------------------------------------------------
            AT45_Read_Buffer()

Func:      Read a block of data from buffer 1 or 2 of 
           the device AT45DB041B.  
Input:     (1)0: choice buffer 1; 
              1: choice buffer 2.
           (2)nine address bits(BFA8~BFA0):
           (3)how many bytes do you want to read?(<265)
           (4)a pointer poited to the first address of an array; 
                  
Output:    No.
Attention: (1)the data stream load to the device before
              you write user_data into the device is:      
      
           0101 0100  (for buffer 1)
           0101 0110  xxxx xxxx  xxxx xxxBFA8  BFA7~BFA0 xxxx xxxx           
------------------------------------------------------------------*/
void AT45_Read_Buffer(bit buffer_choice,tWord address,tWord num,char * string)
{
  tWord i;
  
  AT45DB041_CS=0;  //active the device
  
  if(buffer_choice)
  {
     SPI_WriteByte(0x56);   //buffer 2
  }
  else SPI_WriteByte(0x54); //buffer 1
  
  SPI_WriteByte(0x11);      //xxxx xxxx

  if(address>255)
  {
     SPI_WriteByte(0x11);   //BFA8=1
  }
  else SPI_WriteByte(0x10); //BFA8=0

  SPI_WriteByte((tByte)(address & 0x00ff));//BFA7~BFA0

  
  SPI_WriteByte(0x33);      //xxxx xxxx
  
  //now read the user_data
  _nop_();
  _nop_();
  for(i=0;((i<=263)&(i<num));i++)
  {
    
   string[i]=SPI_ReadByte();
  }
  
  AT45DB041_CS=1; 
}
  



/*-----------------------------------------------------------
         AT45_MemoryRead()

Func:   sequentially read a continuous stream of data 
        from the device's main memory.
Input:  (1)which page?(0~2047)---------------------page
        (2)from where of the page(0~263)--------address
        (3)how many bytes do you want to read?------num
        (4)a pointer poited to the first address 
           of an array.the data is store in this array.           
Output: No.
Attention: 68h--xxxx PA10~PA7--PA6~PA0 BFA8--BFA7~BFA0--
           xxxx xxxx--xxxx xxxx--xxxx xxxx--xxxx xxxx
-------------------------------------------------------------*/
void AT45_MemoryRead(tWord page,tWord address,tWord num,char * string)
{
   tWord i;
   tByte temp;   
   AT45DB041_CS=0;
   
   //send command stream of data
   SPI_WriteByte(0x68);
   SPI_WriteByte((tByte)((page & 0x0780)>>7));
   
   temp=(tByte)(page & 0x007F);
   temp=temp<<1;
   if(address & 0x0100) temp=temp | 0x01;
   SPI_WriteByte(temp);
  
   SPI_WriteByte((tByte)(address & 0x00ff));
   
   SPI_WriteByte(0x33);//32 don't care bits 
   SPI_WriteByte(0x33); 
   SPI_WriteByte(0x33); 
   SPI_WriteByte(0x33);   
   
   //now read the user_data
   _nop_();
   _nop_();
   //2048*264=538624,but don't read so many 
   //bytes at one time.
   for(i=0;((i<=65535)&(i<num));i++)
   {
    
     string[i]=SPI_ReadByte();
   }
  
   AT45DB041_CS=1; 
}


/*----------------------------------------------------
              AT45_MemoryPageWrite()

Func:     Main Memory Page Program through Buffer 1 or 2.
Input:    (1)0: use buffer 1
             1: use buffer 2
          (2)the start address of the buffer.-----address
          (3)which page will be write?(0~2047)-------page
          (4) how many bytes will be write?-----------num
          (5)a pointer poited to the first address of 
             the array in which you store your data.
          
Output:   No.
Attention: (1)This operation write data to buffer,until the 
            /cs change from low to high, then load the 
            data from buffer to the choiced page.
            the initial stream of data is:
         
           0x82 (use buffer 1)
           0x85--xxxx PA10~PA7--PA6~PA0 BFA8--BFA7~BFA0            
        
------------------------------------------------------*/
void AT45_MemoryPageWrite(bit buffer_choice,tWord page,tWord address,tWord num,const char * const string)
{
   tWord i;
   tByte temp;   
   AT45DB041_CS=0;
   
   //send command stream of data
   if(buffer_choice)
   {
     SPI_WriteByte(0x85);    //buffer 2
   }
   else SPI_WriteByte(0x82); //buffer 1

   SPI_WriteByte((tByte)((page & 0x0780)>>7));
   
   temp=(tByte)(page & 0x007F);
   temp=temp<<1;
   if(address & 0x0100) temp=temp | 0x01;
   SPI_WriteByte(temp);
  
   SPI_WriteByte((tByte)(address & 0x00ff));

   //now write the user_data
   i=0;
   while(i<num)
   {
      SPI_WriteByte(string[i]);
      i++;
   }

   AT45DB041_CS=1;
}
   



/*-------------------------------------------------------------------
              AT45_MemoryToBuffer()

Func: transfer of the page of data from the main memory to the buffer
Input:    (1) 0: choice buffer 1
              1: choice buffer 2
          (2) which page of the memory?-------page
Output:    No.
Attention: the initial stream of data:
           
           0x53(for buffer 1)
           0x55--xxxx PA10~PA7--PA6~PA0 x--xxxx xxxx  
---------------------------------------------------------------------*/
void AT45_MemoryToBuffer(bit buffer_choice,tWord page)
{
   tByte temp;  
   tWord i; 

   AT45DB041_CS=0;
   
   if(buffer_choice) 
   {
     SPI_WriteByte(0x55);    //buffer 2
   } 
   else SPI_WriteByte(0x53); //buffer 1

   SPI_WriteByte((tByte)((page & 0x0780)>>7)); 

   temp=(tByte)(page & 0x007f);
   temp=temp<<1;
   SPI_WriteByte(temp);

   SPI_WriteByte(0x33);

   AT45DB041_CS=1;

   //wait
   i=0x8fff;
   while(i--);
   
}


/*----------------------------------------------------------
              AT45_BufferToMemory()

Func:   BUFFER TO MAIN MEMORY PAGE PROGRAM WITH BUILT-IN ERASE.
Input:  (1) 0: choice buffer 1
            1: choice buffer 2 
        (2) which page to store the data from buffer----page
Output: No.
Attention: the initial stream of data:
           
           0x83(for buffer 1)
           0x86--xxxx PA10~PA7--PA6~PA0 x--xxxx xxxx   
------------------------------------------------------------*/
void AT45_BufferToMemory(bit buffer_choice,tWord page)
{
   tByte temp; 
   tWord i;  

   AT45DB041_CS=0;
   
   if(buffer_choice) 
   {
     SPI_WriteByte(0x86);    //buffer 2
   } 
   else SPI_WriteByte(0x83); //buffer 1

   SPI_WriteByte((tByte)((page & 0x0780)>>7)); 

   temp=(tByte)(page & 0x007f);
   temp=temp<<1;
   SPI_WriteByte(temp);

   SPI_WriteByte(0x33);

   AT45DB041_CS=1;

   //wait
   i=0x8fff;
   while(i--);
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩精品综合在线| 国产一区美女在线| 成人黄色777网| 337p粉嫩大胆色噜噜噜噜亚洲| 亚洲福利一区二区| 美国精品在线观看| 欧美欧美午夜aⅴ在线观看| 亚洲欧洲日产国产综合网| 国产成人免费视频网站高清观看视频| 91麻豆精品国产91久久久久| 亚洲国产精品影院| 在线一区二区视频| 亚洲精品国产成人久久av盗摄| 国产一区二区91| 精品嫩草影院久久| 亚洲人妖av一区二区| 成人国产精品视频| 国产欧美日韩另类视频免费观看| 精彩视频一区二区| 精品88久久久久88久久久| 久久99国产精品成人| 日韩一区二区精品在线观看| 日本网站在线观看一区二区三区| 5566中文字幕一区二区电影| 日韩av电影天堂| 欧美一级片在线观看| 三级久久三级久久久| 日韩欧美一级精品久久| 精品一区二区三区免费播放| 日韩一区和二区| 国产福利91精品一区二区三区| 久久久久久久综合日本| 大桥未久av一区二区三区中文| 国产拍揄自揄精品视频麻豆| av不卡免费电影| 中文成人综合网| 91丨九色丨蝌蚪富婆spa| 亚洲资源中文字幕| 欧美一区二区人人喊爽| 精品一区二区三区欧美| 国产女主播一区| 色妞www精品视频| 日韩电影在线免费观看| 2020国产成人综合网| 成人一级视频在线观看| 一区二区三区**美女毛片| 欧美日韩成人综合天天影院| 精品亚洲成av人在线观看| 国产精品久久夜| 欧美视频一二三区| 天天色 色综合| 久久久国际精品| 欧美在线观看一区| 美腿丝袜亚洲综合| 国产婷婷色一区二区三区在线| 91麻豆视频网站| 欧美a级一区二区| 国产精品久久久久影院老司| 欧美日韩在线综合| 国产一区美女在线| 亚洲午夜av在线| 久久综合九色欧美综合狠狠| 欧美中文字幕一区二区三区亚洲| 久久99精品国产| 亚洲影院免费观看| 久久亚洲欧美国产精品乐播| 色婷婷综合久久| 国产乱子轮精品视频| 亚洲自拍欧美精品| 欧美国产一区在线| 日韩三级视频中文字幕| 91在线观看高清| 韩国视频一区二区| 亚洲综合另类小说| 国产欧美日韩综合精品一区二区 | 五月婷婷激情综合| 精品成人佐山爱一区二区| 欧美性色aⅴ视频一区日韩精品| 国产一区二区0| 全国精品久久少妇| 一区二区三区四区不卡在线| 国产欧美日产一区| 欧美哺乳videos| 欧美日韩精品一区视频| 91亚洲国产成人精品一区二区三| 一区二区三区欧美激情| 欧美绝品在线观看成人午夜影视| 色域天天综合网| 91在线视频在线| 91精品91久久久中77777| 一本大道久久a久久精二百| 91蝌蚪porny| 91官网在线观看| 欧美中文字幕一区| 欧美精品日韩综合在线| 制服丝袜亚洲色图| 日韩精品一区二区三区视频在线观看 | 水蜜桃久久夜色精品一区的特点| 五月婷婷综合网| 七七婷婷婷婷精品国产| 韩国av一区二区三区四区 | 国产呦萝稀缺另类资源| 国产成人免费视频网站| 91亚洲精品乱码久久久久久蜜桃| 色视频成人在线观看免| 欧美人妇做爰xxxⅹ性高电影| 日韩美女一区二区三区四区| 2020日本不卡一区二区视频| 中文字幕在线不卡一区| 亚洲一区二区三区免费视频| 日本中文在线一区| 国产成人鲁色资源国产91色综| 91在线免费播放| 91精品国产入口| 日本一区二区三区电影| 亚洲蜜臀av乱码久久精品| 日精品一区二区三区| 国产精品系列在线观看| 欧美在线一区二区| 欧美mv日韩mv| 18成人在线观看| 日韩精品欧美精品| 成人综合在线网站| 欧美体内she精视频| 久久久一区二区三区捆绑**| 亚洲少妇中出一区| 久久精品国产网站| 色综合天天综合网国产成人综合天 | av不卡在线播放| 欧美一区二区免费视频| **性色生活片久久毛片| 日韩电影免费在线观看网站| 成人的网站免费观看| 日韩欧美专区在线| 亚洲欧洲精品一区二区精品久久久| 三级久久三级久久久| 91一区二区在线观看| 欧美电视剧在线看免费| 洋洋av久久久久久久一区| 国产精品中文字幕一区二区三区| 欧洲一区二区三区在线| 国产婷婷精品av在线| 日本大胆欧美人术艺术动态| 97久久超碰国产精品| 国产亚洲制服色| 美女视频免费一区| 在线观看av一区二区| 国产精品看片你懂得| 久久精品国产77777蜜臀| 91九色02白丝porn| 国产精品免费网站在线观看| 精品一区二区三区在线播放 | 人人精品人人爱| 欧美性受xxxx| 中文字幕五月欧美| 国产一区二区三区日韩| 日韩一区二区影院| 午夜电影久久久| 欧美丝袜第三区| 一区二区三区四区国产精品| av动漫一区二区| 国产日韩av一区二区| 国产在线一区二区综合免费视频| 91麻豆精品国产无毒不卡在线观看| 亚洲欧美激情插| 成人av资源下载| 中文字幕精品—区二区四季| 国产毛片精品一区| 欧美草草影院在线视频| 美女国产一区二区三区| 在线播放中文一区| 亚洲成人先锋电影| 欧美综合久久久| 亚洲国产一区二区视频| 欧美色精品在线视频| 亚洲一区二区三区精品在线| 欧美性受xxxx| 日韩精品1区2区3区| 7777精品伊人久久久大香线蕉最新版| 亚洲韩国一区二区三区| 欧美日韩精品福利| 日韩高清国产一区在线| 日韩亚洲欧美在线观看| 久久精品久久精品| 久久久久久久综合日本| 国产成人一区在线| 日本一区二区三区四区| a在线欧美一区| 一区二区免费在线| 欧美日韩国产综合视频在线观看| 三级欧美在线一区| 精品日韩成人av| 国产1区2区3区精品美女| 一区在线中文字幕| 日本黄色一区二区| 奇米精品一区二区三区在线观看| 精品粉嫩超白一线天av| 成人黄色电影在线 | 欧美伊人久久大香线蕉综合69| 亚洲妇熟xx妇色黄|