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

📄 test_main.c

📁 基于44b0板的键盘开发程序,已经测试通过,接上去的是4*4的键盘
💻 C
📖 第 1 页 / 共 3 页
字号:
}

void writebit(int b)
{

  WaitForSCK(0);
   if (b) 
     rPDATG |= 0x20; else
     rPDATG &= ~0x20;  
  WaitForSCK(1);
}

void ToKeyboard(int value)
{
  int i;
  int p=1;
  rPDATG &= ~0x40;   // Request to send/
  rPCONG = 0xD7FF;   // 01 01
  for (i=0;i<100;i++);
  rPDATG &= ~0x20;
  rPDATG |= 0x40;
  rPCONG = 0xC7FF;  // 00 01  
  for (i=0;i<8;i++)
  {  
     writebit(value & 0x01);
     p = p + value;
     value = value >> 1;
  }
  writebit(p & 0x01);
  writebit(1);

  rPCONG = 0xC3FF; // 00 00

  WaitForSCK(0);
  if (((rPDATG>>5) & 0x01)==1) 
  {
    rPCONG = 0xD7FF;// Release Mouse Line.
    rPDATG |= 0x60;  
    return;
  }
  WaitForSCK(1);
  rPCONG = 0xD7FF;// Release Mouse Line.
  rPDATG |= 0x60;  
  ReadMouse();
}


void ProcessKeyboard()
{
	int b,x,y;
	ToMouse(0xEB);
	b = ReadMouse();
	x = ReadMouse();
	y = ReadMouse();

 	Uart_Printf("\n\r %x, %x, %x", b, x, y);
	Delay(1000);
}

int Main()
{
	rSYSCFG=CACHECFG;   // Using 8KB Cache//
	rINTCON=0x5;    //Non-vectored,IRQ enable,FIQ disable 
	rINTMOD=0x0;    //All=IRQ mode
	Port_Init();
	Lcd_DispOFF();
	Lcd_PowerUp();
	Led_Display(0x00);
	Delay(10000);
	Led_Display(0x07);
	Delay(5000);
	Led_Display(0x0);
         //-------------------------------------------------------------------------------
 	// Init LCD Contorl
	ClearVideoBuffer();
	rLCDCON1=(0)|(1<<5)|(0x3<<8)|(0x3<<10)|(10<<12);
	rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21);  
	rLCDSADDR1= (0x00<<27) | ((0x0c000000>>22)<<21 ) | M5D(0x0c000000>>1);
	rLCDSADDR2= M5D( (((U32)0x0c000000+(LCD_XSIZE*LCD_YSIZE/8))>>1) ) | (13<<21);
	rLCDSADDR3= (LCD_XSIZE/16);
	rLCDCON1=(1)|(1<<5)|(0x3<<8)|(0x3<<10)|(10<<12);
	Intro();
	Lcd_DispON();
	//-------------------------------------------------------------------------------
 	Delay(50000);
	ClearIntro();
	Led_Display(0x00);
	Delay(10000);
	Led_Display(0x07);
	Delay(5000);
	Led_Display(0x0);

	mPosX = 154;
 	mPosY = 110;
	DrawMousePointer(mPosX, mPosY);

	Uart_Init(115200); 
	Uart_Printf("\n\rMOA Starting....");		

	//	KeyboardInitial();

	while (1)
	{

                ReadMouse();
		//ProcessKeyboard();

	};
	return 0;
}


void Port_Init(void)
{
    rPCONA=0x1ff;	

//    rPDATB=0x3ff;
//    rPCONB=0x3ff;
	rPDATB = 0x04f;
	rPCONB = 0x7cf;    

    rPDATC=0xffff;	//All I/O Is High
    rPCONC=0x0f05f555;	
    rPUPC=0x30c0;	//PULL UP RESISTOR should be enabled to I/O

    rPDATD=0xff;
    rPCOND=0xaaaa;	
    rPUPD=0xff;

    rPDATE=0x1ff;  	//All I/O Is High
    rPCONE=0x20428;	//All NC is INPUT	
    rPUPE=0x06;	//PE8 do not have programmable pull-up resistor.  

     rPDATF=0x1ff;	//All I/O Is High
    rPCONF=0x20900a;//All NC is INPUT
    rPUPF=0x163;

    rPDATG=0xff;
    rPCONG=0xC3FF;		
    rPUPG=0x0;		//should be enabled  
    
    rSPUCR=0x7; 	//D15-D0 pull-up disable
    
    rEXTINT=0x0;	//All EXTINT0-7 Low level interrupt
    rNCACHBE0=(((Non_Cache_End)>>12)<<16)|((Non_Cache_Start)>>12); 
}

⌨️ 快捷键说明

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