在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > ARM·Nand Flash的控制

            ARM·Nand Flash的控制

            作者: 時間:2016-11-24 來源:網(wǎng)絡 收藏
            static void s3c2440_write_addr_lp(unsigned int addr)
            {
            int i;
            volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFADDR;
            int col, page;
            col = addr & NAND_BLOCK_MASK_LP;
            page = addr / NAND_SECTOR_SIZE_LP;
            *p = col & 0xff;
            for(i=0; i<10; i++);
            *p = (col >> 8) & 0x0f;
            for(i=0; i<10; i++);
            *p = page & 0xff;
            for(i=0; i<10; i++);
            *p = (page >> 8) & 0xff;
            for(i=0; i<10; i++);
            *p = (page >> 16) & 0x03;
            for(i=0; i<10; i++);
            }
            static unsigned char s3c2440_read_data(void)
            {
            volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFDATA;
            return *p;
            }
            static void nand_reset(void)
            {
            nand_chip.nand_reset();
            }
            static void wait_idle(void)
            {
            nand_chip.wait_idle();
            }
            static void nand_select_chip(void)
            {
            int i;
            nand_chip.nand_select_chip();
            for(i=0; i<10; i++);
            }
            static void nand_deselect_chip(void)
            {
            nand_chip.nand_deselect_chip();
            }
            static void write_cmd(int cmd)
            {
            nand_chip.write_cmd(cmd);
            }
            static void write_addr(unsigned int addr)
            {
            nand_chip.write_addr(addr);
            }
            static unsigned char read_data(void)
            {
            return nand_chip.read_data();
            }
            void nand_init(void)
            {
            #define TACLS 0
            #define TWRPH0 3
            #define TWRPH1 0
            if ((GSTATUS1 == 0x32410000) || (GSTATUS1 == 0x32410002))
            {
            nand_chip.nand_reset = s3c2410_nand_reset;
            nand_chip.wait_idle = s3c2410_wait_idle;
            nand_chip.nand_select_chip = s3c2410_nand_select_chip;
            nand_chip.nand_deselect_chip = s3c2410_nand_deselect_chip;
            nand_chip.write_cmd = s3c2410_write_cmd;
            nand_chip.write_addr = s3c2410_write_addr;
            nand_chip.read_data = s3c2410_read_data;
            s3c2410nand->NFCONF = (1<<15)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0);
            }
            else
            {
            nand_chip.nand_reset = s3c2440_nand_reset;
            nand_chip.wait_idle = s3c2440_wait_idle;
            nand_chip.nand_select_chip = s3c2440_nand_select_chip;
            nand_chip.nand_deselect_chip = s3c2440_nand_deselect_chip;
            nand_chip.write_cmd = s3c2440_write_cmd;
            #ifdef LARGER_NAND_PAGE
            nand_chip.write_addr = s3c2440_write_addr_lp;
            #else
            nand_chip.write_addr = s3c2440_write_addr;
            #endif
            nand_chip.read_data = s3c2440_read_data;
            s3c2440nand->NFCONF = (TACLS<<12)|(TWRPH0<<8)|(TWRPH1<<4);
            s3c2440nand->NFCONT = (1<<4)|(1<<1)|(1<<0);
            }
            nand_reset();
            }
            void nand_read(unsigned char *buf, unsigned long start_addr, int size)
            {
            int i, j;
            #ifdef LARGER_NAND_PAGE
            if ((start_addr & NAND_BLOCK_MASK_LP) || (size & NAND_BLOCK_MASK_LP)) {
            return ;
            }
            #else
            if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) {
            return ;
            }
            #endif
            nand_select_chip();
            for(i=start_addr; i < (start_addr + size);) {
            write_cmd(0);
            write_addr(i);
            #ifdef LARGER_NAND_PAGE
            write_cmd(0x30);
            #endif
            wait_idle();
            #ifdef LARGER_NAND_PAGE
            for(j=0; j < NAND_SECTOR_SIZE_LP; j++, i++) {
            #else
            for(j=0; j < NAND_SECTOR_SIZE; j++, i++) {
            #endif
            *buf = read_data();
            buf++;
            }
            }
            nand_deselect_chip();
            return ;
            }
            這一長串紅色的代碼也就是Nand Flash的初始化,我們可以仔細的分析一下Nand的控制寄存器
            再看代碼,從head.s中也就跳轉(zhuǎn)到了nand.c中的灰色部分 ;
            1)S3C2410和S3C2440的一個判斷
            2)定義了一個結(jié)構(gòu)體
            {
            nand_chip.nand_reset = s3c2440_nand_reset;
            nand_chip.wait_idle = s3c2440_wait_idle;
            nand_chip.nand_select_chip = s3c2440_nand_select_chip;
            nand_chip.nand_deselect_chip = s3c2440_nand_deselect_chip;
            nand_chip.write_cmd = s3c2440_write_cmd;
            #ifdef LARGER_NAND_PAGE
            nand_chip.write_addr = s3c2440_write_addr_lp;
            #else
            nand_chip.write_addr = s3c2440_write_addr;
            #endif
            nand_chip.read_data = s3c2440_read_data;
            s3c2440nand->NFCONF = (TACLS<<12)|(TWRPH0<<8)|(TWRPH1<<4);
            s3c2440nand->NFCONT = (1<<4)|(1<<1)|(1<<0);
            }
            *上面定義了結(jié)構(gòu)體,右邊一列都是s3c2440中可以調(diào)用的函數(shù) ;
            *在設置時序中:【NFCONF】寄存器
            使能NAND Flash控制器,初始化ECC,禁止片選 :【NFCONT】寄存器
            (我覺得了解一下就好了,還真的去看時序啊,那個老師都沒說的清楚,估計是默認值)

            【NFCONF】


            【NFCONT】


            上一頁 1 2 下一頁

            關(guān)鍵詞: ARMNandFlas

            評論


            技術(shù)專區(qū)

            關(guān)閉