📄 main.c
字号:
/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: main.c
** Last modified Date: 2004-09-16
** Last Version: 1.0
** Descriptions: 如果使用DebugInExram生成目标编译工程,使用JTAG仿真调试时,注意开发板上的JP10跳线
** 需设置Bank0-Flash, Bank1-RAM。
**------------------------------------------------------------------------------------------------------
** Created by:
** Created date:
** Version:
** Descriptions:
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"
#define BEEP (1<<7) /* P0.7为蜂鸣器控制 */
// 声明外部函数
extern void DispRGB(void);
extern void CLineDemo(void);
extern void CRectangleDemo(void);
extern void CCircleDemo(void);
extern void DispXP_Pic(void);
extern void DrawTree( int xStart, int yStart,
double length,
double angle,
int num );
extern void Disp_BKColor(void);
extern void Disp_Pic1(void);
extern void Disp_Pic2(void);
extern void Disp_Pic3(void);
extern void Disp_Pic4(void);
extern void Disp_Pic5(void);
extern void Disp_Pic6(void);
extern void Disp_Pic7(void);
extern void Disp_Pic8(void);
extern void HzDisp(void);
extern void DelayNS(uint32 dly);
// LED1--LED4控制宏定义
#define LED_ADJ 28
#define LED_IOCON (0xFF<<LED_ADJ)
#define LED_OFF() IO2SET=LED_IOCON
#define LED_DISP(dat) LED_OFF(); IO2CLR=((dat)<<LED_ADJ)
// 定义LED显示数据
uint8 const LED_DISP_TAB[42] =
{ 0x0F, 0x00, 0x0F, 0x00, 0x0F, 0x00, // 全闪
0x0F, 0x00, 0x0F, 0x00, 0x0F, 0x00,
0x00, 0x01, 0x03, 0x07, 0x0F, 0x07, // 向右增加
0x03, 0x01, 0x00,
0x05, 0x0A, 0x05, 0x0A, 0x05, 0x0A, // 向左移动
0x05, 0x0A, 0x05, 0x0A, 0x05, 0x0A,
0x00, 0x08, 0x0C, 0x0E, 0x0F, 0x0E, // 向右增加
0x0C, 0x08, 0x00
};
static uint8 led_no = 0; // LED显示数据计数器(LED_DISP_TAB[led_no])
/****************************************************************************
* 名称:IRQ_Time0()
* 功能:定时器0中断服务程序,取反LEDCON控制口。
* 入口参数:无
* 出口参数:无
****************************************************************************/
void __irq IRQ_Time0(void)
{ // 设置LED显示数据计数器
led_no++;
if(led_no>=42)
{ led_no = 0;
}
LED_DISP(LED_DISP_TAB[led_no]);
T0IR = 0x02; // 清除中断标志
VICVectAddr = 0x00; // 通知VIC中断处理结束
}
/****************************************************************************
* 名称:Time0Init()
* 功能:初始化定时器0,定时时间为0.3S,并打开中断。
* 入口参数:无
* 出口参数:无
****************************************************************************/
void Time0Init(void)
{
T0PR = 99; // 设置定时器0分频为100分频,得110592Hz
T0MCR = 0x03<<3; // 匹配通道1匹配中断并复位T0TC
T0MR1 = 110592/3; // 设置MR1比较值(0.3S定时值)
T0TCR = 0x03; // 启动并复位T0TC
T0TCR = 0x01;
/* 设置定时器0中断IRQ */
VICIntSelect = 0x00; // 所有中断通道设置为IRQ中断
VICVectCntl0 = 0x24; // 定时器0中断通道分配最高优先级(向量控制器0)
VICVectAddr0 = (uint32)IRQ_Time0; // 设置中断服务程序地址向量
VICIntEnable = 0x00000010; // 使能定时器0中断
}
// 主程序。控制LCD显示图片、汉字,控制LED显示流水灯。
int main (void)
{
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
IO0DIR = BEEP; // 设置蜂鸣器的控制口为输出
IO2DIR = LED_IOCON; // 设置LED1--LED4的控制口为输出
LED_OFF();
srand(3721); // 初始化随机总机
Time0Init();
GUI_Initialize();
while(1)
{
// 控制蜂鸣器响
IO0CLR = BEEP;
DelayNS(15); // 延时
IO0SET = BEEP;
DelayNS(1); // 延时
// 画图操作演示
CLineDemo();
GUI_ClearSCR();
CRectangleDemo();
GUI_ClearSCR();
CCircleDemo();
GUI_ClearSCR();
DispXP_Pic(); // 显示背景图片
DrawTree(120,260, 30, 1.67, 9);
DelayNS(100);
GUI_ClearSCR();
// 显示RGB三色
DispRGB();
DelayNS(200); // 延时
// 图片显示演示
Disp_Pic1();
DelayNS(300);
Disp_Pic2();
DelayNS(300);
Disp_Pic3();
DelayNS(300);
Disp_Pic4();
DelayNS(300);
// 广告图片显示
Disp_Pic5();
DelayNS(300);
Disp_Pic6();
DelayNS(300);
Disp_Pic7();
DelayNS(300);
Disp_Pic8();
DelayNS(300);
GUI_ClearSCR();
// 显示" 广州周立功
// 单片机
// 发展有限公司 "
HzDisp();
DelayNS(200); // 延时
GUI_ClearSCR();
}
return(0);
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -