zoukankan      html  css  js  c++  java
  • key.c

    /**************************************************************
    4*4 Key Scan
    *************************************************************
    */

    #include "def.h"
    #include "option.h"
    #include "2440addr.h"
    #include "2440lib.h"
    #include "2440slib.h" 

    /******************************************************************************
        1X6 ¾ØÕó¼üÅÌ
    Áù¸öÊäÈëÒý½Å£º    EINT8 -----( GPG0  )
                    EINT11 -----( GPG3  )
                    EINT13-----( GPG5  )
                    EINT14-----( GPG6 )
                    EINT15-----( GPG7 )
                    EINT19-----( GPG11 )
                    
                    
    *****************************************************************************
    */
    U16 Key_Scan( void )
    {
        Delay( 80 ) ;

        if(      (rGPGDAT&(1<< 0)) == 0 )    
            return 1 ;
        else if( (rGPGDAT&(1<< 3)) == 0 )
            return 2;
        else if( (rGPGDAT&(1<< 5)) == 0 )
            return 3 ;
        else if( (rGPGDAT&(1<< 6)) == 0 )
            return 4 ;
        else if( (rGPGDAT&(1<< 7)) == 0 )
            return 5 ;
        else if( (rGPGDAT&(1<<11)) == 0 )
            return 6 ;
        else
            return 0;

    }

    static void __irq Key_ISR(void)
    {
        U8 key;
        U32 r;

        EnterCritical(&r);
        if(rINTPND==BIT_EINT8_23) {
            ClearPending(BIT_EINT8_23);
            if(rEINTPEND&(1<<8)) {
            //Uart_Printf("eint11 ");
                rEINTPEND |= 1<< 8;
            }
            if(rEINTPEND&(1<<11)) {
            //Uart_Printf("eint11 ");
                rEINTPEND |= 1<< 11;
            }
            if(rEINTPEND&(1<<13)) {
            //Uart_Printf("eint11 ");
                rEINTPEND |= 1<< 13;
            }
            if(rEINTPEND&(1<<14)) {
            //Uart_Printf("eint11 ");
                rEINTPEND |= 1<< 14;
            }
            if(rEINTPEND&(1<<15)) {
            //Uart_Printf("eint11 ");
                rEINTPEND |= 1<< 15;
            }
            if(rEINTPEND&(1<<19)) {
            //    Uart_Printf("eint19 ");        
                rEINTPEND |= 1<< 19;
            }
        }

        key=Key_Scan();
        if( key == 0xff )
            Uart_Printf( "Interrupt occur... Key is released! ") ;
        else
            Uart_Printf( "Interrupt occur... K%d is pressed! ", key) ;

        ExitCritical(&r);
    }

    void KeyScan_Test(void)
    {
        Uart_Printf(" Key Scan Test, press ESC key to exit ! ");    

        
        rGPGCON = rGPGCON & (~((3<<22)|(3<<6)|(3<<0)|(3<<10)|(3<<12)|(3<<14))) |
                             ((2<<22)|(2<<6)|(2<<0)|(2<<10)|(2<<12)|(2<<14)) ;        //GPG11,3 set EINT
        
        rEXTINT1 &= ~(7|(7<<0));    
        rEXTINT1 |= (0|(0<<0));    //set eint8 falling edge int
        
        rEXTINT1 &= ~(7<<12);
        rEXTINT1 |= (0<<12);    //set eint11 falling edge int
        
        rEXTINT1 &= ~(7<<20);
        rEXTINT1 |= (0<<20);    //set eint13 falling edge int
        
        rEXTINT1 &= ~(7<<24);
        rEXTINT1 |= (0<<24);    //set eint14 falling edge int
        
        rEXTINT1 &= ~(7<<28);
        rEXTINT1 |= (0<<28);    //set eint15 falling edge int
            
        rEXTINT2 &= ~(0xf<<12);
        rEXTINT2 |= (0<<12);    //set eint19 falling edge int
        

        rEINTPEND |= (1<<8)|(1<<11)|(1<<13)|(1<<14)|(1<<15)|(1<<19);        //clear eint 11,19
        rEINTMASK &= ~((1<<8)|(1<<11)|(1<<13)|(1<<14)|(1<<15)|(1<<19));    //enable eint11,19
        ClearPending(BIT_EINT0|BIT_EINT2|BIT_EINT8_23);
        pISR_EINT0 = pISR_EINT2 = pISR_EINT8_23 = (U32)Key_ISR;
        EnableIrq(BIT_EINT0|BIT_EINT2|BIT_EINT8_23);    

         while( Uart_GetKey() != ESC_KEY ) ;
         DisableIrq(BIT_EINT0|BIT_EINT2|BIT_EINT8_23);    
    }
  • 相关阅读:
    MVC上传文件并模拟进度条
    C#文件的压缩和解压(ZIP)使用DotNetZip封装类操作zip文件(创建/读取/更新)实例
    Inherits、CodeFile、CodeBehind的区别
    .csproj文件的配置 IIS可以调试
    C# <%@ Register %>指令
    将n行3列的数据dataTable装换成m行7列的dataTable
    在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: 命名管道提供程序, error: 40
    Js全选,插入实现
    Jquery autocomplete插件的使用
    jquery.autocomplete自动补全功能
  • 原文地址:https://www.cnblogs.com/liuchengchuxiao/p/4169156.html
Copyright © 2011-2022 走看看