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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? at25f512_drv.c~

?? CodeVision AT25F512 + ATmega168 Driver
?? C~
?? 第 1 頁 / 共 2 頁
字號:
/*C**************************************************************
/ Function: at25f512_drv
/----------------------------------------------------------------
/ Description: ATMEL FLASH (AT25F512A) Driver 
/----------------------------------------------------------------                                                       
/ Note:
/----------------------------------------------------------------
/ Author:   Sam Lu
/ Version:  V1.00
/ Date:     2006/02/05
*****************************************************************/
/*_____________I N C L U D E____________________________________*/
#include <mega168.h>
#include <driver\spi\spi_drv.h>
#include <driver\at25f512\at25f512_drv.h>
/*_____________V A R I A B L E__________________________________*/
/*_____________E N D____________________________________________*/ 
                              

/*F**************************************************************
/ Function: at25f512_initial
/----------------------------------------------------------------
/ Description: atmel at25f512a initial
/---------------------------------------------------------------- 
/ Parameter:                                                                                                                
/ Return:                                                      
/----------------------------------------------------------------
/ Note:
*****************************************************************/
void at25f512_initial(void)
{
    spi_state = READY_TO_SEND;
}

/*F**************************************************************
/ Function: spi_stc
/----------------------------------------------------------------
/ Description: spi stc (interrupt service routine)
/---------------------------------------------------------------- 
/ Parameter:                                                                                                                
/ Return:                                                      
/----------------------------------------------------------------
/ Note:
*****************************************************************/
interrupt [SPI_STC] void spi_stc(void)
{
    switch (spi_state)
    {
        case INSTRUCTION :                                          /* INSTRUCTION STATE */        
            spi_state = ADDRESS;        
            byte_cnt = 1;
            SPDR = (unsigned char)(address>>16);                    /* Address phase is 3 byte long for SPI flashes */
            break;        

        case ADDRESS :                                              /* ADDRESS STATE */        
            if (byte_cnt == NB_ADDR_BYTE)                           /* is the last address byte reached? */
            {
                spi_state = DATA;                                   /* go to the DATA state */
                byte_cnt = 0;
                SPDR = *data_ptr;                                   /* send the first byte */
            }
            else if (byte_cnt == 1)                                 /* must the middle address byte be sent? */
                {
                    byte_cnt ++;
                    SPDR = (unsigned char)(address>>8);
                }
                else
                {
                    byte_cnt ++;
                    SPDR = (unsigned char)(address);
                }
             break;         

        case DATA :                                                 /* DATA STATE */        
            data_ptr++;                                             /* point to the next byte (even if it was the last) */
            if (byte_cnt == nb_byte - 1 )                               /* is the last byte sent? */
            {   
                AT25F512A_CS = 1;                                   /* Disable AT25F512 Chip Select (H) */
                SPIF;
                //SPCR &= ~(1<<SPIE);
                SPCR &= ~((1<<SPE)|(1<<SPIE));
                spi_state = READY_TO_SEND;                          /* return to the idle state */                                
            }
            else
            {      
                byte_cnt ++;
                SPDR = *data_ptr;                
            }
            break;    
    
        default :
        {
            spi_state = READY_TO_SEND;
        }
    }  
}


/*F**************************************************************
/ Function: write_command
/----------------------------------------------------------------
/ Description: write command for at25f512 (WREN / WRDI)  
/---------------------------------------------------------------- 
/ Parameter:    op_code             : WREN/WRDI instruction code                                                                                                                
/ Return:       TRANSFER_COMPLETED  : the write access was completed without error
                BUSY                : the SPI peripheral or the serial memory is busy                                                     
/----------------------------------------------------------------
/ Note:
*****************************************************************/ 
unsigned char write_command(unsigned char op_code)
{
    unsigned char sr;                                               /* status register byte */  
    if (read_status_register(&sr) == TRANSFER_COMPLETED)            /* Is the SPI interface not currently busy */
    {      
        if (!(sr & (1<<RDY)))                                       /* is the serial memory ready ? */
        {   
            SPCR |= (1<<SPE);                                       /* Enable SPI Interface */
            AT25F512A_CS = 0;                                       /* Enable AT25F512A Chip Select (L) */                                                                                                       
            spi_transfer(op_code);                                  /* transmitt the op_code */            
            AT25F512A_CS = 1;                                       /* Enable AT25F512A Chip Select (H) */                        
            SPCR &= ~(1<<SPE);                                      /* Disable SPI Interface */           
            return TRANSFER_COMPLETED;
        }
        else
        {               
            return BUSY;
        }
    }
    else
    {          
        return BUSY; 
    }
}

/*F**************************************************************
/ Function: read_status_register
/----------------------------------------------------------------
/ Description: Read Status Register (RDSR)  
/---------------------------------------------------------------- 
/ Parameter:    op_code             : status variable address                                                                                                                
/ Return:       TRANSFER_COMPLETED  : the read access is completed without error
                BUSY                : the SPI peripheral is busy                                                     
/----------------------------------------------------------------
/ Note:
*****************************************************************/ 
unsigned char read_status_register(unsigned char *status)
{
    if (spi_state == READY_TO_SEND)
    {
        SPCR |= (1<<SPE);                                           /* Enable SPI Interface */
        AT25F512A_CS = 0;                                           /* Enable AT25F512A Chip Select (L) */
        spi_transfer(RDSR);                                         /* transmitt the op_code RDSR */
        *status = spi_transfer(0xFF);                               /* get the status register value, send the value 0xFF to avoid toggle on the MOSI line */
        AT25F512A_CS = 1;                                           /* Disable AT25F512A Chip Select (H) */
        SPCR &= ~(1<<SPE);                                          /* Disable SPI Interface */    
        return TRANSFER_COMPLETED;
    }
    else
    {
        *status = 1;
        return BUSY; 
    }
}


/*F**************************************************************
/ Function: write_status_register
/----------------------------------------------------------------
/ Description: Write Status Register (WRSR)  
/---------------------------------------------------------------- 
/ Parameter:    op_code             : status variable address                                                                                                                
/ Return:       TRANSFER_COMPLETED  : the read access is completed without error
                BUSY                : the SPI peripheral is busy                                                     
/----------------------------------------------------------------
/ Note:
*****************************************************************/ 
unsigned char write_status_register(unsigned char status_register)
{
    unsigned char sr;                                               /* read status register */
    if (read_status_register(&sr) == TRANSFER_COMPLETED)            /* Is the SPI interface currently not busy */
    {                  
        if (!(sr & (1<<RDY)))                                       /* is the serial memory ready ? */
        {                                                          
            while(write_command(WREN) != TRANSFER_COMPLETED);       /* write commande - write enable */                                                                        
            SPCR |= (1<<SPE);
            AT25F512A_CS = 0;            
            spi_transfer(WRSR);                                     /* transmit the WRSR op_code */
            spi_transfer(status_register);                          /* transmit the status register value */
            AT25F512A_CS = 1;                                       /* Disable AT25F512A Chip Select (H) */
            SPCR &= ~(1<<SPE);                                      /* Disable SPI Interface */
            return TRANSFER_COMPLETED;
        }
        else
        {
            return BUSY;
        }
    }
    else
    {
        return BUSY;
    }       
}

/*F**************************************************************
/ Function: get_char_array
/----------------------------------------------------------------
/ Description: get data by block mode and put on buffer
/---------------------------------------------------------------- 
/ Parameter:    address             : get data address
                nb_of_byte          : get number of byte
                destination         : the result area                                                                                                            
/ Return:       TRANSFER_COMPLETED  : the read access is completed without error
                BUSY                : the SPI peripheral is busy                                                     
                OUT_OF_RANGE        : address out of range (0x00FFFF)
/----------------------------------------------------------------
/ Note:
*****************************************************************/ 
unsigned char get_char_array(unsigned long address, unsigned long nb_of_byte, unsigned char *destination)
{
    unsigned char sr;                                               /* SPI memory status register */
    unsigned char AccessStatus;                                     /* Access status value */
    unsigned int  byteread_cnt;                                     /* Read byte counter (range 1 to memory size) */
    unsigned char *current_dest;
  
    current_dest = destination;                                     /* copy destination pointer because it needs to be incremented */
  
    if ((address) <= TOP_ADDR)                                      /* TOP ADDR = 0x00FFFF */
    {
        if (read_status_register(&sr) == TRANSFER_COMPLETED)        /* Is the SPI interface currently not busy */
        { 
            if (!(sr & (1<<RDY)))                                   /* is the SPI memory ready ? */
            {                                        
                SPCR |= (1<<SPE);                                   /* Enable SPI Interface */
                AT25F512A_CS = 0;                                   /* Enable AT25F512A Chip Select (L) */
                spi_transfer(READ);                                 /* transmitt the op_code READ */
                spi_transfer((unsigned char)(address>>16));         /* Address phase is 3 byte long for SPI flashes */
                spi_transfer((unsigned char)(address>>8));          /* send MSByte address first */
                spi_transfer((unsigned char)(address));             /* send LSByte address */
                byteread_cnt = 0;                   
                while (byteread_cnt < nb_of_byte)
                {                    
                    *current_dest++ = spi_transfer(0xFF);           /* store read byte, post increment the current_dest pointer */
                    byteread_cnt++;
                }                  
                AT25F512A_CS = 1;                                   /* Disable AT25F512A Chip Select (H) */
                SPCR &= ~(1<<SPE);                                   /* Enable SPI Interface */                
                AccessStatus = TRANSFER_COMPLETED;
            }
            else
            {
                AccessStatus = BUSY;
            }
        }   
        else
        {
            AccessStatus = BUSY;
        }   
    }
    else
    {
        AccessStatus = OUT_OF_RANGE;
    }
    return AccessStatus;  
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久这里只精品最新地址| 国产精品电影院| 国产精品毛片大码女人| 亚洲一级二级三级在线免费观看| 美女在线一区二区| 91国在线观看| 国产欧美日韩亚州综合| 亚洲成人一区二区在线观看| 国产aⅴ综合色| 91超碰这里只有精品国产| 国产精品网站在线观看| 久久精品国产精品青草| 在线视频一区二区三| 国产农村妇女精品| 久久精品国产免费看久久精品| 97久久久精品综合88久久| 国产午夜一区二区三区| 麻豆精品一二三| 欧美一区二区三区在线看| 一区二区三区四区激情 | 亚洲视频在线一区二区| 韩国欧美一区二区| 欧美高清你懂得| 亚洲国产毛片aaaaa无费看| 一本到高清视频免费精品| 国产亚洲欧美中文| 激情综合亚洲精品| 欧美一区二区三区喷汁尤物| 亚洲精品免费在线观看| 91麻豆国产精品久久| 最新日韩av在线| www.综合网.com| 国产精品国产馆在线真实露脸 | 欧美高清视频www夜色资源网| 一级日本不卡的影视| 丰满少妇在线播放bd日韩电影| 亚洲精品在线观| 亚洲一区在线观看免费| 91麻豆精品国产91久久久| 久久久www免费人成精品| 中文av字幕一区| 国产精品一区二区久久不卡| 久久久99精品免费观看不卡| 日本视频中文字幕一区二区三区| 欧美日韩成人在线| 麻豆freexxxx性91精品| 欧美哺乳videos| 福利91精品一区二区三区| 亚洲品质自拍视频| 欧美精品免费视频| 麻豆精品视频在线观看免费| 国产人伦精品一区二区| 91伊人久久大香线蕉| 夜夜嗨av一区二区三区| 欧美一区二区三区视频免费| 国精产品一区一区三区mba视频| 久久久久久综合| 99这里只有久久精品视频| 亚洲国产欧美在线| 久久五月婷婷丁香社区| 一本色道a无线码一区v| 日本麻豆一区二区三区视频| 国产精品午夜在线| 91黄色免费网站| 国精品**一区二区三区在线蜜桃| 国产精品传媒视频| 欧美在线观看禁18| 久久精品99久久久| 亚洲欧美国产毛片在线| 日韩三区在线观看| 91色婷婷久久久久合中文| 免费观看一级特黄欧美大片| 亚洲欧洲精品一区二区三区 | 性久久久久久久久久久久| 欧美一级二级三级蜜桃| 91蜜桃网址入口| 国内欧美视频一区二区| 一区二区三区在线免费播放| 精品国产伦一区二区三区免费| 99久久精品国产精品久久| 另类人妖一区二区av| 一卡二卡三卡日韩欧美| 亚洲国产高清aⅴ视频| 欧美一区三区二区| 欧美综合亚洲图片综合区| 国产91精品久久久久久久网曝门| 天天色天天操综合| 一色桃子久久精品亚洲| 欧美哺乳videos| 3d成人h动漫网站入口| 一本久久精品一区二区| 成人午夜av在线| 精品综合免费视频观看| 日韩国产欧美在线播放| 亚洲一区中文在线| 中文字幕亚洲电影| 国产精品国产馆在线真实露脸| 欧美精品一区二区三区久久久| 欧美一区二区三区成人| 欧美电影在哪看比较好| 欧美亚洲一区二区在线| 91麻豆精品在线观看| www.在线欧美| gogo大胆日本视频一区| 不卡在线观看av| 久久99精品久久久久久国产越南| 五月婷婷综合网| 性做久久久久久免费观看欧美| 樱花草国产18久久久久| 亚洲人成网站影音先锋播放| 国产精品伦理一区二区| 国产精品久久久久久亚洲毛片| 欧美岛国在线观看| 日韩精品一区二区三区视频播放 | 色婷婷av一区二区三区gif| av一区二区久久| 99视频在线观看一区三区| caoporen国产精品视频| 99精品在线免费| 日本乱码高清不卡字幕| 色悠久久久久综合欧美99| 色婷婷激情久久| 欧美日韩三级视频| 欧美精品99久久久**| 日韩一区二区三区电影| 久久久久久久久久久久电影| 欧美国产日本韩| 亚洲色大成网站www久久九九| 一区二区三区波多野结衣在线观看| 一区二区三区.www| 日本视频在线一区| 国产在线精品一区二区三区不卡 | 欧美午夜精品久久久| 欧美久久久久久久久久| 欧美xingq一区二区| 国产夜色精品一区二区av| 中文字幕一区免费在线观看| 亚洲美女屁股眼交| 美脚の诱脚舐め脚责91| 成人美女视频在线观看18| 在线观看亚洲一区| 欧美xxxxxxxx| 亚洲蜜桃精久久久久久久| 蜜桃视频一区二区三区在线观看| 国模冰冰炮一区二区| 色综合久久久久综合体| 91精品欧美福利在线观看| 久久久久国产一区二区三区四区| 成人免费在线视频| 亚洲国产精品影院| 国产一区二区三区香蕉| 91视频免费看| 欧美本精品男人aⅴ天堂| 亚洲精品老司机| 激情久久久久久久久久久久久久久久| 成人精品视频一区| 欧美精三区欧美精三区| 国产欧美久久久精品影院| 亚洲一区在线观看视频| 国产成人精品三级| 欧美另类久久久品| 国产精品久久久久影院| 日韩经典一区二区| 日本韩国一区二区三区视频| 久久久噜噜噜久噜久久综合| 亚洲gay无套男同| 成人免费观看视频| 欧美成人一区二区三区片免费 | 中文字幕一区二区三区不卡在线| 日韩在线一区二区三区| 91免费国产在线| 国产日韩精品一区二区三区| 日本亚洲欧美天堂免费| 在线观看91精品国产入口| 国产日韩欧美亚洲| 久久99精品久久久久久动态图 | 日韩免费性生活视频播放| 亚洲高清在线精品| av一区二区三区在线| 国产午夜亚洲精品理论片色戒| 三级一区在线视频先锋 | 99在线热播精品免费| 日本一区二区综合亚洲| 久久狠狠亚洲综合| 欧美一区二区三区在线观看视频| 亚洲精品一卡二卡| av一区二区不卡| 国产精品久久午夜| 成人综合在线视频| 国产精品看片你懂得| 91一区在线观看| 国产精品理论片| 成人av影视在线观看| 国产精品免费av| 懂色av一区二区三区免费观看 | 亚洲女厕所小便bbb| 91免费在线视频观看| 亚洲天堂精品在线观看| 99久久精品费精品国产一区二区| 国产精品女主播av|