惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Securelist
O
OpenAI News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
News and Events Feed by Topic
S
Security Affairs
SecWiki News
SecWiki News
Project Zero
Project Zero
L
Lohrmann on Cybersecurity
P
Proofpoint News Feed
P
Palo Alto Networks Blog
L
LINUX DO - 最新话题
H
Hacker News: Front Page
Recent Commits to openclaw:main
Recent Commits to openclaw:main
I
Intezer
Simon Willison's Weblog
Simon Willison's Weblog
W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
K
Kaspersky official blog
The GitHub Blog
The GitHub Blog
I
InfoQ
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
B
Blog
IT之家
IT之家
AWS News Blog
AWS News Blog
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Google DeepMind News
Google DeepMind News
Spread Privacy
Spread Privacy
N
News and Events Feed by Topic
Security Latest
Security Latest
美团技术团队
C
Check Point Blog
WordPress大学
WordPress大学
T
Tenable Blog
S
Security @ Cisco Blogs
Last Week in AI
Last Week in AI
博客园 - 聂微东
月光博客
月光博客
博客园 - 【当耐特】
S
Schneier on Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Secure Thoughts
Schneier on Security
Schneier on Security
C
Cisco Blogs
Cyberwarzone
Cyberwarzone

博客园 - 邵利超

ZigBee学习之37——osalInitTasks()分析 ZigBee2006协议栈介绍 点对点(单向)传输实验之LED灯指示 ZigBee四种绑定方式在TI Z-Stack中的应用【转载】 at45db642 程序代码 点对点通信实验小结 CC2430串口收发数据 gps 信号解析与显示 CC2430串口测试实验(UART) 正则表达式集合 C#版万年历 在C#中调用视图 c#调用SqlServer中的存储过程 SQL Server 2005 BI综合案例系列课程 SQL2005 BI系列课程 微软工程师主讲的SqlServer2005视频教程 多线程C#2.0聊天软件 内含代码 C#网络编程概述 三 C#网络编程概述 二
DSP串行FLASH(AT45DB642)的源代码
邵利超 · 2010-07-05 · via 博客园 - 邵利超

#include"serprt30.h" 

#include"math.h"     

//'注释:    

  //'DB45BUSY = CLKR0;    

  //'DB45CS = CLKX0;    

  //'DB45SCLK = FSX0;    

  //'SI = DX0; //'输出    

  //'SO = FSR0;//'输入     

  //'DB45OE = DR0;    

volatile SERIAL_PORT_REG *slpt = SERIAL_PORT_ADDR(0);    

extern unsigned int shu_cai_flag;   

/*   //'串口控制寄存器      

spo->gcontrol = 0x04;//'串行口总体控制寄存器   

spo->s_x_control = 0x666;//'串行口发送控制寄存器   

spo->s_r_control = 0x020;//'串行口接首控制寄存器   

*/     

extern int nCurRotorNum_new;   

extern int flash_write_buf[0x4000];    

void busy_wait()   

{    

  unsigned int busy_bit;    

  busy_bit = read_status();   

  while((busy_bit&0x80) != 0x80)   

     busy_bit = read_status();  //'信号忙则等      

}    

unsigned int read_status()   

{     

  unsigned int i,statusBuffer=0;      

  unsigned int statusComand;      

  statusComand = 0x57;   

   //'串口选择模式0       

wait_busy:     

  if( slpt->s_r_control_bit.clkdati == 0)   

      goto wait_busy; //' DB45BUSY     

  slpt->s_x_control_bit.clkdato = 1; //' DB45CS     

  slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK         

  delay_new(10);    

  slpt->s_x_control_bit.clkdato = 0; //' DB45CS     

  delay_new(10);                                        

  for(i=0;i<17;i++)   

  {       

     if(i<8)    

     {   

        if((statusComand&0x80) == 0x80)   

           slpt->s_x_control_bit.ddatout = 1; //' SI     

        else    

           slpt->s_x_control_bit.ddatout = 0; //' SI         

        statusComand = statusComand<<1;    

     }        

     else if(i>8)   

     {     

        statusBuffer<<=1;          

        if(slpt->s_r_control_bit.fsdatin == 1)    //' SO    

            statusBuffer++;                  

     }   

     slpt->s_x_control_bit.fsdatout = 1; //' DB45CLK     

     delay_new(2);   

     slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK          

  }   

  delay_new(5);    

  slpt->s_x_control_bit.clkdato = 1; //' DB45CS     

  return(statusBuffer);    

}    

void read_mainMemoryPage(unsigned int  pageAddr, unsigned int  byteAddr,unsigned int wordLong)   

{    

  unsigned int i,j;    

  unsigned int readPageComand = 0x52;     

  int  *pBuffer;    

  int tempData = 0;    

  pBuffer = flash_write_buf;   

  busy_wait();     

  slpt->s_x_control_bit.clkdato = 1; //' DB45CS     

  slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK    

  slpt->s_x_control_bit.clkdato = 0; //' DB45CS      

  for(i=0;i<65;i++)    

  {         

     if(i<8)    

     {   

       if((readPageComand&0x80) == 0x80)   

           slpt->s_x_control_bit.ddatout = 1; //' SI      

       else    

          slpt->s_x_control_bit.ddatout = 0; //' SI              

       readPageComand <<= 1;           

     }    

     if((i>=8)&&(i<21))   

     {   

        if((pageAddr&0x1000) == 0x1000)   

           slpt->s_x_control_bit.ddatout = 1; //' SI     

        else    

          slpt->s_x_control_bit.ddatout = 0; //' SI    

        pageAddr <<= 1;                     

     }   

     if((i>=21)&&(i<32))   

     {   

        if((byteAddr&0x400) == 0x400)   

           slpt->s_x_control_bit.ddatout = 1; //' SI     

        else    

          slpt->s_x_control_bit.ddatout = 0; //' SI           

        byteAddr <<= 1;              

     }   

     slpt->s_x_control_bit.fsdatout = 1; //' DB45CLK           

     delay_new(1);   

     slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK        

  }   

  for(i=0;i<WORDLONG;I++) if(slpt- <<="1;" *pBuffer="0;" { for(j="0;j<32;j++)">s_r_control_bit.fsdatin == 1)         

             *pBuffer = *pBuffer + 1; //' SO       

        slpt->s_x_control_bit.fsdatout = 1; //' DB45CLK          

        delay_new(4);   

        slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK      

     }       

     pBuffer++;       

  }   

  delay_new(5);   

  slpt->s_x_control_bit.clkdato = 1; //' DB45CS    

}    

void write_mainMemoryPage(unsigned int  pageAddr,unsigned int  byteAddr,unsigned int wordLong)   

{   

  unsigned int i,j;    

  unsigned int writePageComand = 0x53; // 'main->buffer1        

  int  *pBuffer,temp;     

  pBuffer = flash_write_buf;    

  temp = pageAddr;        

  busy_wait();   

  slpt->s_x_control_bit.clkdato = 1; //' DB45CS     

  slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK    

  slpt->s_x_control_bit.clkdato = 0; //' DB45CS      

  for(i=0;i<32;i++)    

  {        

     if(i<8)    

     {   

       if((writePageComand&0x80) == 0x80)   

           slpt->s_x_control_bit.ddatout = 1; //' SI     

       else    

          slpt->s_x_control_bit.ddatout = 0; //' SI             

       writePageComand <<= 1;           

     }    

     if((i>=8)&&(i<21))   

     {   

        if((pageAddr&0x1000) == 0x1000)   

           slpt->s_x_control_bit.ddatout = 1; //' SI      

        else    

          slpt->s_x_control_bit.ddatout = 0; //' SI     

        pageAddr <<= 1;                     

     }       

     slpt->s_x_control_bit.fsdatout = 1; //' DB45CLK     

     delay_new(2);        

     slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK           

  }    

  pageAddr = temp;     

  writePageComand = 0x82;    

  slpt->s_x_control_bit.clkdato = 1; //' DB45CS    

  busy_wait();    

  slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK    

  slpt->s_x_control_bit.clkdato = 0; //' DB45CS      

  for(i=0;i<32;i++)    

  {        

     if(i<8)    

     {   

       if((writePageComand&0x80) == 0x80)   

           slpt->s_x_control_bit.ddatout = 1; //' SI     

       else    

          slpt->s_x_control_bit.ddatout = 0; //' SI             

       writePageComand <<= 1;           

     }    

     if((i>=8)&&(i<21))   

     {   

        if((pageAddr&0x1000) == 0x1000)   

           slpt->s_x_control_bit.ddatout = 1; //' SI      

        else    

          slpt->s_x_control_bit.ddatout = 0; //' SI     

        pageAddr <<= 1;                     

     }   

     if(i>=21)   

     {   

        if((byteAddr&0x400) == 0x400)   

           slpt->s_x_control_bit.ddatout = 1; //' SI     

        else    

          slpt->s_x_control_bit.ddatout = 0; //' SI              

        byteAddr <<= 1;              

     }   

     slpt->s_x_control_bit.fsdatout = 1; //' DB45CLK     

     delay_new(2);        

     slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK           

  }    

  for(i=0;i<WORDLONG;I++) { for(j="0;j<32;j++)" slpt- 0x80000000) if((temp&0x80000000)="=" temp="*pBuffer;">s_x_control_bit.ddatout = 1; //' SI     

       else    

          slpt->s_x_control_bit.ddatout = 0; //' SI          

       temp <<= 1;    

       slpt->s_x_control_bit.fsdatout = 1; //' DB45CLK     

       delay_new(3);     

       slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK         

     }   

     pBuffer++;       

  }   

  delay_new(5);   

  slpt->s_x_control_bit.clkdato = 1; //' DB45CS    

}    

void erase_mainMemoryPage(int  pageAddr,int comandFlag)   

{   

   unsigned int i,j = 1,k;    

   unsigned int erasePageComand ; //'也擦出        

   unsigned int buf1,buf2;       

   if(comandFlag == 0)    

   {   

     erasePageComand = 0x81;   

   }   

   if(comandFlag == 1)   

   {       

       erasePageComand = 0x50;           

   }   

   if(comandFlag == 2)   

   {       

       erasePageComand = 0x50;    

       j = 1024;          

   }   

   buf1 = erasePageComand;   

   buf2 =  pageAddr;   

   for(k=0;k<J;K++,BUF2=BUF2+8) { slpt- busy_wait(); pageAddr="buf2;" erasePageComand="buf1;">s_x_control_bit.clkdato = 1; //' DB45CS     

     slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK    

     slpt->s_x_control_bit.clkdato = 0; //' DB45CS       

     for(i=0;i<32;i++)    

     {       

       if(i<8)    

       {   

          if((erasePageComand&0x80) == 0x80)   

            slpt->s_x_control_bit.ddatout = 1; //' SI      

        else    

           slpt->s_x_control_bit.ddatout = 0; //' SI             

        erasePageComand <<= 1;           

       }    

       if((i>=8)&&(i<21))   

       {   

          if((pageAddr&0x1000) == 0x1000)   

             slpt->s_x_control_bit.ddatout = 1; //' SI    

          else    

             slpt->s_x_control_bit.ddatout = 0; //' SI    

          pageAddr <<= 1;                     

       }   

       slpt->s_x_control_bit.fsdatout = 1; //' DB45CLK          

       delay_new(2);   

       slpt->s_x_control_bit.fsdatout = 0; //' DB45CLK    

     }     

     delay_new(5);   

     slpt->s_x_control_bit.clkdato = 1; //' DB45CS       

   }    

   busy_wait();