📄 some_test.c
字号:
/*
***********************************************************************
Embest Info&Tech Co., Ltd. All rights reserved.
www.embedinfo.com
***********************************************************************
---------------- file information -------------------------------------
file name: uart0_test.c
version : v0
author : z.x.q. Embest
begin : 2006-04-10
finish : 2006-04-10
define : uart0_test file
notes :
---------------- modify information -----------------------------------
version :
modify :
begin :
finish :
define :
-----------------------------------------------------------------------
*/
/*-------------------------------------------------------------------*/
/* include files */
/*---------------------------------------------------------------- --*/
//#include "..\..\com\lpc_lib_lcd_touch_interface\lcd_touch.h"
#include "..\..\com\lpc_lib_touch\touch.h"
#include "..\..\com\lpc_lib_uart\lpc_lib_uart.h"
#include "..\..\com\lpc_lib_88\lpc_lib_88.h"
#include "..\..\com\lpc_lib_AD\lpc_lib_AD.h"
#include "..\..\com\22eb06_lib_iolamp\22eb06_lib_iolamp.h"
//#include "..\..\com\lpc_lib_keyboard\lpc_lib_keyboard.h"
//#include "..\..\com\lpc_lib_LCD\lpc_lib_LCD.h"
#include "..\..\com\lpc_lib_IIC\lpc_lib_IIC.h"
#include "..\..\com\lpc_lib_pwm\lpc_lib_pwm.h"
#include "..\..\com\lpc_lib_motor\lpc_lib_motor.h"
/*-------------------------------------------------------------------*/
/* extern global variable declare */
/*-------------------------------------------------------------------*/
extern void time_dly(INT32U dly);
/*-------------------------------------------------------------------*/
/* local function declare */
/*-------------------------------------------------------------------*/
void simple_test(void);
void com_test(void);
void AD_buzzer(void);
void motor_con(void);
//
//原程序里的
void disp_88_test(void);
void AD_test(void);
void led_test(void);
void uart_test(void);
void IIC_test(void);
//
void uart0_pc(void);
void uart0_uart1(void);
void switch_test(void);
void buzzer_test(void);
void motor(INT8U type);
//
void all_test(void);
void draw_picture(INT16U star_x,INT8U star_y,INT16U end_x,INT8U end_y,INT16U piexl_x,INT8U piexl_y);
void touch_errer(void);
void void_yc(void);
POINT getDisplayPoint(POINT touch_data);
void e_led_test(void);
void uart0_to_pc_testing(void);
/*-------------------------------------------------------------------*/
/* global variable define */
/*-------------------------------------------------------------------*/
INT8U case_value=1;
INT8U inter_flag=0; //进中断,标志位置1
POINT touch_data;
POINT lcd_pix;
INT8U bit_lcd=1;
/*
void xxx(xxx xxx, xxx xxx);
*/
/*-------------------------------------------------------------------*/
/* function code */
/*-------------------------------------------------------------------*/
INT32U Main(void)
{
VICIntEnClr = 0xffffffff; //off all interrupt
VICVectAddr = 0;
VICIntSelect = 0;
lpc_init_pll_manual();
//initialize module controller,it is very necessary for stability of system
spi_data_send(0, 0xfb);
spi_data_send(0, 0x56);
// spi_data_send(0, 0xfb); //这只是通过SPI_extend发送数据使module controller使能无效而已,
// spi_data_send(0, 0x56); //但数据并没真正的发送能module controller的使能端
spi_extend_latch(1);
spi_extend_outputen(1); //实现SPI_extend数据的发送
myLCD_init();
touch_init();
jiao_init();
// mylcd_touch_jiao();
all_test();
}
/*******************************************************
*******************************************************/
void draw_picture(INT16U star_x,INT8U star_y,INT16U end_x,INT8U end_y,INT16U piexl_x,INT8U piexl_y)
{
//画框
myposi_piexl_start(star_x,star_y);
myposi_piexl_end(end_x,end_y);
myLCD_line_rectangle(0xfc); //orange
//输入字母
myposi_set(0,0); //确定输出字母的位置 //set display position
myLCD_fore_on(1);
mycolor_set(0x0,0x0);
}
void touch_errer(void)
{
mycls(0xb0);
myposi_set(0,0); //确定输出字母的位置 //set display position
myposi_piexl_start(0,120);
myLCD_fore_on(1);
mycolor_set(0x0,0x0);
myLCD_printf(" please touch one of the button!");
time_dly(500);
}
void void_yc(void)
{
}
/*
POINT getDisplayPoint(POINT touch_data)
{
POINT lcd_pix1;
lcd_pix1.x=touch_data.x+1;
lcd_pix1.y=touch_data.y+1;
return lcd_pix1;
}
*/
// conversion_touch_to_lcd(&touch_xy,&lcd_xy);
// myLCD_printf("(%d,%d) to ( %d ,%d ) ",touch_xy.x,touch_xy.y,lcd_xy.x,lcd_xy.y );
void all_test(void)
{
// INT8U data;
bit_lcd=1;
touch_data.x=0;
touch_data.y=0;
while(1)
{
if(bit_lcd)
{
mycls(0xe0); //clear screen black blue
draw_picture(50,10,270,40,50,17);
myLCD_printf("philips Hello,world!");
draw_picture(50,50,270,80,50,57);
myLCD_printf(" Simple test");
draw_picture(50,90,270,120,50,97);
myLCD_printf(" COM test");
draw_picture(50,130,270,160,50,137);
myLCD_printf(" AD buzzer");
draw_picture(50,170,270,200,50,177);
myLCD_printf(" Motor test");
draw_picture(50,210,270,240,50,217);
myLCD_printf(" jiao zheng");
bit_lcd=0;
}
touch_data=mytouch_get_key();
if(!(touch_data.x==0&&touch_data.y==0))
{
lcd_pix = getDisplayPoint( touch_data );
touch_data.x=0;
touch_data.y=0;
if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 10 && lcd_pix.y <= 40)
case_value=1;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 50 && lcd_pix.y <= 80)
case_value=2;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 90 && lcd_pix.y <= 120)
case_value=3;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 130 && lcd_pix.y <= 160)
case_value=4;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 170 && lcd_pix.y <= 200)
case_value=5;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 210 && lcd_pix.y <= 240)
case_value=6;
else
case_value=7;
switch(case_value)
{
case 1: void_yc();
break;
case 2: simple_test();
break;
case 3: com_test();
break;
case 4: AD_buzzer();
break;
case 5: motor_con();
break;
case 6: mylcd_touch_jiao();
touch_data.x=0;
touch_data.y=0;
break;
case 7: touch_errer();
time_dly(200);
break;
}
bit_lcd=1;
}
}
}
void simple_test(void)
{
// INT8U data;
bit_lcd=1;
while(1)
{
if(bit_lcd)
{
mycls(0xe0); //clear screen black blue
draw_picture(50,10,270,40,50,17);
myLCD_printf(" 1:LED test");
draw_picture(50,50,270,80,50,57);
myLCD_printf(" 2:8LED test");
draw_picture(50,90,270,120,50,97);
myLCD_printf(" 3:SW18/19 test");
draw_picture(50,130,270,160,50,137);
myLCD_printf(" return");
bit_lcd=0;
}
touch_data=mytouch_get_key();
if(!(touch_data.x==0&&touch_data.y==0))
{
lcd_pix=getDisplayPoint( touch_data );
touch_data.x=0;
touch_data.y=0;
if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 10 && lcd_pix.y <= 40)
case_value=1;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 50 && lcd_pix.y <= 80)
case_value=2;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 90 && lcd_pix.y <= 120)
case_value=3;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 130 && lcd_pix.y <= 160)
case_value=4;
else
case_value=6;
switch(case_value)
{
case 1: led_test();
break;
case 2: disp_88_test();
break;
case 3: switch_test();
break;
// case 4: all_test();
// break;
case 6: touch_errer();
time_dly(200);
break;
// time_dly(200);
case 4: bit_lcd=1;
return;
// default :return;
}
bit_lcd=1;
}
}
}
/*******************************************************
*******************************************************/
void com_test(void)
{
// INT8U data;
bit_lcd=1;
while(1)
{
if(bit_lcd)
{
mycls(0xe0); //clear screen black blue
draw_picture(50,10,270,40,50,17);
myLCD_printf(" 1:IIC test");
draw_picture(50,50,270,80,50,57);
myLCD_printf(" 2:uart0 to pc test");
draw_picture(50,90,270,120,50,97);
myLCD_printf(" 3:uart0 to uart1 test");
draw_picture(50,130,270,160,50,137);
myLCD_printf(" ruturn");
bit_lcd=0;
}
touch_data=mytouch_get_key();
if(!(touch_data.x==0&&touch_data.y==0))
{
lcd_pix=getDisplayPoint( touch_data );
touch_data.x=0;
touch_data.y=0;
if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 10 && lcd_pix.y <= 40)
case_value=1;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 50 && lcd_pix.y <= 80)
case_value=2;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 90 && lcd_pix.y <= 120)
case_value=3;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 130 && lcd_pix.y <= 160)
case_value=4;
else
case_value=5;
switch(case_value)
{
case 1: IIC_test();
break;
case 2: uart0_pc();
break;
case 3: uart0_uart1();
break;
case 5: touch_errer();
// time_dly(200);
break;
case 4: bit_lcd=1;
return;
// time_dly(200);
// break;
// default :return;
}
bit_lcd=1;
}
}
}
/*******************************************************
*******************************************************/
void AD_buzzer(void)
{
// INT8U data;
bit_lcd=1;
while(1)
{
if(bit_lcd)
{
mycls(0xe0); //clear screen black blue
draw_picture(50,10,270,40,50,17);
myLCD_printf(" 1:AD test");
draw_picture(50,50,270,80,50,57);
myLCD_printf(" 2:buzzer test");
draw_picture(50,90,270,120,50,97);
myLCD_printf(" ruturn");
bit_lcd=0;
}
touch_data=mytouch_get_key();
if(!(touch_data.x==0&&touch_data.y==0))
{
lcd_pix=getDisplayPoint( touch_data );
touch_data.x=0;
touch_data.y=0;
if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 10 && lcd_pix.y <= 40)
case_value=1;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 50 && lcd_pix.y <= 80)
case_value=2;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 90 && lcd_pix.y <= 120)
case_value=3;
else
case_value=4;
switch(case_value)
{
case 1: AD_test();
break;
case 2: buzzer_test();
break;
case 4: touch_errer();
time_dly(200);
break;
// case 3: all_test();
// break;
case 3: bit_lcd=1;
return;
// default :return;
}
bit_lcd=1;
}
}
}
/*******************************************************
*******************************************************/
void motor_con(void)
{
// INT8U data;
bit_lcd=1;
while(1)
{
if(bit_lcd)
{
mycls(0xe0); //clear screen black blue
draw_picture(50,10,270,40,50,17);
myLCD_printf(" 1:DC motor");
draw_picture(50,50,270,80,50,57);
myLCD_printf(" 2:Step motor");
draw_picture(50,90,270,120,50,97);
myLCD_printf(" ruturn");
bit_lcd=0;
}
touch_data=mytouch_get_key();
if(!(touch_data.x==0&&touch_data.y==0))
{
lcd_pix=getDisplayPoint( touch_data );
touch_data.x=0;
touch_data.y=0;
if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 10 && lcd_pix.y <= 40)
case_value=1;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 50 && lcd_pix.y <= 80)
case_value=2;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 90 && lcd_pix.y <= 120)
case_value=3;
else
case_value=4;
switch(case_value)
{
case 1: motor(0);
break;
case 2: motor(1);
break;
case 4: touch_errer();
time_dly(200);
break;
case 3: bit_lcd=1;
return;
// case 3: all_test();
// break;
// default :return;
// cls(); //clear screen
// LCD_printf("1:DC motor\n");
// LCD_printf("2:Step motor\n");
// LCD_printf("any key to main menu!");
// data=get_key();
// cls(); //clear screen
// switch(data)
// {
// case 1: motor(0);
// break;
// case 2: motor(1);
// break;
// default: return;
// }
}
bit_lcd=1;
}
}
}
/**************************************************
1234567890循环显示
***************************************************/
void disp_88_test(void)
{
// INT8U data;
/*
while(1)
{
*/
mycls(0xe0); //clear screen black blue
draw_picture(50,10,270,40,50,17);
myLCD_printf(" 8LED testing");
e_led_test();
/*
draw_picture(50,50,270,80,50,57);
myLCD_printf(" return");
touch_data=mytouch_get_key();
if(!(touch_data.x==0&&touch_data.y==0))
{
lcd_pix=getDisplayPoint( touch_data );
if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 10 && lcd_pix.y <= 40)
case_value=1;
else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 50 && lcd_pix.y <= 80)
case_value=2;
else
case_value=3;
switch(case_value)
{
case 1: e_led_test();
break;
// case 2: simple_test();
// break;
case 3: touch_errer();
time_dly(200);
break;
case 2: return;
// time_dly(10);
}
*/
display_88_close();
touch_data.x=0;
touch_data.y=0;
// }
// }
}
/*******************************************************
*******************************************************/
void e_led_test(void)
{
INT32U i=0,j;
display_88_init();
while(1)
{
switch(i)
{
case 0: j= 1234567;
break;
case 1: j=12345678;
break;
case 2: j=23456789;
break;
case 3: j=34567890;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -