⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kbc.c

📁 OMAP1030 处理器的ARM 侧硬件测试代码 OMAP1030 是TI的双核处理器
💻 C
字号:
//************************************************************************************
//                               COMMIT.INC
//                         NEPTUNE  TESTING  PROJECT
//           FLIE NAME:  KBC.C
//           AUTHOR   :  ZHANGXUGUANG
//           REV      :  0.1
//       DESCRIPTION  :  CHECK THE KEYPAD IF IS OK. IF TIME IS ENOUGH I WILL CHECK THE
//                       KBC DETAILED INLCULING LONG KEY .REPEAT KEY AND TIME OUT TO IDLE
//                       STATE.
//*************************************************************************************

#include "kbc.h"
#include "UART_IrDA.h"
#include "elcd.h"
#include "interrupt_mapping.h"
unsigned int kbcInterruptFlag = 0;
unsigned int KBCFLAG = 0;
char keyid[36] ;
extern void Setgroupbit( int, int, int , int );
extern void Setgroup16bit( int, int, int, int );
int keyPadFlag = 0;

//**************************************************************************************/
//Function name:void configureclockofkbc( );
//Description  :configure the KBC_ICLK, KBC_FCLK(32K)
//Parameter    :No
//Author       :rev 0.1
//Date         :10/18 /05
//**************************************************************************************/
void configureclockofkbc( )
{  
   Setgroupbit( *(unsigned int*)( ARM_IDLECT2 ) , 11,1, 1);//enable the clkm3 clock domain.
     
   Setgroupbit( *(unsigned int*)( ARM_IDLECT2 ) , 7, 1, 1);//enable TIPB clock.
  
  }
//*************************************************************************************/
//function name:void initkbcinterface( ); 
//description  :init kbc module register.
//Parameter    :No
//Author       :zhangxuguang
//Rev          :0.1
//date         :10/18/05
//*************************************************************************************/
void initkbcinterface( )
{
  //add 060218
 

  Setgroup16bit( KBC_CNTL_REG, 1, 1, 0x01 );       // configure scan mode as hardware mode.
  Setgroup16bit( KBC_INTERUPT_ENABLE, 0, 3, 0x01 );//enable PRESS EVENT DETECT and disable other.
  Setgroup16bit( KBC_CNTL_REG, 2, 3, 0x05 );       //timeer clock divider is 256 the timer clock 
                                                   //is 32k / 256.
  Setgroup16bit( KBC_DEBOUNCING_TIME, 0, 6, 0x3f );//debouncing time is 31.25us * 256 * 64 = 0.5 ms
  }
//*************************************************************************************/
//Function name:void kbcinthprocess( )
//description  :Process the KBC interruption
//Parameter    :No
//Author       :zhangxuguang
//Rev          :0.1
//date         :10/18/05
//**************************************************************************************/
void kbcinthprocess( )
{
	int i;
    unsigned short kbcIntNum = 0xffff;
	unsigned short kbcIntNum2 = 0xffff;
	unsigned short kbcStatus = 0xffff;
    kbcInterruptFlag = 1;
	KBCFLAG = ~KBCFLAG;
//	Setgroupbit(0xfffe0004, 1, 1,1) ; //mask the mpu L2 irq1.
//    Setgroupbit(0xfffecb04, 0, 1,1) ; //mask MPU L1 IRQ O

    kbcStatus = *(unsigned short*)(0xfffbe008);
	
	
    
/*	
    kbcIntNum = *( int*)( 0xfffecb10 ) ;
    kbcIntNum = *( int*)( 0xfffe0010 ) ;

   	kbcIntNum = *( int*)( 0xfffecb00 ) ;

	kbcIntNum2 = *( int* )( 0xfffe0000 );
	kbcIntNum2 = *( int*)( 0xfffe0100 );
    
 */   
    
	for(i=0;i<500;i++);
	Setgroup16bit(0xfffbe00a, 0, 3, 0xf);

	kbcIntNum = *(unsigned short*)(0xfffbe014);
    kbcIntNum = *(unsigned short*)(0xfffbe016);
	kbcIntNum = *(unsigned short*)(0xfffbe018);
	if(KBCFLAG == 1)
		UART_Printf( UART2 ,"Press key process, \n\r" );
	else
		UART_Printf( UART2 ,"Release key process, \n\r" );  
//	Setgroupbit(0xfffe0018, 0, 1, 1 ); // enable new l2 interrupt
	
	
    
	
    
	return;
   }
//**************************************************************************************/
//Function Name:void kbcpinconfigure( )
//descriptioni :configure the pin muxplex/
//Parameter    :no
//Author       :zhangxuguang
//Rev          :0.1
//date         :10/18/05
//**************************************************************************************/
void kbcpinconfigure( )
{
   Setgroupbit( KBC_R0_CONF, 0, 2, 0 );
   Setgroupbit( KBC_R1_CONF, 0, 2, 0 );
   Setgroupbit( KBC_R2_CONF, 0, 2, 0 );
   Setgroupbit( KBC_R3_CONF, 0, 2, 0 );
   Setgroupbit( KBC_R4_CONF, 0, 2, 0 );
   Setgroupbit( KBC_R5_CONF, 0, 2, 0 );


  }
//*************************************************************************************/
//Functioin name:void kbcpulluprow(
//description   :pullup all row .
//Parameter     :no
//Author        :zhangxuguang
//Rev           :0.1
//date          :10/18/05
//*************************************************************************************/
void kbcpulluprow( )
{
   Setgroupbit( KBC_R0_CONF, 3, 2,0x3 );  //pull up r0.
   Setgroupbit( KBC_R1_CONF, 3, 2,0x3 );
   Setgroupbit( KBC_R2_CONF, 3, 2,0x3 );
   Setgroupbit( KBC_R3_CONF, 3, 2,0x3 );
   Setgroupbit( KBC_R4_CONF, 3, 2,0x3 );
   Setgroupbit( KBC_R5_CONF, 3, 2,0x3 );

  }
//************************************************************************************/
//Function Name :kbcinterruptinit( )
//description   :initialize the interruption
//Parameter     :no
//Author        :zhangxuguang
//Rev           :0.1
//Date          :10/18/05
//************************************************************************************/
void kbcinterruptinit( )
{
//  INTERRUPT_L2_ILR_1 = 0x06;
  IsrRegister(KEYBOARD_INT, kbcinthprocess);

  Setgroupbit( INTERRUPT_L2_ILR_1, 0, 8, 0x006 );     // rout to IRQ, LOW LEVEL, PRIORITY IS 1.
  Setgroupbit( INTERRUPT_L2_MIR_1, 1, 1, 0x000 );     // open mpu level 2 int-kb_it.

  Setgroupbit( INTERRUPT_L1_ILR_0, 0, 7, 0x002 );     // mpu level 1 IRQ-0, LOW LEVEL, PRI IS 0.
  Setgroupbit( INTERRUPT_L1_MIR  , 0, 1, 0x000 );     // open the level 1 IRQ-0.


  }

//************************************************************************************/
//Function Name: kbctest( )
//Description  : kbc testing function entry point.
//Parameter    : No
//Rev          : 0.1
//Author       : zhangxuguang
//Date         : 18/10/05
//ECR/ECN      : NO.
//************************************************************************************/
void  kbctest( )
{
  KBCFLAG = 1;
    
   kbcpinconfigure( );
   configureclockofkbc( );
    
   initkbcinterface( );
   kbcpulluprow( );

   kbcInterruptFlag=0;	
   kbcinterruptinit( );

   while(1 )
   { 
     
     if(kbcInterruptFlag==1)
	 {
	 UART_Printf( UART2 ," key process, \n\r" );
     kbcInterruptFlag=0;
     break;

    }
   	
   }
  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -