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

📄 icetek-vc5509-edu.h

📁 非常有用的vc5509 c语言入门程序2,对于入门者非常有用
💻 H
字号:
// 2005.Jan.15 ICETEK-CTR Define Changed.
//
#include "scancode.h"


// McBSP0  ------------------------------------------------------
ioport unsigned int *SPCR20=(unsigned int *)0x2804;
ioport unsigned int *SPCR10=(unsigned int *)0x2805;
ioport unsigned int *PCR_0=(unsigned int *)0x2c12;
#define SPCR1_0 (*SPCR10)
#define SPCR2_0 (*SPCR20)
#define PCR0 (*PCR_0)
// McBSP1  ------------------------------------------------------
ioport unsigned int *SPCR21=(unsigned int *)0x2c04;
ioport unsigned int *PCR_1=(unsigned int *)0x2c12;
#define SPCR2_1 (*SPCR21)
#define PCR1 (*PCR_1)
// McBSP2  ------------------------------------------------------
ioport unsigned int *SPCR12=(unsigned int *)0x3005;
ioport unsigned int *PCR_2=(unsigned int *)0x3012;
#define SPCR1_2 (*SPCR12)
#define PCR2 (*PCR_2)

// ICETEK-VC5509-A -----------------------------------------------
#define LBDS (*((unsigned int *)0x400001))
#define DIPS (*(unsigned int *)0x400002)
// ICETEK-CTR  --------------------------------------------------
#define CTRGR (*(unsigned int *)0x600800)
#define CTRKEY (*(unsigned int *)0x602800)
#define CTRCLKEY (*(unsigned int *)0x600801)
#define CTRLA (*(unsigned int *)0x602802)
#define CTRLR (*(unsigned int *)0x602803)
#define CTRLCDCMDR (*(unsigned int *)0x602800)
#define CTRLCDCR (*(unsigned int *)0x600801)
#define CTRLCDLCR (*(unsigned int *)0x602801)
#define CTRLCDRCR (*(unsigned int *)0x600802)
// Special values -----------------------------------------------
#define LCDCMDTURNON 0x3f
#define LCDCMDTURNOFF 0x3e
#define LCDCMDSTARTLINE 0xc0
#define LCDCMDPAGE 0xb8
#define LCDCMDVERADDRESS 0x40

// Variables
unsigned char ledbuf[8],ledx[8];

unsigned char ledkey[10][8]=
{
	{0x00,0x00,0x7C,0x82,0x82,0x82,0x7C,0x00},	//0
	{0x00,0x00,0x00,0x84,0xFE,0x80,0x00,0x00},	//1
	{0x00,0x00,0x84,0xC2,0xA2,0x92,0x8C,0x00},	//2
	{0x00,0x00,0x44,0x92,0x92,0x92,0x6C,0x00},  //3
	{0x00,0x00,0x30,0x28,0x24,0xFE,0x20,0x00},  //4
	{0x00,0x00,0x4E,0x92,0x92,0x92,0x62,0x00},  //5
	{0x00,0x00,0x7C,0x92,0x92,0x92,0x64,0x00},  //6
	
	{0x00,0x00,0x02,0xC2,0x32,0x0A,0x06,0x00},  //7
	{0x00,0x00,0x6C,0x92,0x92,0x92,0x6C,0x00},  //8
	{0x00,0x00,0x4C,0x92,0x92,0x92,0x7C,0x00}   //9
};
unsigned char ledbuf[8],ledx[8];
unsigned int _numDot[8][8]=
{
	{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03},	//9
	{0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00},	//9
	{0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0},	//9
	{0xf0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00},	//9
	
	{0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f},	//9
	{0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00},	//9
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},	//9
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}	//9

};
//unsigned int _num[10][8][8]=
//{
unsigned int _num9[8][8]=
{
	{0x00,0x00,0x00,0x00,0x0f,0x0f,0xf0,0xf0},	//9
	{0xf0,0xf0,0xf0,0xf0,0x0f,0x0f,0x00,0x00},	//9
	{0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x0f},	//9
	{0x0f,0x0f,0x0f,0x0f,0xff,0xff,0x00,0x00},	//9
	
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//9
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//9
	{0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0},	//9
	{0xf0,0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00}	//9

};
unsigned int _num8[8][8]=
{
	{0x00,0x00,0x00,0x00,0x0f,0x0f,0xf0,0xf0},	//8
	{0xf0,0xf0,0xf0,0xf0,0x0f,0x0f,0x00,0x00},	//8
	{0x00,0x00,0x00,0x00,0xf0,0xf0,0x0f,0x0f},	//8
	{0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0x00,0x00},	//8
	
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//8
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//8
	{0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0},	//8
	{0xf0,0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00}	//8

};
unsigned int _num7[8][8]=
{
	{0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff},	//7
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},	//7
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},	//7
	{0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00},	//7
	
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},	//7
	{0x00,0x00,0xf0,0xf0,0x0f,0x0f,0x00,0x00},	//7
	{0x00,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xf0},	//7
	{0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0x00,0x00}	//7

};
unsigned int _num6[8][8]=
{
	{0x00,0x00,0x00,0x00,0x0f,0x0f,0xf0,0xf0},	//6
	{0xf0,0xf0,0xf0,0xf0,0x0f,0x0f,0x00,0x00},	//6
	{0x00,0x00,0x00,0x00,0xff,0xff,0x0f,0x0f},	//6
	{0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0x00,0x00},	//6
	
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//6
	{0x00,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00},	//6
	{0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0},	//6
	{0xf0,0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00}	//6

};
unsigned int _num5[8][8]=
{
	{0x00,0x00,0x00,0x00,0x0f,0x0f,0xf0,0xf0},	//5
	{0xf0,0xf0,0xf0,0xf0,0x0f,0x0f,0x00,0x00},	//5
	{0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x0f},	//5
	{0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0x00,0x00},	//5
	
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//5
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},	//5
	{0x00,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xf0},	//5
	{0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0x00,0x00}	//5

};
unsigned int _num4[8][8]=
{
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},	//4
	{0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00},	//4
	{0x00,0x00,0x00,0x00,0xff,0xff,0xf0,0xf0},	//4
	{0xf0,0xf0,0xff,0xff,0xf0,0xf0,0x00,0x00},	//4
	
	{0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0},	//4
	{0x0f,0x0f,0xff,0xff,0x00,0x00,0x00,0x00},	//4
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},	//4
	{0x00,0x00,0xf0,0xf0,0x00,0x00,0x00,0x00}	//4

};
unsigned int _num3[8][8]=
{
	{0x00,0x00,0x00,0x00,0x0f,0x0f,0xf0,0xf0},	//3
	{0xf0,0xf0,0xf0,0xf0,0x0f,0x0f,0x00,0x00},	//3
	{0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x0f},	//3
	{0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0x00,0x00},	//3
	
	{0x00,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00},	//3
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//3
	{0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0},	//3
	{0xf0,0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00}	//3

};
unsigned int _num2[8][8]=
{
	{0x00,0x00,0x00,0x00,0xf0,0xfc,0xff,0xff},	//2
	{0xf3,0xf0,0xf0,0xf0,0xf0,0xf0,0x00,0x00},	//2
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0},	//2
	{0xf0,0xfc,0x3f,0x0f,0x03,0x00,0x00,0x00},	//2
	
	{0x00,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00},	//2
	{0x00,0x00,0x00,0xc0,0xff,0xff,0x00,0x00},	//2
	{0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0},	//2
	{0xf0,0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00}	//2

};
unsigned int _num1[8][8]=
{
	{0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0},	//1
	{0xff,0xff,0xf0,0xf0,0x00,0x00,0x00,0x00},	//1
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},	//1
	{0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00},	//1
	
	{0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x0f},	//1
	{0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00},	//1
	{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},	//1
	{0xf0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00}	//1

};
unsigned int _num0[8][8]=
{
	{0x00,0x00,0x00,0x00,0x0f,0x0f,0xf0,0xf0},	//0
	{0xf0,0xf0,0xf0,0xf0,0x0f,0x0f,0x00,0x00},	//0
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//0
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//0
	
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//0
	{0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00},	//0
	{0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0},	//0
	{0xf0,0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00}	//0

};
//};
/*
unsigned int _num0_b[16]=
{	//0_bottom
	0x0000,0x0000,0x0000,0x0000,0x0fff,0x0fff,0xF000,0xf000,
	0xf000,0xf000,0xf000,0xf000,0x0fff,0x0fff,0x0000,0x0000
};
unsigned int _num0_t[16]=
{	//0_top
	0x0000,0x0000,0x0000,0x0000,0xff00,0xff00,0x00f0,0x00f0,
	0x00f0,0x00f0,0x00f0,0x00f0,0xff00,0xff00,0x0000,0x0000
};
*/
unsigned int str1[64]=
{	//瑞泰创新
	0x1042,0x1042,0x0FFE,0x0842,0x0442,0x00,0xFF40,0x15E,
	0x150,0x7FD0,0x15F,0x3F50,0x4150,0x815E,0x7F40,0x00,
	0x420,0x2422,0x222A,0x112A,0x12AA,0x4C6A,0x843F,0x7FAA,
	0x82A,0xC6A,0x12AA,0x212A,0x232A,0x622,0x220,0x00,
	0x40,0x20,0x3FD0,0x404C,0x4043,0x4244,0x4448,0x43D8,
	0x7830,0x10,0x00,0x7FC,0x2000,0x4000,0x3FFF,0x00,
	0x2120,0x1124,0x4D2C,0x8135,0x7FE6,0x534,0x592C,0x2124,
	0x1800,0x7FC,0x24,0x24,0xFFE2,0x22,0x22,0x00
};

#define nMusicNumber 52
unsigned int music[nMusicNumber][2]=
{
	{101,1920},{121,1440},{114,480},{101,1920},{151,1920},
	{151,480},{135,480},{121,480},{101,480},{114,960},{121,960},{135,3840},
	{121,480},{114,480},{101,480},{91,480},{101,960},{101,960},
	{76,1920},{101,1920},{114,960},{121,960},{135,1440},{151,480},{151,1920},{0,1920},
	{101,1920},{121,1440},{114,480},{101,1920},{151,1920},
	{151,480},{135,480},{121,480},{101,480},{114,960},{121,960},{135,3840},
	{121,480},{114,480},{101,480},{91,480},{101,960},{101,960},
	{76,1920},{101,1920},{114,960},{121,960},{135,1440},{151,480},{151,1920},{0,1920}
};
unsigned int pwm[8]={ 0x86,0x87,0x83,0x8b,0x89,0x8d,0x8c,0x8e };
unsigned char dbClearKey;

// Functions
void InitInterrupt(void);			// 初始化中断
void InitCTR();						// 初始化ICETEK-CTR
void CloseCTR();					// 关闭ICETEK-CTR上各设备
void Delay(unsigned int nTime);		// 延时子程序
void Delay1(unsigned int nTime);	// 延时子程序(带LED显示刷新)
unsigned char GetKey();				// 读取键盘输入
void RefreshLEDArray();				// 刷新发光二极管阵列显示
void SetLEDArray(int nNumber);		// 修改发光二极管阵列显示内容
char ConvertScanToChar(unsigned char cScanCode);	// 将键盘扫描码转换成字符
void LCDCMD(unsigned char dbCommand);	// 向液晶显示器发送命令
void LCDWriteLeft(unsigned char dbData);	// 写液晶显示器左半屏
void _LCDCLS();							// 清除液晶显示器显示
void TurnOnLCD();						// 打开液晶显示器

void CloseCTR()
{
    CTRGR=0; 				 
    CTRLR=0; CTRLR=0x40;
    CTRLR=0x0c0;
	LCDCMD(LCDCMDTURNOFF);	
	dbClearKey=CTRCLKEY;
	LBDS=0;
}

void LCDCMD(unsigned char dbCommand)
{
	CTRLCDCMDR=dbCommand;		
	CTRLCDCR=0;
}

unsigned char GetKey()
{
	unsigned char dbReturn;
	
	dbReturn=CTRKEY;
	dbClearKey=CTRCLKEY;
	return dbReturn;
}

char ConvertScanToChar(unsigned char cScanCode)
{
	char cReturn;
	
	cReturn=0;
	switch ( cScanCode )
	{
		case SCANCODE_0: cReturn='0'; break;
		case SCANCODE_1: cReturn='1'; break;
		case SCANCODE_2: cReturn='2'; break;
		case SCANCODE_3: cReturn='3'; break;
		case SCANCODE_4: cReturn='4'; break;
		case SCANCODE_5: cReturn='5'; break;
		case SCANCODE_6: cReturn='6'; break;
		case SCANCODE_7: cReturn='7'; break;
		case SCANCODE_8: cReturn='8'; break;
		case SCANCODE_9: cReturn='9'; break;
		case SCANCODE_Plus: cReturn='+'; break;
		case SCANCODE_Minus: cReturn='-'; break;
	}
	return cReturn;
}

void InitCTR()
{
    CTRGR=0; CTRGR=0x80; CTRGR=0;
    CTRLR=0; CTRLR=0x40;
    CTRLR=0x0c0;
	LCDCMD(LCDCMDTURNOFF);	
	dbClearKey=CTRCLKEY;
	LBDS=0;
}

void Delay(unsigned int nDelay)
{
	int ii,jj,kk=0;
	for ( ii=0;ii<nDelay;ii++ )
	{
		for ( jj=0;jj<1024;jj++ )
		{
			kk++;
		}
	}
}

void Delay1(unsigned int nDelay)
{
	int ii,jj,kk=0;
	for ( ii=0;ii<nDelay;ii++ )
	{
		for ( jj=0;jj<64;jj++ )
		{
			RefreshLEDArray();
			kk++;
		}
	}
}

void RefreshLEDArray()
{
	int i;
	for ( i=0;i<8;i++ )
	{
		CTRGR=ledx[i];
		CTRLA=ledbuf[i];
	}
}

void SetLEDArray(int nNumber)
{
	int i;
	for ( i=0;i<8;i++ )
		ledbuf[i]=~ledkey[nNumber][7-i];
}

void LCDWriteLeft(unsigned char dbData)
{
	CTRLCDLCR=dbData;
	CTRLCDCR=0;
}

void LCDWriteRight(unsigned char dbData)
{
	CTRLCDRCR=dbData;
	CTRLCDCR=0;
}

void TurnOnLCD()
{
	LCDCMD(LCDCMDTURNON);
}

void _LCDCLS()
{
	int i,j;
	LCDCMD(LCDCMDSTARTLINE);
	for ( i=0;i<8;i++ )
	{
		LCDCMD(LCDCMDPAGE+i);
		LCDCMD(LCDCMDVERADDRESS);
		for ( j=0;j<64;j++ )
			LCDWriteLeft(0);
		LCDCMD(LCDCMDPAGE+i);
		LCDCMD(LCDCMDVERADDRESS);
		for ( j=0;j<64;j++ )
			LCDWriteRight(0);
	}
}

⌨️ 快捷键说明

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