/*
*********************************************************************************************************
* EXAMPLE CODE
*
* (c) Copyright 2009; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
* Knowledge of the source code may NOT be used to develop a similar product.
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* EXAMPLE CODE
*
* ST Microelectronics STM32
* on the
*
* Micrium uC-Eval-STM32F107
* Evaluation Board
*
* Filename : app.c
* Version : V1.00
* Programmer(s) : JJL
EHS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#include <includes.h>
#include <math.h>
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
#define APP_TEST_MAX 20
#define MOTMAXPosition 43989
#define limit_max 2450
#define limit_min 2100
/*
*********************************************************************************************************
* LOCAL VARIABLES
*********************************************************************************************************
*/
static OS_TCB AppTaskStartTCB;
static OS_TCB ETHEncoderTCB;
static OS_TCB ETHSenderTCB;
//static OS_TCB FlashWriterTCB;
//static OS_TCB USARTTCB;
static OS_SEM AppETHEncoderSem;
static OS_SEM AppETHSenderSem;
//static OS_SEM AppFlashWriterSem;
//static OS_SEM AppUSARTSem;
static OS_SEM AppTaskStartSem;
static OS_FLAG_GRP AppETHEncoderFlagGrp;
static CPU_STK AppTaskStartStk[APP_TASK_START_STK_SIZE];
static CPU_STK AppTaskETHEncoderStk[APP_ETHEncoder_STK_SIZE];
static CPU_STK AppTaskETHSenderStk[APP_ETHSender_STK_SIZE];
//static CPU_STK AppTaskFlashWriterStk[APP_FlashWriter_STK_SIZE];
//static CPU_STK AppTaskUSARTStk[APP_USART_STK_SIZE];
/*CAN VARIABLES*/
CPU_INT32U CANAddrToGet;//暂存发送的目标地址
CanRxMsg CANRxMessage;
CanTxMsg CANTxMessage;
CPU_INT08U CAN_RX0_Buffer[8];
/*Ethernet VARIABLES*/
CPU_INT08U USART_Buf[256];//串口写入缓存
CPU_INT16U NofData;
/*USART VARIABLES*/
CPU_BOOLEAN USART_DISABLE_FLAG = 0;
/*LED VARIABLES*/
CPU_INT16U tick = 0;
/*Task_Execute_Times VARIABLES*/
CPU_INT32U TaskExeTim_ETH = 0;
CPU_INT32U TaskExeTim_ETH1 = 0;
CPU_INT32U TaskExeTim_FlashWriter = 0;
CPU_INT32U TaskExeTim_USART = 0;
CPU_INT32U clk_freq_mhz;
/*Task_Test_Code VARIABLES*/
CPU_INT32U TestOK1 = 0;
CPU_INT32U TestOK2 = 0;
CPU_INT32U TestOK3 = 0;
/*Reset steps VARIABLES*/
CPU_INT32U Reset_steps = 0;
CPU_INT32U Reset_steps_Last = 0;
CPU_INT32U Reset_TIMES = 0;
CPU_INT32U MotPosMax = 0;
/*Turn VARIABLES*/
CPU_INT08S TurnBitOld = 0;
CPU_INT08S TurnBit = 0;
/*ADC1 VARIABLES*/
CPU_INT16U ADC_DATA1 = 0;
unsigned char can_flag = 0;
unsigned char reset_flag = 0;
unsigned char can_receive_flag = 0;
unsigned char can_reset_flag = 0;
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void AppTaskETHEncoder (void *p_arg);
static void AppTaskETHSender (void *p_arg);
//static void AppTaskFlashWriter (void *p_arg);
//static void AppTaskUSART (void *p_arg);
static void AppTaskStart (void *p_arg);
static void AppTaskCreate (void);
static void AppObjCreate (void);
/*
*********************************************************************************************************
* main()
*
* Description : This is the standard entry point for C code. It is assumed that your code will call
* main() once you have performed all necessary initialization.
*
* Arguments : none
*
* Returns : none
*********************************************************************************************************
*/
int main (void)
{
OS_ERR err;
BSP_IntDisAll(); /* Disable all interrupts. */
OSInit(&err);
/* Init uC/OS-III. */
OSTaskCreate((OS_TCB *)&AppTaskStartTCB, /* Create the start task */
(CPU_CHAR *)"App Task Start",
(OS_TASK_PTR)AppTaskStart,
(void *)0,
(OS_PRIO )APP_TASK_START_PRIO,
(CPU_STK *)&AppTaskStartStk[0],
(CPU_STK *)&AppTaskStartStk[APP_TASK_START_STK_SIZE / 10],
(OS_STK_SIZE)APP_TASK_START_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);
OSStart(&err); /* Start multitasking (i.e. give control to uC/OS-III). */
}
/*
*********************************************************************************************************
* STARTUP TASK
*
* Description : This is an example of a startup task. As mentioned in the book's text, you MUST
* initialize the ticker only once multitasking has started.
*
* Arguments : p_arg is the argument passed to 'AppTaskStart()' by 'OSTaskCreate()'.
*
* Returns : none
*
* 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;
OS_ERR err;
CPU_TS ts;
(void)p_arg;
BSP_Init(); /* Initialize BSP functions */
CPU_Init(); /* Initialize the uC/CPU services */
cpu_clk_freq = BSP_CPU_ClkFreq(); /* Determine SysTick reference freq. */
app.rar_stm32-
版权申诉
22 浏览量
2022-09-23
13:38:26
上传
评论
收藏 4KB RAR 举报
我虽横行却不霸道
- 粉丝: 77
- 资源: 1万+