亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲精品成人少妇| 激情六月婷婷久久| 99精品欧美一区二区三区综合在线| 2024国产精品视频| 久久国产日韩欧美精品| 日韩欧美中文字幕精品| 免费成人av在线播放| 欧美日韩和欧美的一区二区| 亚洲激情图片qvod| 91国产精品成人| 亚洲自拍偷拍欧美| 欧亚一区二区三区| 亚洲高清免费在线| 欧美日韩在线亚洲一区蜜芽| 亚洲国产视频一区二区| 欧美日韩不卡一区| 免费黄网站欧美| 欧美xxxxxxxxx| 国产在线一区观看| 国产女同互慰高潮91漫画| 风流少妇一区二区| 国产精品电影一区二区| 色婷婷久久一区二区三区麻豆| 亚洲美女一区二区三区| 欧美影片第一页| 日本午夜精品一区二区三区电影| 日韩欧美成人激情| 国产一区二区三区精品欧美日韩一区二区三区 | 日韩欧美在线不卡| 久久国产日韩欧美精品| 国产亚洲精品超碰| gogogo免费视频观看亚洲一| 亚洲美女屁股眼交3| 在线观看不卡一区| 免费成人你懂的| 国产亚洲精品福利| 色屁屁一区二区| 日韩不卡手机在线v区| 日韩精品中午字幕| 国产91精品久久久久久久网曝门| 成人欧美一区二区三区视频网页| 欧美日韩激情在线| 国产一区二区三区在线观看精品 | 色94色欧美sute亚洲线路一久| 亚洲久草在线视频| 欧美一级专区免费大片| 国产一区二区中文字幕| 一色桃子久久精品亚洲| 欧美日韩夫妻久久| 国产精品一级在线| 亚洲欧美一区二区三区极速播放 | 最新中文字幕一区二区三区| 在线亚洲一区观看| 免费xxxx性欧美18vr| 国产亚洲精品精华液| 欧洲一区二区三区免费视频| 久久精品国产免费看久久精品| 国产精品久久一卡二卡| 欧美视频一区二区三区| 激情图片小说一区| 亚洲精品免费一二三区| 精品欧美一区二区在线观看| 91在线视频网址| 免费黄网站欧美| 综合久久久久综合| 日韩午夜小视频| bt7086福利一区国产| 日本成人在线视频网站| 亚洲欧洲av色图| 日韩一二三区不卡| 99精品久久99久久久久| 久久精品99国产精品| 亚洲人精品一区| 精品对白一区国产伦| 在线观看日韩av先锋影音电影院| 国产伦精品一区二区三区视频青涩| 亚洲男女一区二区三区| 久久色.com| 欧美老女人在线| av在线一区二区| 久久国产乱子精品免费女| 伊人一区二区三区| 久久久99久久| 欧美一区二区在线免费播放| 92精品国产成人观看免费| 国模大尺度一区二区三区| 亚洲乱码国产乱码精品精的特点 | 色综合天天综合网天天狠天天| 老司机精品视频在线| 亚洲综合激情小说| 中文字幕av免费专区久久| 日韩欧美久久一区| 欧美亚洲国产怡红院影院| 成人黄色电影在线| 美女一区二区在线观看| 亚洲午夜精品在线| 国产精品成人一区二区三区夜夜夜| 日韩视频免费观看高清在线视频| 91成人网在线| 不卡免费追剧大全电视剧网站| 精品一区二区免费在线观看| 亚洲成人免费av| av电影天堂一区二区在线| 国产精品中文字幕日韩精品| 日韩电影免费一区| 亚洲午夜视频在线| 亚洲欧美一区二区久久| 国产亚洲一二三区| ww亚洲ww在线观看国产| 制服丝袜亚洲播放| 欧美日韩综合色| 色婷婷综合在线| 99国产精品视频免费观看| 国产夫妻精品视频| 国产一区二区三区四区五区美女| 天使萌一区二区三区免费观看| 亚洲一区二区三区中文字幕在线| 亚洲天堂网中文字| 国产精品久久久久一区二区三区 | 国产成人av电影在线| 精品一区二区三区视频| 美国一区二区三区在线播放| 亚洲国产欧美在线人成| 亚洲一二三区不卡| 一区二区三区在线免费| 亚洲欧美另类综合偷拍| 亚洲视频综合在线| 国产精品婷婷午夜在线观看| 日本一区免费视频| 久久久国产精品麻豆| 久久久久久99久久久精品网站| 欧美tickle裸体挠脚心vk| 精品少妇一区二区三区在线视频| 日韩精品一区二区三区swag| 欧美大肚乱孕交hd孕妇| 亚洲精品一区二区三区影院| 久久伊人蜜桃av一区二区| 久久影院视频免费| 久久精品夜夜夜夜久久| 欧美国产精品中文字幕| 国产精品福利一区二区| 亚洲乱码一区二区三区在线观看| 亚洲靠逼com| 亚洲成av人片观看| 亚洲大片精品永久免费| 日韩福利电影在线| 激情综合网激情| 福利91精品一区二区三区| 91婷婷韩国欧美一区二区| 在线观看日产精品| 3751色影院一区二区三区| 日韩一卡二卡三卡国产欧美| 欧美mv日韩mv| 中文字幕不卡在线| 亚洲美女免费在线| 天堂精品中文字幕在线| 黄网站免费久久| 国产精品系列在线播放| 91网站在线观看视频| 欧美日韩三级在线| 日韩亚洲欧美高清| 亚洲国产精品国自产拍av| 亚洲免费观看高清完整版在线观看熊| 亚洲成av人影院在线观看网| 久久国产乱子精品免费女| 成人毛片视频在线观看| 欧美性做爰猛烈叫床潮| 日韩一区二区免费在线电影| 欧美国产禁国产网站cc| 一区二区三区中文免费| 麻豆国产一区二区| 成人高清伦理免费影院在线观看| 色噜噜久久综合| 日韩欧美电影一二三| 国产精品国产三级国产有无不卡 | 六月婷婷色综合| 岛国精品在线观看| 精品视频一区二区三区免费| 久久综合中文字幕| 亚洲欧洲综合另类| 麻豆精品一区二区综合av| thepron国产精品| 欧美一区二区三区在线| 国产精品久久99| 青青草国产精品亚洲专区无| www.色精品| 日韩一区二区三区免费观看| 中文字幕在线视频一区| 日韩中文字幕麻豆| 成人黄动漫网站免费app| 在线播放亚洲一区| 国产精品三级在线观看| 日韩av电影免费观看高清完整版在线观看 | 日韩成人av影视| 不卡区在线中文字幕| 日韩免费视频一区| 一区二区三区四区乱视频| 经典三级视频一区| 在线观看日韩电影| 欧美国产一区视频在线观看|