📄 user.c
字号:
/****************************************Copyright (c)**************************************************
** Modified date:
** Version:
** Descriptions:
**
*********************************************************************************************************/
#include "config.h"
#define TASK0_ID 15 /* 任务0的ID */
#define TASK0_PRIO TASK0_ID /* 任务0的优先级 */
#define TASK0_STACK_SIZE 512 /* 定义任务0堆栈长度 */
#define TASK1_ID 16 /* 任务1的ID */
#define TASK1_PRIO TASK1_ID /* 任务1的优先级 */
#define TASK1_STACK_SIZE 512*5 /* 定义任务1堆栈长度 */
#define TASK2_ID 17 /* 任务1的ID */
#define TASK2_PRIO TASK2_ID /* 任务1的优先级 */
#define TASK2_STACK_SIZE 512*4 /* 定义任务1堆栈长度 */
#define TASK3_ID 18 /* 任务1的ID */
#define TASK3_PRIO TASK3_ID /* 任务1的优先级 */
#define TASK3_STACK_SIZE 300 /* 定义任务1堆栈长度 */
#define TASK4_ID 19 /* 任务1的ID */
#define TASK4_PRIO TASK4_ID /* 任务1的优先级 */
#define TASK4_STACK_SIZE 512*2 /* 定义任务1堆栈长度 */
//#define TASK5_ID 20 /* 任务1的ID */
//#define TASK5_PRIO TASK5_ID /* 任务1的优先级 */
//#define TASK5_STACK_SIZE 512/2 /* 定义任务1堆栈长度 */
OS_STK TASK0_STACK[TASK0_STACK_SIZE]; /* 建立任务0堆栈 */
OS_STK TASK1_STACK[TASK1_STACK_SIZE]; /* 建立任务1堆栈 */
OS_STK TASK2_STACK[TASK2_STACK_SIZE]; /* 建立任务1堆栈 */
OS_STK TASK3_STACK[TASK3_STACK_SIZE]; /* 建立任务1堆栈 */
OS_STK TASK4_STACK[TASK4_STACK_SIZE]; /* 建立任务1堆栈 */
//OS_STK TASK5_STACK[TASK5_STACK_SIZE]; /* 建立任务1堆栈 */
void TASK0 (void *pdata); /* 声明任务0 */
void TASK1 (void *pdata); /* 声明任务1 */
void TASK2 (void *pdata); /* 声明任务2 */
void TASK3 (void *pdata); /* 声明任务3 */
void TASK4 (void *pdata); /* 声明任务4 */
//void TASK5 (void *pdata); /* 声明任务4 */
#if defined(SYSTEM_SEMCONTROL)
OS_EVENT *gw_pSysRsrcSem = 0;
OS_EVENT *gw_pSysFlashSem = 0;
#endif //end of #if defined(SYSTEM_SEMCONTROL)
// Chad add
unsigned short gw_SystemInitReady = 0;
void UserTask (void )
{
OSTaskCreateExt (TASK0,
(void *)0,
&TASK0_STACK[TASK0_STACK_SIZE-1],
TASK0_PRIO,
TASK0_ID,
&TASK0_STACK[0],
TASK0_STACK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
OSTaskCreateExt (TASK1,
(void *)0,
&TASK1_STACK[TASK1_STACK_SIZE-1],
TASK1_PRIO,
TASK1_ID,
&TASK1_STACK[0],
TASK1_STACK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
OSTaskCreate (TASK2,
(void *)0,
&TASK2_STACK[TASK2_STACK_SIZE-1],
TASK2_PRIO);
OSTaskCreate (TASK3,
(void *)0,
&TASK3_STACK[TASK3_STACK_SIZE-1],
TASK3_PRIO);
OSTaskCreate (TASK4,
(void *)0,
&TASK4_STACK[TASK4_STACK_SIZE-1],
TASK4_PRIO);
// OSTaskCreate (TASK5,
// (void *)0,
// &TASK5_STACK[TASK5_STACK_SIZE-1],
// TASK5_PRIO);
}
uint8 RESET_FLAG=0;
extern Dump_Sec(uint8);
extern W25X32_Set_Counter(uint32,uint32,uint8);
extern W25X32_Get_Counter(uint32);
extern Ini_Sec_counter(uint8*, uint8, uint8 );
extern W25X32_WRITE_BLOCK(uint32, uint32, uint8*, uint32);
extern uint8 setup_sec;
extern uint8 work_sec;
extern uint8 custom_sec;
extern uint8 mileage_sec;
//系统初始化。。。。。。。。。
void InitSystem(void)
{
char cUartArg[] = "BaudRate=9600 DataBits=8 StopBits=1 Parity=0 RtsControl=0";
char cUartArg1[] = "BaudRate=4800 DataBits=8 StopBits=1 Parity=0 RtsControl=0";
char cUartArg2[] = "BaudRate=115200 DataBits=8 StopBits=1 Parity=0 RtsControl=0";
char cUartArg3[] = "BaudRate=115200 DataBits=8 StopBits=1 Parity=0 RtsControl=0";
TargetInit (); /* 目标板初始化 */
W25X32_INIT();
WDTinit();
/*
* 引脚访问速度配置
*/
SCS &= (~(0x01)); //P0、P1默认为低速访问模式,以兼容老器件
PINSEL10 = 0; //第3位为 0:ETM interface pins control.ETM interface is disabled.
// 1:ETM interface is enabled. ETM signals are available on the pins hosting them regardless of the PINSEL4content.
FIO0MASK =0x00; //不屏蔽引脚高速功能
FIO1MASK =0x00;
FIO2MASK =0x00;
FIO3MASK =0x00;
FIO4MASK =0x00;
GPIO0_Init((1 << 17), 1); // 设置P0.17为输出,控制GPS电源
P0_GPIOSet((1 << 17)); //输出高电平
GPIO0_Init((1 << 24), 1); // 设置P0.24为输出,控制GSM模块ON_KEY
P0_GPIOClr((1 << 24)); //输出低电平
GPIO0_Init((1 << 23), 0);
GPIO1_Init((1 << 27), 0); //检测告警输入,ALARM P1.27
GPIO1_Init((1 << 18), 1); //CTC, P1.18
GPIO2_Init((1 << 1), 0); //检测ACC开关量输入 P2.1
GPIO2_Init((1 << 0), 1); //远程控制输出,CTROUT P2.0
P2_GPIOSet((1 << 0)); //输出高电平
PCONP |= (1<<24) | (1<<25);
PINSEL0 |= ((0x01 << 4) | (0x01 << 6)); /* 设置P0.2和P0.3连接到UART0 */
PINSEL0 |= 0x01 << 30; /* 设置P0.15和P0.16连接到UART1 */
PINSEL1 |= 0x01 << 0;
PINSEL0 |= ((0x01 << 20) | (0x01 << 22)); /* 设置P0.10和P0.11连接到UART2 */
PINSEL0 |= ((0x02 << 0) | (0x02 << 1)); /* 设置P0.0和P0.1连接到UART3 */
PINSEL1 |= ((0x03 << 18) | (0x03 << 20)); /* 设置P0.25和P0.26连接到UART3 */
uartInit (UART0, cUartArg, NULL); /* 初始化串口0 */
uartInit (UART1, cUartArg1, NULL); /* 初始化串口0 */
uartInit (UART2, cUartArg2, NULL); /* 初始化串口2 */
uartInit (UART3, cUartArg3, NULL); /* 初始化串口3 */
SetVICIRQ (6, 5, (uint32)uart0Isr); /* 设置UART0中断 */
SetVICIRQ (7, 6, (uint32)uart1Isr); /* 设置UART1中断 */
SetVICIRQ (28, 7, (uint32)uart2Isr); /* 设置UART2中断 */
SetVICIRQ (29, 8, (uint32)uart3Isr); /* 设置UART3中断 */
T1IR = 0x01; //定时器1,清除中断
// Chad
//uartWrite(UART3,(uint8 *)"System running......\r\n",strlen("System running......\r\n"),NULL); //测试
__DBG0_printf1("System running......\r\n");
#if defined(SYSTEM_SEMCONTROL)
gw_pSysRsrcSem = OSSemCreate(1);
{
char szOut[48];
sprintf(szOut, "\r\n== System Resource Sem=0x%x\r\n", (uint32)((void *)gw_pSysRsrcSem) );
__DBG0_printf1(szOut);
}
gw_pSysFlashSem = OSSemCreate(1);
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -