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

📄 main.c

📁 周立功2103开发板CD资料
💻 C
字号:
#define IN_MAIN
#include "config.h"
#include "I2C.h"
#include "ZLG7290.H"
#pragma import(__use_no_semihosting_swi)        //don't delete this line

#define		ZLG7290			0x70				// 定义器件地址
#define		Glitter_COM		0x70            

/*********************************************************************************************************
** Function name:			IRQ_Exception
**
** Descriptions:			interrupt exceptional handler , change it as needed
**                          don't delete this function 
********************************************************************************************************/
void  IRQ_Exception(void)
{
}
/*********************************************************************************************************
* 函数名称:DelayNS()
* 函数功能:长软件延时。
* 入口参数:dly		延时参数,值越大,延时越久
* 出口参数:无
********************************************************************************************************/
void  DelayNS(uint32  dly)
{  uint32  i;

   for(; dly>0; dly--) 
      for(i=0; i<50000; i++);
}
/*********************************************************************************************************
** 函数名称:Main()
** 函数功能:ZLG7290演示实验。
** 入口参数:无
** 出口参数:无
** 说明:P0.17连接到SCL,P0.18连接到SDA。
********************************************************************************************************/
void Main(void)
{

	uint8  disp_buf[8];	
	uint8  key;
	uint8  i = 0;
   TargetInit(VPBDIV_DATA, PLLCFG_DATA, MAMTIM_DATA);      // don't delete
    while((PLLSTAT & (1 << 10)) == 0);                      // can delete
    


	DelayNS(100);
	i = I2C_Init(I2Cn_n,I2Cn_Mode,100000,I2Cn_Addr,0);	//I2C1主模式,通信速率100K,使用中断通道0
   
	/* 进行全闪测试 */
	for(i=0; i<8; i++) 
	{
		disp_buf[i] = 0xC8;
	}
	ZLG7290_SendBuf(disp_buf,8);
	DelayNS(1000);
   
	/* 显示"8 7 6 5 4 3 2 1" */
	for(i=0; i<8; i++) disp_buf[i] = i;
	ZLG7290_SendBuf(disp_buf,8);
	DelayNS(1000);
  
	/* 显示"LPC2210F" */
	disp_buf[7] = 0x14;
	disp_buf[6] = 0x16;
	disp_buf[5] = 0x0c;
	disp_buf[4] = 0x02;
 	disp_buf[3] = 0x01;
	disp_buf[2] = 0x00;
	disp_buf[1] = 0x03;
	disp_buf[0] = 0x0F;
	ZLG7290_SendBuf(disp_buf,8);
 
	/* 读取按键,设置键值对应的显示位闪烁 */
	while(1)
	{  
		DelayNS(1);   
		key = 0;
		I2C_ReadNByte(I2Cn_n,ZLG7290,1,0x01,disp_buf,2);
		if(0==disp_buf[1]) 
		{
			key = disp_buf[0];
		}     
    
		switch(key)
		{
			case  1:
			case  9:
				ZLG7290_SendCmd(Glitter_COM, 0x01);
				break;        
      
			case  2:
			case  10:
				ZLG7290_SendCmd(Glitter_COM, 0x02);         
				break;
         
			case  3:
			case  11:  
				ZLG7290_SendCmd(Glitter_COM, 0x04);
				break;
         
			case  4:
			case  12:
				ZLG7290_SendCmd(Glitter_COM, 0x08);
				break;
               
			case  5:
			case  13:
				ZLG7290_SendCmd(Glitter_COM, 0x10);
				break;       
               
			case  6:
			case  14:
				ZLG7290_SendCmd(Glitter_COM, 0x20);         
				break;
         
			case  7:
			case  15:  
				ZLG7290_SendCmd(Glitter_COM, 0x40);
				break;
         
			case  8:
			case  16:
				ZLG7290_SendCmd(Glitter_COM, 0x80);
				break;
               
			default: 
				break;
		}
	}
} 
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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