20240909-DXSPX-emb/RTCGet(可以跑的版本)/Src/Usr/App/app_main.c
2024-09-11 17:03:46 +08:00

243 lines
8.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*****************************************************************************/
/* ZTYP Technology , Inc. Copyright (c) 2001-2018 */
/*****************************************************************************/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#include <string.h>
#include "app_cfg.h"
#include "cpu_core.h"
#include "os.h"
#include "bsp.h"
#include "bsp_sys.h"
#include "usr_bsp_sys.h"
#include "usr_drv_sys.h"
#include "usr_drv_rtc_i2c.h"
#include "RTCTask.h"
#include "UartTask.h"
//#include "usr_task_sys.h"
//#include "usr_task_network.h"
//#include "usr_task_watchdog.h"
//#include "usr_task_heart.h"
//#include "usr_task_inside_para_sensor.h"
//#include "usr_task_many_para_sensor.h"
//#include "usr_task_camera.h"
//#include "usr_task_rtc.h"
//#include "usr_task_timer.h"
//#include "usr_task_imu.h"
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL CONSTANTS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL DATA TYPES
*********************************************************************************************************
*/
/*$PAGE*/
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
static OS_STK AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE];
static OS_STK RtcTaskStk[RTC_TASK_STK_SIZE];
static OS_STK UartTaskStk[UART_TASK_STK_SIZE];
/*
*********************************************************************************************************
* LOCAL MACRO'S
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void AppTaskCreate (void);
static void AppTaskStart (void *p_arg);
/*$PAGE*/
/*
*********************************************************************************************************
* main()
*
* Description : Entry point for C code.
*
* Arguments : none.
*
* Returns : none.
*
* Note(s) : (1) It is assumed that your code will call main() once you have performed all necessary
* initialization.
*********************************************************************************************************
*/
int main (void)
{
#if (OS_TASK_NAME_EN > 0)
CPU_INT08U err;
#endif
#if (CPU_CFG_NAME_EN == DEF_ENABLED)
CPU_ERR cpu_err;
#endif
#if (CPU_CFG_NAME_EN == DEF_ENABLED)
CPU_NameSet((CPU_CHAR *)"TM4C1294NCPDT",
(CPU_ERR *)&cpu_err);
#endif
CPU_IntDis(); /* Disable all interrupts. */
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
OSTaskCreateExt((void (*)(void *)) AppTaskStart, /* Create the start task */
(void *) 0,
(OS_STK *)&AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE - 1],
(INT8U ) APP_CFG_TASK_START_PRIO,
(INT16U ) APP_CFG_TASK_START_PRIO,
(OS_STK *)&AppTaskStartStk[0],
(INT32U ) APP_CFG_TASK_START_STK_SIZE,
(void *) 0,
(INT16U )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));
#if (OS_TASK_NAME_EN > 0)
OSTaskNameSet(APP_CFG_TASK_START_PRIO, (INT8U *)"Start", &err);
#endif
OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */
while (1) {
;
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* App_TaskStart()
*
* Description : Startup task example code.
*
* Arguments : p_arg Argument passed by 'OSTaskCreate()'.
*
* Returns : none.
*
* Created by : main().
*
* Notes : (1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
* used. The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
static void AppTaskStart (void *p_arg)
{
CPU_INT32U cpu_clk_freq;
CPU_INT32U cnts;
(void)p_arg; /* See Note #1 */
(void)&p_arg;
BSP_Init(); /* Initialize BSP functions */
cpu_clk_freq = BSP_SysClkFreqGet(); /* Determine SysTick reference freq. */
cnts = cpu_clk_freq /* Determine nbr SysTick increments */
/ (CPU_INT32U)OS_TICKS_PER_SEC;
OS_CPU_SysTickInit(cnts);
CPU_Init(); /* Initialize the uC/CPU services */
#if (OS_TASK_STAT_EN > 0)
OSStatInit(); /* Determine CPU capacity */
#endif
Mem_Init();
#ifdef CPU_CFG_INT_DIS_MEAS_EN
CPU_IntDisMeasMaxCurReset();
#endif
/* <20><>usr bsp <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
usr_bsp_set_sysclock(cpu_clk_freq);
/* <20><>ʼ<EFBFBD><CABC>usrbsp */
usr_bsp_sys_init();
/* <20><>ʼ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> */
usr_drv_sys_init();
AppTaskCreate(); /* Creates all the necessary application tasks. */
while (DEF_ON) {
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
OSTimeDly(1000);
}
}
/*
*********************************************************************************************************
* AppTaskCreate()
*
* Description : Create the application tasks.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : AppTaskStart()
*
* Note(s) : none.
*********************************************************************************************************
*/
static void AppTaskCreate (void)
{
OSTaskCreateExt((void (*)(void *)) RtcTask,
(void *) 0,
(OS_STK *)&RtcTaskStk[RTC_TASK_STK_SIZE - 1],
(INT8U ) RTC_TASK_PRIO,
(INT16U ) RTC_TASK_PRIO,
(OS_STK *)&RtcTaskStk[0],
(INT32U ) RTC_TASK_STK_SIZE,
(void *) 0,
(INT16U )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));
OSTaskCreateExt((void (*)(void *)) UartTask,
(void *) 0,
(OS_STK *)&UartTaskStk[UART_TASK_STK_SIZE - 1],
(INT8U ) UART_TASK_PRIO,
(INT16U ) UART_TASK_PRIO,
(OS_STK *)&UartTaskStk[0],
(INT32U ) UART_TASK_STK_SIZE,
(void *) 0,
(INT16U )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));
}