248 lines
9.6 KiB
C
248 lines
9.6 KiB
C
|
|
/*
|
||
|
|
*********************************************************************************************************
|
||
|
|
* EXAMPLE CODE
|
||
|
|
*
|
||
|
|
* This file is provided as an example on how to use Micrium products.
|
||
|
|
*
|
||
|
|
* Please feel free to use any application code labeled as 'EXAMPLE CODE' in
|
||
|
|
* your application products. Example code may be used as is, in whole or in
|
||
|
|
* part, or may be used as a reference only. This file can be modified as
|
||
|
|
* required to meet the end-product requirements.
|
||
|
|
*
|
||
|
|
* Please help us continue to provide the Embedded community with the finest
|
||
|
|
* software available. Your honesty is greatly appreciated.
|
||
|
|
*
|
||
|
|
* You can find our product's user manual, API reference, release notes and
|
||
|
|
* more information at https://doc.micrium.com.
|
||
|
|
* You can contact us at www.micrium.com.
|
||
|
|
*********************************************************************************************************
|
||
|
|
*/
|
||
|
|
|
||
|
|
/*
|
||
|
|
*********************************************************************************************************
|
||
|
|
*
|
||
|
|
* APPLICATION CODE
|
||
|
|
*
|
||
|
|
* Texas Instruments TM4C129x
|
||
|
|
* on the
|
||
|
|
*
|
||
|
|
* DK-TM4C129X
|
||
|
|
* Development Kit
|
||
|
|
*
|
||
|
|
* Filename : app.c
|
||
|
|
* Version : V1.00
|
||
|
|
* Programmer(s) : FF
|
||
|
|
*********************************************************************************************************
|
||
|
|
* Note(s) : None.
|
||
|
|
*********************************************************************************************************
|
||
|
|
*/
|
||
|
|
/*
|
||
|
|
*********************************************************************************************************
|
||
|
|
* INCLUDE FILES
|
||
|
|
*********************************************************************************************************
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include "app_cfg.h"
|
||
|
|
#include <cpu_core.h>
|
||
|
|
#include <os.h>
|
||
|
|
|
||
|
|
#include "bsp.h"
|
||
|
|
#include "bsp_sys.h"
|
||
|
|
|
||
|
|
#include "McuBsp.h"
|
||
|
|
#include "RTCTask.h"
|
||
|
|
#include "UartTask.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 *)"TM4C1294KCPDT",
|
||
|
|
(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, (unsigned char *)"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();
|
||
|
|
McuBSP_Init(cpu_clk_freq);
|
||
|
|
|
||
|
|
RTCInit(USR_DRV_RTC_I2C_ADDRESS, USR_I2C_SPEED100000); // 设置时间
|
||
|
|
AppTaskCreate(); /* Creates all the necessary application tasks. */
|
||
|
|
|
||
|
|
while (DEF_ON) {
|
||
|
|
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));
|
||
|
|
}
|
||
|
|
|