///*****************事件定义*****************///
OS_EVENT *Nand_Rw_Sem; //Nand_Flash读写控制权旗语
//and you can use it as folloeing:
// Nand_Rw_Sem=OSSemCreate(1); //创建Nand-Flash读写控制权旗语,初值为1满足互斥条件//
// OSSemPend(Nand_Rw_Sem,0,&err);
// OSSemPost(Nand_Rw_Sem);
OS_EVENT *Uart_Rw_Sem; //Uart读写控制权旗语
//and you can use it as folloeing:
// Uart_Rw_Sem=OSSemCreate(1); //创建Uart读写控制权旗语,初值为1满足互斥条件//
// OSSemPend(Uart_Rw_Sem,0,&err);
// OSSemPost(Uart_Rw_Sem);
//////////////////////////////////////////////////////////
INT8U err;
char didian [6][12]={"","nan chang"," bei jing ","shang hai"," guang zhou"," ji nan "};
int jiage[6][6]={0,0,0,0,0,0,
0,0,200,300,400,500,
0,200,0,600,700,800,
0,300,600,0,50,450,
0,400,700,50,0,500,
0,500,800,450,500,0};
int sumpiao[6][6]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int mykey=-1;
void jiemian(){
int i=0;
for( i=1;i<6;i++){
Uart_Printf("---%s",didian);
}
Uart_Printf("\n");
Uart_Printf("xuan ze cao zuo\n");
Uart_Printf("1 mai piao\n");
Uart_Printf("2 cha chun che ci\n");
Uart_Printf("3 tong ji jin tian liu liang \n");
Uart_Printf("0 tui chu \n");
Delay(2000);
}
void choose(int mykey){
switch(mykey){
case 1:Uart_Printf(" mai piao\n");
buyticket();
break;
case 2:Uart_Printf ("cha xun che ci\n");
search();
break;
case 3: Uart_Printf("tong ji jin tian liu liang \n");
count();
break;
}
}
void search(void){
int begin=0,end=0;
Uart_Printf("chu fa di \n");
Delay(300);
begin=mykey;
Uart_Printf("%d---%s\n",begin,didian[begin]);
Uart_Printf("mu di di \n");
end=mykey;
Uart_Printf("%d---%s\n",end,didian[end]);
if(begin==end){
Uart_Printf("chu fa di he mu di di xiang tong cuo wu \n");
Uart_Printf("chu fa di \n");
begin=mykey;
Uart_Printf("mu di di \n");
end=mykey;
}
if(jiage[begin][end]!=0){
Uart_Printf("you che ci, che piao jia qian %d\n",jiage[begin][end]);
}
}
void count(void){
int i=0,j=0;
int x=0;
for(i=1;i<6;i++){
x=0;
for( j=1;j<6;j++){
x=sumpiao[j]+x;
}
Uart_Printf("jin tian dao %s de you %d ren\n",didian,x);
}
}
void buyticket(){
int begin=0,end=0,num=0;
Uart_Printf("chu fa di \n");
begin=mykey;
Uart_Printf("mu di di \n");
end=mykey;
if(begin==end){
Uart_Printf("chu fa di he mu di di xiang tong cuo wu \n");
Uart_Printf("chu fa di \n");
begin=mykey;
Uart_Printf("mu di di \n");
end=mykey;
}
Uart_Printf("mai de piao shu \n");
num=mykey;
if(jiage[begin][end]!=0){
Uart_Printf("jia qian %d\n",jiage[begin][end]);
sumpiao[begin][end]=sumpiao[begin][end]+num;
Uart_Printf("chu fa di %s mu di di %s piaoshu %d money %d\n",didian[begin],didian[end],num,num*jiage[begin][end]);
}
}
int main(void)
{
ARMTargetInit(); //开发板初始化
OSInit(); //操作系统初始化
uHALr_ResetMMU();//复位MMU
LCD_Init(); //初始化LCD模块
LCD_printf("LCD initialization is OK\n");//向液晶屏输出数据
LCD_printf("320 x 240 Text Mode\n");
initOSGUI();//初始化图形界面
LoadFont();//调Unicode字库
LoadConfigSys();//使用config.sys文件配置系统设置
LCD_printf("Create task on uCOS-II...\n");
OSTaskCreate(Main_Task, (void *)0, (OS_STK *)&Main_Stack[STACKSIZE*8-1], Main_Task_Prio);// 创建系统任务
////////////////////////////////////////////////////
OSTaskCreate( Serial_Receive_Task, (void *)0, (OS_STK *)&Serial_Receive_Stack[STACKSIZE*8-1], Serial_Receive_Task_Prio );// 创建串口任务