在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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>

            新聞中心

            S3C2440-IIC

            作者: 時間:2016-12-02 來源:網(wǎng)絡(luò) 收藏
            void __irq IIC_ISR(void){
            rSRCPND |= 0x1<<27;
            rINTPND |= 0x1<<27;
            flag = 0;
            }
            void wrat24c02(unsigned char add,unsigned char word, U32 length){
            int i;
            flag = 1;
            rIICDS = 0xa0; //dev add
            rIICCON &= "(0x1<<4); //清中斷
            rIICSTAT = 0xf0; //主發(fā)送模式,寫開始信號輸出,IIC Rx/Tx使能
            //等待ACK,接收器在接受到8位數(shù)據(jù)后,在第9個時鐘周期,拉低SDA電平,然后會產(chǎn)生中斷
            while(flag == 1)
            delay(100);
            flag = 1;
            rIICDS = word; //word add 發(fā)送要寫入的數(shù)據(jù)的內(nèi)存其實地址
            rIICCON &= "(0x1<<4);
            while(flag)
            delay(100); //注意要有delay
            for(i = 0; i < length; i++){
            flag = 1;
            rIICDS = iic_buffer[ i];
            rIICCON &= "(0x1<<4);
            while(flag)
            delay(100);
            }
            rIICCON = 0xe0; //IIC應(yīng)答有效,IICCLK=fpclk/512,IIC接受發(fā)送中斷使能位
            rIICSTAT = 0xd0; //主發(fā)送模式,rIICCON和rIICSTAT配置好,方便下次使用
            }
            void rdat24c02(unsigned char add, unsigned char word, U32 length){
            int i;
            char temp;
            flag = 1;
            rIICDS = add; //dev add
            rIICCON &= "(0x1<<4);
            rIICSTAT = 0xf0;
            while(flag)
            delay(100);
            flag = 1;
            rIICDS = word; //word add
            rIICCON &= "(0x1<<4);
            while(flag)
            delay(100);
            flag = 1;
            //這里的IIC的隨機讀操作,根據(jù)IIC的隨機讀時序,先發(fā)啟動,要讀取的設(shè)備地址和寫的內(nèi)存地址,方向是寫,即0,重啟IIC,
            //發(fā)要讀取的設(shè)備地址,這次方向是讀,然后接到ACK,從機向主機發(fā)data,主機相應(yīng)ACK,直到最后一個data,主機不相應(yīng)ACK,
            //發(fā)送停止信號
            rIICDS = add; //dev add
            rIICSTAT = 0xb0; //改變方向為主接收
            rIICCON &= "(0x1<<4);
            while(flag)
            delay(100);
            flag = 1;
            temp = rIICDS;
            rIICCON &= "(0x1<<4);
            while(flag)
            delay(100);
            for(i = 0; i < length; i++){
            flag = 1;
            if(i == (length - 1)){
            rIICCON &= "(0x1<<7);
            }
            iic_buffer[ i] = rIICDS;
            rIICCON &= "(0x1<<4);
            while(flag)
            delay(100);
            }
            rIICCON = 0xd0;
            rIICSTAT = 0x90;
            delay(200);
            }
            int Main(){
            int i;
            count= 0;
            length = 0;
            cmd = 0;
            command = 0;
            rGPECON = 0xa0000000; //GPE15~14 IICSDA,IICSCL
            rGPEUP = 0xc000;
            rIICCON = 0xe0; //IIC應(yīng)答有效,IICCLK=fpclk/512,IIC接受發(fā)送中斷使能位
            rIICSTAT = 0x10; //IIC總線有效Rx/Tx
            rULCON0 = 0x3;
            rUCON0 = (1<<11)|(1<<2)|(1<<0);
            rUBRDIV0 = 26;
            rSRCPND = (0x1<<28)|(0x1<<27);
            rINTPND = (0x1<<28)|(0x1<<27);
            rSUBSRCPND = 0x1<<0;
            rINTMSK &= "((0x1<<28)|(0x1<<27));
            rINTSUBMSK &= "(0x1<<0);
            pISR_UART0 = (U32)UART0_ISR;
            pISR_IIC = (U32)IIC_ISR;
            for(i = 0; i < 8; i++){
            iic_buffer[ i] = 0xee;
            }
            while(1){
            switch(cmd){
            case 0x01:
            cmd = 0;
            wrat24c02(add, word, length);
            break;
            case 0x02:
            cmd = 0;
            rdat24c02(add, word, length);
            for(i = 0; i < 8; i++){
            while(!(rUTRSTAT0&0x4));
            rUTXH0 = iic_buffer[ i];
            }
            break;
            }
            }
            return 0;
            }
            上一頁 1 2 下一頁

            關(guān)鍵詞: S3C2440IIC串行總

            評論


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

            關(guān)閉