/** ****************************************************************************** * File Name : main.c * Description : This file provides code for the configuration * of main. ****************************************************************************** * @attention * *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "sys.h" #include "delay.h" #include "usart.h" #include "led.h" #include "console.h" #include "vi.h" #include "temp.h" #include "io.h" #include "brtc.h" #include "device_param.h" #include "pl455_comm.h" #include "can_comm.h" #include "rs485_comm.h" #include "log.h" #include "task_manager.h" #include "includes.h" void console_task(void *p_arg); //Task priority #define START_TASK_PRIO 3 //Task stack size #define START_STK_SIZE 512 //Task stack CPU_STK START_TASK_STK[START_STK_SIZE]; //Task functions void start_task(void *p_arg); //can_comm task //Task priority #define CAN_COMM_TASK_PRIO 4 //Task stack size #define CAN_COMM_STK_SIZE 256 //Task stack CPU_STK CAN_COMM_TASK_STK[CAN_COMM_STK_SIZE]; //Task functions void can_comm_task(void *p_arg); //PL455 comm task //Task priority #define PL455_COMM_TASK_PRIO 5 //Task stack size #define PL455_COMM_STK_SIZE 256 //Task stack CPU_STK PL455_COMM_TASK_STK[PL455_COMM_STK_SIZE]; //Task functions void pl455_comm_task(void *p_arg); //VI ADC task //Task priority #define VI_ADC_TASK_PRIO 6 //Task stack size #define VI_ADC_STK_SIZE 256 //Task stack CPU_STK VI_ADC_TASK_STK[VI_ADC_STK_SIZE]; //Task functions void vi_adc_task(void *p_arg); //TEMP task //Task priority #define TEMP_TASK_PRIO 7 //Task stack size #define TEMP_STK_SIZE 256 //Task stack CPU_STK TEMP_TASK_STK[TEMP_STK_SIZE]; //Task functions void temp_task(void *p_arg); //RS485 task //Task priority #define RS485_COMM_TASK_PRIO 8 //Task stack size #define RS485_COMM_STK_SIZE 128 //Task stack CPU_STK RS485_COMM_TASK_STK[RS485_COMM_STK_SIZE]; //Task functions void rs485_comm_task(void *p_arg); //io task //Task priority #define IO_TASK_PRIO 9 //Task stack size #define IO_STK_SIZE 128 //Task stack CPU_STK IO_TASK_STK[IO_STK_SIZE]; //Task functions void io_task(void *p_arg); ////log task ////Task priority //#define LOG_TASK_PRIO 10 ////Task stack size //#define LOG_STK_SIZE 2048 ////Task control block //OS_TCB LOGTaskTCB; ////Task stack //CPU_STK LOG_TASK_STK[LOG_STK_SIZE]; ////Task functions //void log_task(void *p_arg); OS_Q snmp_trapQ; int main(void) { OS_ERR err; CPU_SR_ALLOC(); delay_init(168); // Delay init bsp_Init(); TaksTCBInit(); OSInit(&err); // UCOSIII init OS_CRITICAL_ENTER(); // Enter critical section //Create a started task OSTaskCreate((OS_TCB * )GetAppTaskTCB(START_TASK_PRIO), //Task control block (CPU_CHAR * )"Start Task", //Task name (OS_TASK_PTR )start_task, //Task functions (void * )0, //The parameters passed to the task function (OS_PRIO )START_TASK_PRIO, //Task priority (CPU_STK * )&START_TASK_STK[0], //Task stack base address (CPU_STK_SIZE)START_STK_SIZE/10, //Task stack depth limit (CPU_STK_SIZE)START_STK_SIZE, //Task stack size (OS_MSG_QTY )0, //Tasks within the maximum number of messages that Message Queuing can receive, for the 0 o'clock to receive messages (OS_TICK )0, //When enabling Web time length, is 0 for the default length£¬ (void * )0, //Users add stores (OS_OPT )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR, //Task options (OS_ERR * )&err); //Store the return value of the function when an error OS_CRITICAL_EXIT(); //Exit the critical section OSStart(&err); //Start UCOSIII while(1); } //Start task functions void start_task(void *p_arg) { OS_ERR err; CPU_SR_ALLOC(); p_arg = p_arg; CPU_Init(); #if OS_CFG_STAT_TASK_EN > 0u OSStatTaskCPUUsageInit(&err); //Statistical tasks #endif #ifdef CPU_CFG_INT_DIS_MEAS_EN //If measurement is enabled interrupt off time CPU_IntDisMeasMaxCurReset(); #endif #if OS_CFG_SCHED_ROUND_ROBIN_EN //When you use the Web when //The time slice round robin feature, the length of the time slice to 1 system clock ticks, 1*5=5ms OSSchedRoundRobinCfg(DEF_ENABLED,1,&err); #endif RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC,ENABLE);//Enable the CRC clock OS_CRITICAL_ENTER(); //Enters the critical section // CAN Comm Task OSTaskCreate((OS_TCB* )GetAppTaskTCB(CAN_COMM_TASK_PRIO), (CPU_CHAR* )"CAN Comm Task", (OS_TASK_PTR )can_comm_task, (void* )0, (OS_PRIO )CAN_COMM_TASK_PRIO, (CPU_STK* )&CAN_COMM_TASK_STK[0], (CPU_STK_SIZE)CAN_COMM_STK_SIZE/10, (CPU_STK_SIZE)CAN_COMM_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); // PL455 Comm task OSTaskCreate((OS_TCB* )GetAppTaskTCB(PL455_COMM_TASK_PRIO), (CPU_CHAR* )"PL455 Comm Task", (OS_TASK_PTR )pl455_comm_task, (void* )0, (OS_PRIO )PL455_COMM_TASK_PRIO, (CPU_STK* )&PL455_COMM_TASK_STK[0], (CPU_STK_SIZE)PL455_COMM_STK_SIZE/10, (CPU_STK_SIZE)PL455_COMM_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); //VI ADC task OSTaskCreate((OS_TCB* )GetAppTaskTCB(VI_ADC_TASK_PRIO), (CPU_CHAR* )"VI ADC Task", (OS_TASK_PTR )vi_adc_task, (void* )0, (OS_PRIO )VI_ADC_TASK_PRIO, (CPU_STK* )&VI_ADC_TASK_STK[0], (CPU_STK_SIZE)VI_ADC_STK_SIZE/10, (CPU_STK_SIZE)VI_ADC_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); //Temp ADC task OSTaskCreate((OS_TCB* )GetAppTaskTCB(TEMP_TASK_PRIO), (CPU_CHAR* )"Temp ADC Task", (OS_TASK_PTR )temp_task, (void* )0, (OS_PRIO )TEMP_TASK_PRIO, (CPU_STK* )&TEMP_TASK_STK[0], (CPU_STK_SIZE)TEMP_STK_SIZE/10, (CPU_STK_SIZE)TEMP_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); //RS485 Comm Task OSTaskCreate((OS_TCB* )GetAppTaskTCB(RS485_COMM_TASK_PRIO), (CPU_CHAR* )"RS485 Comm Task", (OS_TASK_PTR )rs485_comm_task, (void* )0, (OS_PRIO )RS485_COMM_TASK_PRIO, (CPU_STK* )&RS485_COMM_TASK_STK[0], (CPU_STK_SIZE)RS485_COMM_STK_SIZE/10, (CPU_STK_SIZE)RS485_COMM_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); //IO Task OSTaskCreate((OS_TCB* )GetAppTaskTCB(IO_TASK_PRIO), (CPU_CHAR* )"IO task", (OS_TASK_PTR )io_task, (void* )0, (OS_PRIO )IO_TASK_PRIO, (CPU_STK* )&IO_TASK_STK[0], (CPU_STK_SIZE)IO_STK_SIZE/10, (CPU_STK_SIZE)IO_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); //Log Task // OSTaskCreate((OS_TCB* )&LOGTaskTCB, // (CPU_CHAR* )"LOG task", // (OS_TASK_PTR )log_task, // (void* )0, // (OS_PRIO )LOG_TASK_PRIO, // (CPU_STK* )&LOG_TASK_STK[0], // (CPU_STK_SIZE)LOG_STK_SIZE/10, // (CPU_STK_SIZE)LOG_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); //Trap Task // OSTaskCreate((OS_TCB* )GetAppTaskTCB(TRAP_TASK_PRIO), // (CPU_CHAR* )"Trap task", // (OS_TASK_PTR )trap_task, // (void* )0, // (OS_PRIO )TRAP_TASK_PRIO, // (CPU_STK* )&TRAP_TASK_STK[0], // (CPU_STK_SIZE)TRAP_STK_SIZE/10, // (CPU_STK_SIZE)TRAP_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); // OS_TaskSuspend((OS_TCB*)GetAppTaskTCB(START_TASK_PRIO),&err); //Pending start task OS_CRITICAL_EXIT(); //Exit the critical section console_task(p_arg); } //Console Task void console_task(void *p_arg) { AppTaskDebug(); } //CAN COMM Task void can_comm_task(void *p_arg) { App_TaskCanComm(); } //PL455 COMM Task void pl455_comm_task(void *p_arg) { App_TaskPl455Comm(); } //VI Adc Task void vi_adc_task(void *p_arg) { AppTaskVIAdc(); } //Temp Task void temp_task(void *p_arg) { AppTaskTempAdc(); } //IO Task void rs485_comm_task(void *p_arg) { App_TaskRs485Comm(); } //IO Task void io_task(void *p_arg) { App_TaskIO(); } ////LCD COMM Task //void lcd_comm_task(void *p_arg) //{ // App_TaskLcdComm(); //} //LOG Task void log_task(void *p_arg) { // while(1) // { // } }