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

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

?? 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 | 午夜精品爽啪视频| 国产免费久久精品| 日韩欧美国产综合一区 | 男女视频一区二区| 亚洲午夜一区二区| 亚洲九九爱视频| 日本一区二区三区四区在线视频| 欧美日韩综合在线免费观看| 91色视频在线| 91成人免费网站| 在线免费亚洲电影| 91社区在线播放| 在线观看一区二区视频| a4yy欧美一区二区三区| 国产成人精品免费网站| 国产成人精品午夜视频免费| 精品亚洲aⅴ乱码一区二区三区| 日韩精品欧美成人高清一区二区| 国产欧美日韩不卡| 国产欧美日韩在线观看| 久久众筹精品私拍模特| 欧美刺激午夜性久久久久久久| 欧美色图免费看| 555www色欧美视频| 日韩一区二区三区在线| 精品久久久久久无| 国产调教视频一区| 国产精品无遮挡| 亚洲精品中文字幕在线观看| 一区二区三区四区av| 亚洲午夜电影在线| 免费人成精品欧美精品| 亚洲第一综合色| 婷婷综合五月天| 久久精品国产精品青草| 国产一区二区成人久久免费影院| 国产在线精品一区二区不卡了| 国产精品一二三四五| 狠狠v欧美v日韩v亚洲ⅴ| 久久草av在线| 91亚洲精华国产精华精华液| 在线观看日韩一区| 日韩欧美国产精品一区| 2024国产精品| 一区二区三区精品视频| 日本不卡的三区四区五区| 首页国产欧美久久| 国产1区2区3区精品美女| 欧美少妇bbb| 国产亚洲一区二区三区在线观看 | 日本欧美久久久久免费播放网| 久久草av在线| 欧美日韩在线观看一区二区 | 欧美性色aⅴ视频一区日韩精品| 久久婷婷色综合| 日韩va亚洲va欧美va久久| 色综合久久天天| 亚洲欧洲精品天堂一级| 国产sm精品调教视频网站| 日韩欧美在线综合网| 午夜欧美电影在线观看| 在线精品亚洲一区二区不卡| 中文字幕中文字幕在线一区| 国产东北露脸精品视频| 精品88久久久久88久久久| 日欧美一区二区| 337p亚洲精品色噜噜| 亚洲国产精品麻豆| 欧洲精品视频在线观看| 综合久久久久久久| 99re66热这里只有精品3直播 | 欧美二区三区91| 日韩高清在线不卡| 678五月天丁香亚洲综合网| 丝袜美腿亚洲一区二区图片| 欧美乱妇15p| 麻豆精品在线视频| 日韩欧美国产小视频| 激情五月激情综合网| 久久亚区不卡日本| 国产传媒欧美日韩成人| 亚洲国产精品黑人久久久| 丰满亚洲少妇av| 亚洲欧美日韩人成在线播放| 欧洲色大大久久| 日本aⅴ亚洲精品中文乱码| 欧美va天堂va视频va在线| 精品在线观看免费| 国产精品久久影院| 91麻豆免费观看| 五月激情综合婷婷| 久久一区二区视频| a级精品国产片在线观看| 亚洲欧美一区二区三区久本道91| 在线观看中文字幕不卡| 全国精品久久少妇| 欧美国产在线观看| 欧美性大战久久| 国产在线播放一区二区三区| 国产精品每日更新| 欧美三级电影在线观看| 精品一区二区三区免费观看| 国产精品久久久久影院亚瑟| 欧美婷婷六月丁香综合色| 精品一区二区在线播放| 中文字幕亚洲欧美在线不卡| 欧美最猛黑人xxxxx猛交| 蜜桃精品视频在线观看| 中文字幕av一区 二区| 欧美日韩国产另类一区| 国产精品1024| 亚洲18影院在线观看| 国产女人18水真多18精品一级做 | 精品国产一区二区三区av性色| 成人污污视频在线观看| 调教+趴+乳夹+国产+精品| 国产精品每日更新| 精品国产乱码久久久久久夜甘婷婷 | 麻豆精品国产91久久久久久| 国产精品视频一二三区| 日韩欧美卡一卡二| 欧美在线影院一区二区| 国产白丝精品91爽爽久久| 奇米色一区二区| 一区二区三区毛片| 中文字幕在线播放不卡一区| 精品国产精品一区二区夜夜嗨 | 日韩影视精彩在线| 亚洲丝袜美腿综合| 久久久99免费| 在线电影欧美成精品| 欧日韩精品视频| 成人app软件下载大全免费| 免费成人你懂的| 亚洲午夜电影在线| 亚洲免费观看高清| 中文字幕日韩一区二区| 国产清纯美女被跳蛋高潮一区二区久久w | 成人福利视频网站| 国产乱码精品一区二区三区av| 亚洲高清免费一级二级三级| 亚洲精品国产视频| 亚洲乱码中文字幕综合| 亚洲日本在线视频观看| 亚洲欧洲99久久| 亚洲欧洲成人精品av97| 亚洲欧洲日本在线| 综合精品久久久| 亚洲日本va午夜在线电影| 中文字幕一区二区不卡| 日韩理论片在线| 一区二区在线看| 亚洲国产精品人人做人人爽| 天堂va蜜桃一区二区三区 | 另类的小说在线视频另类成人小视频在线| 亚洲高清中文字幕| 三级成人在线视频| 毛片av中文字幕一区二区| 激情综合色综合久久综合| 国产曰批免费观看久久久| 国产精品一二三| 丁香婷婷综合激情五月色| bt7086福利一区国产| 色婷婷激情一区二区三区| 欧美日韩精品系列| 欧美成人综合网站| 国产精品丝袜久久久久久app| 17c精品麻豆一区二区免费| 亚洲精品中文字幕乱码三区| 亚洲国产精品影院| 国内精品久久久久影院薰衣草 | 国产精品一色哟哟哟| 成人福利电影精品一区二区在线观看| 99在线精品视频| 欧美久久久久久蜜桃| 久久在线观看免费| 有码一区二区三区| 日本不卡一区二区三区高清视频| 狠狠色狠狠色综合日日91app| kk眼镜猥琐国模调教系列一区二区| 日本精品一级二级| 精品动漫一区二区三区在线观看| 国产精品丝袜一区| 日本不卡视频在线观看| 处破女av一区二区| 欧美日韩国产小视频| 久久综合五月天婷婷伊人| 亚洲精品视频在线观看网站| 久久爱www久久做| 91激情在线视频| 久久久亚洲精品石原莉奈| 亚洲成av人在线观看| 成人午夜短视频| 日韩欧美一二三| 亚洲成人av福利| 色综合视频在线观看| 久久精品人人做人人爽人人|