[原创]
【TI首届低功耗设计大赛】智能手表之U/COSIII实时操作系统移植
添加u/cosIII所需的文件,如下图
建立任务主要代码如下:
#include "app.h"
#include "gui_desktop.h"
#include "sim908.h"
#include
#include "wm.h"
#include "gui_common.h"
#include "rtc.h"
#include "i2c_ee.h"
#include "bsp_sdfatfs_app.h"
extern OS_TCB StartUp_TCB;
static OS_TCB LED_TCB;
static CPU_STK LED_Stk[TASK_LED_STK_SIZE];
static OS_TCB GUI_TCB;
static CPU_STK GUI_Stk[TASK_GUI_STK_SIZE];
static OS_TCB GUI_Touch_TCB;
static CPU_STK GUI_Touch_Stk[TASK_GUI_Touch_STK_SIZE];
//static OS_TCB AT_TCB;
//static CPU_STK AT_Stk[TASK_AT_STK_SIZE];
OS_TCB IntTest_TCB;
static CPU_STK IntTest_Stk[TASK_INTTEST_STK_SIZE];
OS_TCB MessageHandle_TCB;
static CPU_STK MessageHandle_Stk[TASK_MESSAGEHANDLE_STK_SIZE];
OS_TCB PhoneHandle_TCB;
static CPU_STK PhoneHandle_Stk[TASK_PHONEHANDLE_STK_SIZE];
OS_TCB GPRSHandle_TCB;
static CPU_STK GPRSHandle_Stk[TASK_GPRSHANDLE_STK_SIZE];
OS_TCB TimeUpdate_TCB;
static CPU_STK TimeUpdate_Stk[TASK_TIMEUPDATE_STK_SIZE];
OS_TCB SimCheck_TCB;
static CPU_STK SimCheck_Stk[TASK_SIMCHECK_STK_SIZE];
OS_TCB Wireless_TCB;
static CPU_STK Wireless_Stk[TASK_WIRELESS_STK_SIZE];
OS_MEM MyPartition;
u8 MyPartitionStorage[MEMLIST_SIZE][DATA_BUFF_SIZE];
OS_MUTEX Mutex_USART2;
OS_Q Q_GSMResponse;
OS_FLAG_GRP MessageFlagGrp;
OS_FLAG_GRP PhoneFlagGrp;
OS_FLAG_GRP GPRSFlagGrp;
OS_TMR MyTmr1;
/*
* 函数名:Task_Start
* 描述 : 启动任务,
* 优先级为1,
* 初始化及创建其它任务
* 输入 :无
* 输出 : 无
*/
void Task_Start(void *p_arg)
{
OS_ERR err;
(void)p_arg;
/* 板级初始化 */
BSP_Init();
//创建任务LED
/*
OSTaskCreate((OS_TCB *)&LED_TCB, // 任务控制块指针
(CPU_CHAR *)"LED", // 任务名称
(OS_TASK_PTR )Task_LED, // 任务代码指针
(void *)0, // 传递给任务的参数parg
(OS_PRIO )TASK_LED_PRIO, // 任务优先级
(CPU_STK *)&LED_Stk[0], // 任务堆栈基地址
(CPU_STK_SIZE)TASK_LED_STK_SIZE/10, // 堆栈剩余警戒线
(CPU_STK_SIZE)TASK_LED_STK_SIZE, // 堆栈大小
(OS_MSG_QTY )0, // 可接收的最大消息队列数
(OS_TICK )0, // 时间片轮转时间
(void *)0, // 任务控制块扩展信息
(OS_OPT )(OS_OPT_TASK_STK_CHK |
OS_OPT_TASK_STK_CLR), // 任务选项
(OS_ERR *)&err); // 返回值
*/
OSTaskCreate( (OS_TCB *)&IntTest_TCB, //任务控制块指针
(CPU_CHAR *)"inttest", //任务名
(OS_TASK_PTR )Task_IntTest, //任务代码指针
(void *)0, //传递给任务的参数
(OS_PRIO )TASK_INTTEST_PRIO, //任务优先级
(CPU_STK *)&IntTest_Stk[0], //任务堆栈基地址
(CPU_STK_SIZE)TASK_INTTEST_STK_SIZE/10, //堆栈警戒线
(CPU_STK_SIZE)TASK_INTTEST_STK_SIZE, //堆栈大小
(OS_MSG_QTY )10, //可接收的最大消息队列数
(OS_TICK )0, //时间片轮转时间
(void *)0, //任务控制块扩展信息
(OS_OPT )(OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR), //任务选项
(OS_ERR *)&err ); //返回值
OSTaskCreate( (OS_TCB *)&MessageHandle_TCB, //任务控制块指针
(CPU_CHAR *)"MessageHandle", //任务名
(OS_TASK_PTR )Task_MessageHandle, //任务代码指针
(void *)0, //传递给任务的参数
(OS_PRIO )TASK_MESSAGEHANDLE_PRIO, //任务优先级
(CPU_STK *)&MessageHandle_Stk[0], //任务堆栈基地址
(CPU_STK_SIZE)TASK_MESSAGEHANDLE_STK_SIZE/10, //堆栈警戒线
(CPU_STK_SIZE)TASK_MESSAGEHANDLE_STK_SIZE, //堆栈大小
(OS_MSG_QTY )0, //可接收的最大消息队列数
(OS_TICK )0, //时间片轮转时间
(void *)0, //任务控制块扩展信息
(OS_OPT )(OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR), //任务选项
(OS_ERR *)&err ); //返回值
/*
OSTaskCreate( (OS_TCB *)&PhoneHandle_TCB, //任务控制块指针
(CPU_CHAR *)"PhoneHandle", //任务名
(OS_TASK_PTR )Task_PhoneHandle, //任务代码指针
(void *)0, //传递给任务的参数
(OS_PRIO )TASK_PHONEHANDLE_PRIO, //任务优先级
(CPU_STK *)&PhoneHandle_Stk[0], //任务堆栈基地址
(CPU_STK_SIZE)TASK_PHONEHANDLE_STK_SIZE/10, //堆栈警戒线
(CPU_STK_SIZE)TASK_PHONEHANDLE_STK_SIZE, //堆栈大小
(OS_MSG_QTY )0, //可接收的最大消息队列数
(OS_TICK )0, //时间片轮转时间
(void *)0, //任务控制块扩展信息
(OS_OPT )(OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR), //任务选项
(OS_ERR *)&err ); //返回值
*/
OSTaskCreate( (OS_TCB *)&GPRSHandle_TCB, //任务控制块指针
(CPU_CHAR *)"GPRSHandle", //任务名
(OS_TASK_PTR )Task_GPRSHandle, //任务代码指针
(void *)0, //传递给任务的参数
(OS_PRIO )TASK_GPRSHANDLE_PRIO, //任务优先级
(CPU_STK *)&GPRSHandle_Stk[0], //任务堆栈基地址
(CPU_STK_SIZE)TASK_GPRSHANDLE_STK_SIZE/10, //堆栈警戒线
(CPU_STK_SIZE)TASK_GPRSHANDLE_STK_SIZE, //堆栈大小
(OS_MSG_QTY )0, //可接收的最大消息队列数
(OS_TICK )0, //时间片轮转时间
(void *)0, //任务控制块扩展信息
(OS_OPT )(OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR), //任务选项
(OS_ERR *)&err ); //返回值
//创建任务GUI
OSTaskCreate((OS_TCB *)&GUI_TCB,
(CPU_CHAR *)"GUI",
(OS_TASK_PTR )Task_GUI,
(void *)0,
(OS_PRIO )TASK_GUI_PRIO,
(CPU_STK *)&GUI_Stk[0],
(CPU_STK_SIZE)TASK_GUI_STK_SIZE/10,
(CPU_STK_SIZE)TASK_GUI_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
//创建任务GUI_Touch
OSTaskCreate((OS_TCB *)&GUI_Touch_TCB,
(CPU_CHAR *)"GUI_Touch",
(OS_TASK_PTR )Task_GUI_Touch,
(void *)0,
(OS_PRIO )TASK_GUI_TOUCH_PRIO,
(CPU_STK *)&GUI_Touch_Stk[0],
(CPU_STK_SIZE)TASK_GUI_Touch_STK_SIZE/10,
(CPU_STK_SIZE)TASK_GUI_Touch_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
/*
OSTaskCreate((OS_TCB *)&TimeUpdate_TCB,
(CPU_CHAR *)"TimeUpdate",
(OS_TASK_PTR )Task_TimeUpdate,
(void *)0,
(OS_PRIO )TASK_TIMEUPDATE_PRIO,
(CPU_STK *)&TimeUpdate_Stk[0],
(CPU_STK_SIZE)TASK_TIMEUPDATE_STK_SIZE/10,
(CPU_STK_SIZE)TASK_TIMEUPDATE_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
*/
OSTaskCreate((OS_TCB *)&SimCheck_TCB,
(CPU_CHAR *)"SimCheck",
(OS_TASK_PTR )Task_SimCheck,
(void *)0,
(OS_PRIO )TASK_SIMCHECK_PRIO,
(CPU_STK *)&SimCheck_Stk[0],
(CPU_STK_SIZE)TASK_SIMCHECK_STK_SIZE/10,
(CPU_STK_SIZE)TASK_SIMCHECK_STK_SIZE,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
OSTaskCreate((OS_TCB *)&Wireless_TCB,
(CPU_CHAR *)"Wireless",
(OS_TASK_PTR )Task_Wireless,
(void *)0,
(OS_PRIO )TASK_WIRELESS_PRIO,
(CPU_STK *)&Wireless_Stk[0],
(CPU_STK_SIZE)TASK_WIRELESS_STK_SIZE/10,
(CPU_STK_SIZE)TASK_WIRELESS_STK_SIZE,
(OS_MSG_QTY )4,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
//创建定时器任务
OSTmrCreate((OS_TMR *)&MyTmr1,
(CPU_CHAR *)"My Timer #1",
(OS_TICK )10,
(OS_TICK )50,
(OS_OPT )OS_OPT_TMR_PERIODIC,
(OS_TMR_CALLBACK_PTR )TmrCallback_RTCUpdate,
(void *)NULL,
(OS_ERR *)&err);
OSTmrStart((OS_TMR *)&MyTmr1, (OS_ERR *)&err);
//任务删除自己
OSTaskDel(&StartUp_TCB,&err);
}
/*
* 函数名:Task_LED
* 描述 : LED任务1,
* 优先级为4,
* 以200ms的间隔点亮、关闭LED
* 输入 :无
* 输出 : 无
*/
void Task_LED(void *p_arg)
{
OS_ERR err;
(void)p_arg;
while (1)
{
LED1( ON );
OSTimeDlyHMSM(0, 0,1,0,OS_OPT_TIME_HMSM_STRICT,&err);
LED1( OFF);
OSTimeDlyHMSM(0, 0,1,0,OS_OPT_TIME_HMSM_STRICT,&err);
}
}
/*
* 函数名:Task_GUI
* 描述 : GUI任务,
* 优先级为6,
* 显示GUI操作
* 输入 :任务输入参数
* 输出 : 无
*/
void Task_GUI(void *p_arg)
{
// OS_ERR err;
(void)p_arg;
GUI_CreatDeskTop();
//延时
while(1)
{
GUI_Delay( 300 );
//OSTimeDlyHMSM( 0, 0, 0, 200, OS_OPT_TIME_HMSM_STRICT, &err);
}
}
/**
* @brief Task_GUI_Touch 每10ms执行一次,GUI触屏触发函数
* @param p_arg
* @retval 无
*/
void Task_GUI_Touch(void *p_arg)
{
OS_ERR err;
(void)p_arg;
while(1)
{
GUI_TOUCH_Exec(); //10ms一次GUI调用处理触屏
OSTimeDly(10,OS_OPT_TIME_DLY,&err);
}
}
void Task_IntTest(void *p_arg)
{
OS_ERR err;
CPU_TS ts;
u8 flag = 0;
u8 *pdata = NULL;
char *p = NULL;
OS_MSG_SIZE Mes_size;
p_arg = p_arg;
while( 1 )
{
pdata = (u8 *)OSTaskQPend(0, OS_OPT_PEND_BLOCKING, &Mes_size, &ts, &err);
// USART_printf(USART1, "\r\n $%s$ \r\n", pdata);
if(GSM_Response[0] != 0)
{
p = strstr((char *)pdata, (char *)&GSM_Response[0]);
if(p != NULL)
{
GSM_Response[0] = 0; //相当于标志位
OSQPost(&Q_GSMResponse, pdata, 1, OS_OPT_POST_FIFO, &err);
flag = 1;
}
else
{
flag = 0;
}
}
if(flag == 0)
{
if(NULL != strstr((char *)pdata, "+CMTI"))
{
u8 mesaddr[3];
mesaddr[0] = *(strstr((char *)pdata, ",")+1);
mesaddr[1] = *(strstr((char *)pdata, ",")+2);
if( mesaddr[1] >= '0' && mesaddr[1] <= '9')
{
Messagenum = (mesaddr[0] - '0')*10 + (mesaddr[1] - '0');
}
else
{
Messagenum = (mesaddr[0] - '0');
}
Messagebuff[Messagenum-1] = 1;
OSMemPut((OS_MEM *)&MyPartition, (void *)pdata, (OS_ERR *)&err);
OSFlagPost(&MessageFlagGrp, FlagNewMessage, (OS_OPT)OS_OPT_POST_FLAG_SET, &err);
}
else if(NULL != strstr((char *)pdata, "+CLIP:")) //来电
{
u8 *p1 = NULL;
u8 *p2 = NULL;
p1 = (u8 *)strstr((char *)pdata, "\"");
p2 = (u8 *)strstr((char *)(p1+1), "\"");
p2[0] = '\0';
strcpy(RingNumber, p1+1);
if(!WM_IsWindow(WinPara.hRing))//判断当前激活的窗口
{
WM_SendMessageNoPara(WinPara.hWinMain, MY_MESSAGE_RING);
}
OSMemPut((OS_MEM *)&MyPartition, (void *)pdata, (OS_ERR *)&err);
}
else if(NULL != strstr((char *)pdata, "CLOSE")) //网络断开连接
{
OSFlagPost(&GPRSFlagGrp, FlagGPRSConnect, OS_OPT_POST_FLAG_CLR, &err);
OSMemPut((OS_MEM *)&MyPartition, (void *)pdata, (OS_ERR *)&err);
}
else if(NULL != strstr((char *)pdata, "NO PIALTONE")) //无拨号音
{
WM_DeleteWindow(WinPara.hCalling);
WM_DeleteWindow(WinPara.hRing);
WM_DeleteWindow(WinPara.hPhone);
//GUI_MessageBox("\r\n NO PIALTONE! \r\n","error",GUI_MESSAGEBOX_CF_MOVEABLE);
OSMemPut((OS_MEM *)&MyPartition, (void *)pdata, (OS_ERR *)&err);
}
else if(NULL != strstr((char *)pdata, "BUSY")) //占线
{
WM_DeleteWindow(WinPara.hCalling);
WM_DeleteWindow(WinPara.hRing);
WM_DeleteWindow(WinPara.hPhone);
//GUI_MessageBox("\r\n BUSY! \r\n","error",GUI_MESSAGEBOX_CF_MOVEABLE);
OSMemPut((OS_MEM *)&MyPartition, (void *)pdata, (OS_ERR *)&err);
}
else if(NULL != strstr((char *)pdata, "NO CARRIER")) //无法连接
{
WM_DeleteWindow(WinPara.hCalling);
WM_DeleteWindow(WinPara.hRing);
WM_DeleteWindow(WinPara.hPhone);
//GUI_MessageBox("\r\n NO CARRIER! \r\n","error",GUI_MESSAGEBOX_CF_MOVEABLE);
OSMemPut((OS_MEM *)&MyPartition, (void *)pdata, (OS_ERR *)&err);
}
else if(NULL != strstr((char *)pdata, "NO ANSWER")) //无应答
{
WM_DeleteWindow(WinPara.hCalling);
WM_DeleteWindow(WinPara.hRing);
WM_DeleteWindow(WinPara.hPhone);
//GUI_MessageBox("\r\n NO ANSWER! \r\n","error",GUI_MESSAGEBOX_CF_MOVEABLE);
OSMemPut((OS_MEM *)&MyPartition, (void *)pdata, (OS_ERR *)&err);
}
else if(NULL != strstr((char *)pdata, "NORMAL POWER DOWN")) //无应答
{
Sim908_Reset(); //掉电后复位
OSMemPut((OS_MEM *)&MyPartition, (void *)pdata, (OS_ERR *)&err);
}
else //其他未用响应
{
OSMemPut((OS_MEM *)&MyPartition, (void *)pdata, (OS_ERR *)&err);
}
}
flag = 0;
}
}
/*
描述:短信处理任务
*/
void Task_MessageHandle(void *p_arg)
{
u8 i;
OS_ERR err;
CPU_TS ts;
OS_FLAGS Flags_Rdy;
while( 1 )
{
OSFlagPend(&MessageFlagGrp,
FlagMessageFull + FlagNewMessage,
(OS_TICK)0,
(OS_OPT)(OS_OPT_PEND_FLAG_SET_ANY + OS_OPT_PEND_FLAG_CONSUME),
&ts,
&err);
Flags_Rdy = OSFlagPendGetFlagsRdy( &err );
if(Flags_Rdy & FlagNewMessage) //有新短信
{
for(i=0; i<50; i++)
{
if(Messagebuff == MESSAGE_UNREAD)
{
if(SIM_ERR_NONE == Sim908_ReadMessage(i+1, MESSAGE_ENGLISH))
{
Messagebuff = MESSAGE_CMD;
//I2C_EE_BufferWrite(Messagebuff, MESSAGE_FLASH_ADDR, sizeof(Messagebuff));
}
else
{
u8 databuff[300];
Messagebuff = MESSAGE_NOTCMD;
myres = f_open(&myfsrc, "0:/messages.txt", FA_WRITE | FA_OPEN_EXISTING);
myres = f_lseek(&myfsrc, myfsrc.fsize);
sprintf(databuff, "20%s\r\n", MES_STR.Time);
myres = f_write(&myfsrc, databuff, strlen(databuff), &mybw);
//USART_printf(USART1, "\r\n %s \r\n", databuff);
sprintf(databuff, "%s\r\n", MES_STR.Phonenum);
myres = f_write(&myfsrc, databuff, strlen(databuff), &mybw);
//USART_printf(USART1, "\r\n %s \r\n", databuff);
sprintf(databuff, "%s\r\n", MES_STR.Message);
myres = f_write(&myfsrc, databuff, strlen(databuff), &mybw);
//USART_printf(USART1, "\r\n %s \r\n", databuff);
f_close(&myfsrc);
//I2C_EE_BufferWrite(Messagebuff, MESSAGE_FLASH_ADDR, sizeof(Messagebuff));
}
if(i > 40 )
{
Sim908_SendCmd("AT+CMGDA=\"DEL INBOX\"", "OK", 100, NULL); //删除全部接收的短信
}
}
}
}
}
}
/*
描述:电话处理函数
*/
void Task_PhoneHandle(void *p_arg)
{
// OS_ERR err;
// CPU_TS ts;
while( 1 )
{
}
}
/*
描述:GPRS处理任务
*/
void Task_GPRSHandle(void *p_arg)
{
OS_ERR err;
CPU_TS ts;
OS_FLAGS Flags_Rdy;
u8 gpsdatabuff[100];
p_arg = p_arg;
OSTimeDlyHMSM( 0, 0, 13, 0, OS_OPT_TIME_HMSM_STRICT, &err);
//Sim908_TCPClose();
//Sim908_TCPConnect("175.6.4.74", "40487");
while( 1 )
{
OSFlagPend(&GPRSFlagGrp,
FlagGPRSConnect,
(OS_TICK)0,
(OS_OPT)OS_OPT_PEND_FLAG_SET_ANY,
&ts,
&err);
Flags_Rdy = OSFlagPendGetFlagsRdy( &err );
if(Flags_Rdy & FlagGPRSConnect)
{
if(SIM_ERR_NONE == Sim908_GetGPSInformation(&GPS_STR, gpsdatabuff))
{
Sim908_TCPSendData(gpsdatabuff);
}
else
{
Sim908_TCPSendData("还没成功获取GPS数据,请稍候");
}
//Sim908_TCPSendData("AT+CGPSINF=32 32,063824.000,A,2256.040527,N,11203.090490,E,0.00,0.00,040914,,E,A OK");
}
OSTimeDlyHMSM( 0, 0, 2, 0, OS_OPT_TIME_HMSM_STRICT, &err);
}
}
/*
描述:定时器1的回掉函数
*/
void TmrCallback_RTCUpdate(void *p_arg)
{
// OS_ERR err;
p_arg = p_arg;
if(WM_IsWindow(WinPara.hWinMain))//判断当前激活的窗口
WM_SendMessageNoPara(WinPara.hWinMain, MY_MESSAGE_RTC);//向主窗口发送时间更新消息
if(WM_IsWindow(WinPara.hBkWheel))
WM_SendMessageNoPara(WinPara.hBkWheel,MY_MESSAGE_RTC);//向调节时间窗口发送更新消息
}
/*
描述:GPS校时任务
*/
void Task_TimeUpdate(void *p_arg)
{
OS_ERR err;
while( 1 )
{
if(SIM_ERR_NONE == Sim908_GetGPSInformation(&GPS_STR, NULL))
{
//USART_printf(USART1, "\r\n TimeAdjust \r\n");
RTC_Config();
Sim908_TimeAdjust(&TIME_CALENDAR);
OSTimeDlyHMSM( 12, 0, 0, 0, OS_OPT_TIME_HMSM_STRICT, &err); //延时12个小时
}
else
{
//USART_printf(USART1, "\r\n GPS not ready \r\n");
OSTimeDlyHMSM( 0, 0, 30, 0, OS_OPT_TIME_HMSM_STRICT, &err); //延时30秒
}
}
}
/*
函数名:Task_SimCheck
描述: 检查sim卡的相关状态
*/
void Task_SimCheck(void *p_arg)
{
u32 i = 0;
u8 *p1 = NULL;
u8 *p2 = NULL;
u8 databuff[20];
OS_ERR err;
Sim908_Reset();
OSTimeDlyHMSM( 0, 0, 10, 0, OS_OPT_TIME_HMSM_STRICT, &err);
Sim908_GPSSet( 1 );
Sim908_SendCmd("AT", "OK", 50, NULL);
OSTimeDlyHMSM( 0, 0, 0, 10, OS_OPT_TIME_HMSM_STRICT, &err);
Sim908_SendCmd("ATE0", "OK", 50, NULL); //关闭回显
OSTimeDlyHMSM( 0, 0, 0, 10, OS_OPT_TIME_HMSM_STRICT, &err);
Sim908_SendCmd("AT+COLP=1", "OK", 50, NULL); //开启被叫号码显示
OSTimeDlyHMSM( 0, 0, 0, 10, OS_OPT_TIME_HMSM_STRICT, &err);
Sim908_SendCmd("AT+CLIP=1", "OK", 50, NULL); //开启来电显示
OSTimeDlyHMSM( 0, 0, 0, 10, OS_OPT_TIME_HMSM_STRICT, &err);
//Sim908_ReadMessage(5, MESSAGE_ENGLISH);
while( 1 )
{
//USART_printf(USART1, "\r\n breath \r\n");
if(i % 1 == 0)
{
if(SIM_ERR_NONE == Sim908_SendCmd("AT+COPS?", "+COPS:", 50, databuff)) //检查信号
{
if(strstr(databuff, "CHINA MOBILE"))
{
Sim_Operator = 1; //标志运营商为中国移动
WM_SendMessageNoPara(WinPara.hWinStatus, MY_MESSAGE_OPERATOR);
if(SIM_ERR_NONE == Sim908_SendCmd("AT+CSQ", "+CSQ", 50, databuff))
{
p1 = strstr((char *)databuff, ":");
p2 = strstr((char *)p1, ",");
p2[0] = '\0';
strcpy(Sim_RSSI, p1+2);
WM_SendMessageNoPara(WinPara.hWinStatus, MY_MESSAGE_RSSI);
}
}
else
{
Sim_Operator = 0;
WM_SendMessageNoPara(WinPara.hWinStatus, MY_MESSAGE_OPERATOR);
}
}
}
if( i % 1 == 0)
{
if(SIM_ERR_NONE == Sim908_GetGPSInformation(&GPS_STR, NULL))
{
Sim908_GPSConvert(GPS_STR.Latitude, GPS_STR.Longtude, LOCATION);
WM_SendMessageNoPara(WinPara.hWinMain, MY_MESSAGE_GPS);
}
else
{
strcpy(LOCATION, "NO GPS INFORMATION");
WM_SendMessageNoPara(WinPara.hWinMain, MY_MESSAGE_GPS);
}
}
if(i % 6 == 0)
{
if(SIM_ERR_NONE == Sim908_SendCmd("AT+CBC", "+CBC", 50, databuff)) //检查电量
{
p1 = strstr((char *)databuff, ",");
p2 = strstr((char *)p1+1, ",");
p2[0] = '\0';
strcpy(Sim_Battery, p1+1);
WM_SendMessageNoPara(WinPara.hWinStatus, MY_MESSAGE_BAT);
}
}
i++;
if(i >= 1000)
{
i = 0;
}
OSTimeDlyHMSM( 0, 0, 10, 0, OS_OPT_TIME_HMSM_STRICT, &err);
}
}
/*
无线处理任务
*/
void Task_Wireless( void *p_arg )
{
OS_ERR err;
u8 *pdata = NULL;
OS_MSG_SIZE Mes_size;
CPU_TS ts;
while( 1 )
{
pdata = (u8 *)OSTaskQPend(0, OS_OPT_PEND_BLOCKING, &Mes_size, &ts, &err);
if(NULL != pdata)
{
//USART_printf(USART1, "\r\n 接收到 %s \r\n", WirelessBuff);
}
}
}
/****************End of file****************/
-
操作系统占用多少系统资源啊?
RAM和Flash?
理论上2k Ram就够了,不过,想跑应用,还是得大些。很好奇撸主怎么分配的。