📄 main.c
字号:
/***************************************************************************\
Copyright (c) 2004-2007 threewater@up-tech.com, All rights reserved.
by threewter 2004.5.12
\***************************************************************************/
/***************************************************************************\
#说明: C main 函数,ucos-ii初始化等定义
---------------------------------- Bug --------------------------------------
---------------------------------- TODO list --------------------------------------
----------------------------------修正--------------------------------------
2004-5-12 创建
\***************************************************************************/
#include"../ucos-ii/includes.h" /* uC/OS interface */
#include "../ucos-ii/add/osaddition.h"
#include "../inc/drivers.h"
#include "../inc/sys/lib.h"
#include "../src/gui/gui.h"
#include <string.h>
#include <stdio.h>
#include "uhal/uhal.h"
#pragma import(__use_no_semihosting_swi) // ensure no functions that use semihosting
//#define RdURXH2() (*(volatile unsigned char *)0x50008024)
#define WrUTXH2(ch) (*(volatile unsigned char *)0x50008020)=(unsigned char)(ch)
#define WrUTXH0(ch) (*(volatile unsigned char *)0x50000020)=(unsigned char)(ch)
//#define RdUTRSTAT2() (*(volatile unsigned char *)0x50008010)
//#define OSULCON2 (*(volatile unsigned char *)0x50008000)
//#define OSUCON2 (*(volatile unsigned char *)0x50008004)
//#define OSUFCON2 (*(volatile unsigned char *)0x50008008)
//#define OSUMCON2 (*(volatile unsigned char *)0x5000800c)
//#define OSUBRDIV2 (*(volatile unsigned int *)0x50008028)
extern void TchScr_init(void);
extern void irq_TCHSCR(void);
extern void LCD_Init(void);
extern void draw_keyboard(void);
extern void clearscreen(void);
U32 TchScr_GetOSXY(int *x, int *y,int lable);
void getkey(int x,int y);
char dialing( char *phonenum);
OS_STK task1_Stack[STACKSIZE]={0, }; //Main_Test_Task堆栈
void Task1(void *Id); //Main_Test_Task
#define Task1_Prio 12
OS_STK Gprs_Task_Stack[STACKSIZE]={0, }; //Gprs_Task堆栈
void Gprs_Task(void *Id); //Gprs_Task
#define Gprs_Task_Prio 20
//U8 c;
OS_EVENT *dialmessage;
extern OS_EVENT *pevent;
char phonenum[100];
char *call;
char *hold;
char *sendmsg0;
char *sendmsg1;
char *text,ctl;
int i=0;
int x,y;
char function;
/////////////////////////////////////////////////////
// Main function. //
////////////////////////////////////////////////////
int main(void)
{
ctl=26; //结束符
text="hello!";
call="atd";
hold="ath\r";
sendmsg0="at+cmgf=1\r";
sendmsg1="at+cmgs="; //
ARMTargetInit(); // do target (uHAL based ARM system) initialisation //
OSInit(); //needed by uC/OS-II //
LCD_Init();
LCD_Refresh();
clearscreen();
TchScr_init1(); //初始化触摸屏,此时为非中断方式。
//TchScr_Clibrate(); //校准触摸屏,取得LCD四个角上的电压值,然后求得电压值的平均最大最小值。
draw_keyboard();
OSTaskCreate(Task1, (void *)0, (OS_STK *)&task1_Stack[STACKSIZE-1],Task1_Prio);
OSTaskCreate(Gprs_Task, (void *)0, (OS_STK *)&Gprs_Task_Stack[STACKSIZE-1],Gprs_Task_Prio);
pevent=OSMboxCreate((void*)NULL);
dialmessage=OSMboxCreate((void*)NULL);
OSAddTask_Init(1);
OSStart(); // start the OS //
return 0;
}//main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Task1(void *Id)
{
U16 timeout=0;
U8 err;
U32 mode;
TchScr_init(); //初始化触摸屏,以中断方式开始工作。
for(;;){
OSMboxPend(pevent,timeout,&err); //等到触摸屏中断
mode=TchScr_GetOSXY(&x, &y,1); //进行坐标转换,取得在LCD坐标值。
// printf("x=%d,\ty=%d\n",x,y);
getkey(x,y);
function=getphonenum(x,y); //操作选择
dialing(phonenum);
if(function=='C'||function=='H'||function=='S')
{
OSMboxPost(dialmessage, (void *)0);
}
if(function=='F') //cancel
{
i--;
// for (j=0;j<i;j++)
//WrUTXH0(phonenum[j]);
DelChar(phonenum[i]);
phonenum[i]='\0';
//WrUTXH0('\r');
//WrUTXH0('\n');
//for (j=0;j<i;j++)
// WrUTXH0(phonenum[j]);
}
OSTimeDly(100);
}
}
void Gprs_Task(void *Id)
{
INT32U *c1;
U8 err;
U16 timeout=0;
OSInitUart();
InitUart();
Uart_SendString(2,"ate1\r"); //echo
/*hudelay(800);
Uart_SendString(2,"at+chfa=1\r");
hudelay(10000);
Uart_SendString(2,"at+clvl=100\r");
hudelay(10000);
Uart_SendString(2,"at+cmic=1,10\r");*/
hudelay(100);
while(1)
{
OSMboxPend(dialmessage, timeout,&err);
if(function=='H')
{
//添加代码
while(i>0)
phonenum[--i]='\0';
//phonenum[0]='\0';
}
else if(function=='C' )
{
//添加代码
while(i>0)
phonenum[--i]='\0';
//phonenum[0]='\0';
//i=0;
}
else if(function=='S')
{
//添加代码
while(i>0)
phonenum[--i]='\0';
//phonenum[0]='\0';
}
OSTimeDly(100);
}
}
char dialing( char phonenum[])
{
char c0;
c0=getphonenum(x,y);
if(c0!='S'&c0!='H'&c0!='C'&c0!='F')
{
phonenum[i]=c0;
i++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -