解决合并冲突: 统一配置和任务定义
This commit is contained in:
commit
910bd5a1b6
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
* text=auto
|
||||||
91
.mxproject
91
.mxproject
File diff suppressed because one or more lines are too long
@ -63,7 +63,6 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
|
|||||||
User/component/user_math.c
|
User/component/user_math.c
|
||||||
User/component/crc16.c
|
User/component/crc16.c
|
||||||
User/component/PowerControl.c
|
User/component/PowerControl.c
|
||||||
# /home/shentou/workspace/SuperCap/god-yuan-hero/User/component/PowerControl.c
|
|
||||||
# User/device sources
|
# User/device sources
|
||||||
User/device/dr16.c
|
User/device/dr16.c
|
||||||
User/device/AT9S_Pro.c
|
User/device/AT9S_Pro.c
|
||||||
@ -73,7 +72,6 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
|
|||||||
User/device/motor_rm.c
|
User/device/motor_rm.c
|
||||||
User/device/vofa.c
|
User/device/vofa.c
|
||||||
User/device/supercap.c
|
User/device/supercap.c
|
||||||
# /home/shentou/workspace/SuperCap/god-yuan-hero/User/device/supercap.c
|
|
||||||
# User/module sources
|
# User/module sources
|
||||||
User/module/chassis.c
|
User/module/chassis.c
|
||||||
User/module/config.c
|
User/module/config.c
|
||||||
@ -91,7 +89,6 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
|
|||||||
User/task/rc.c
|
User/task/rc.c
|
||||||
User/task/user_task.c
|
User/task/user_task.c
|
||||||
User/task/supercap.c
|
User/task/supercap.c
|
||||||
# /home/shentou/workspace/SuperCap/god-yuan-hero/User/task/supercap.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add include paths
|
# Add include paths
|
||||||
|
|||||||
@ -1,171 +1,171 @@
|
|||||||
/* USER CODE BEGIN Header */
|
/* USER CODE BEGIN Header */
|
||||||
/*
|
/*
|
||||||
* FreeRTOS Kernel V10.3.1
|
* FreeRTOS Kernel V10.3.1
|
||||||
* Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
* Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved.
|
* Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
* the Software without restriction, including without limitation the rights to
|
* the Software without restriction, including without limitation the rights to
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
* subject to the following conditions:
|
* subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* http://www.FreeRTOS.org
|
* http://www.FreeRTOS.org
|
||||||
* http://aws.amazon.com/freertos
|
* http://aws.amazon.com/freertos
|
||||||
*
|
*
|
||||||
* 1 tab == 4 spaces!
|
* 1 tab == 4 spaces!
|
||||||
*/
|
*/
|
||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
|
|
||||||
#ifndef FREERTOS_CONFIG_H
|
#ifndef FREERTOS_CONFIG_H
|
||||||
#define FREERTOS_CONFIG_H
|
#define FREERTOS_CONFIG_H
|
||||||
|
|
||||||
/*-----------------------------------------------------------
|
/*-----------------------------------------------------------
|
||||||
* Application specific definitions.
|
* Application specific definitions.
|
||||||
*
|
*
|
||||||
* These definitions should be adjusted for your particular hardware and
|
* These definitions should be adjusted for your particular hardware and
|
||||||
* application requirements.
|
* application requirements.
|
||||||
*
|
*
|
||||||
* These parameters and more are described within the 'configuration' section of the
|
* These parameters and more are described within the 'configuration' section of the
|
||||||
* FreeRTOS API documentation available on the FreeRTOS.org web site.
|
* FreeRTOS API documentation available on the FreeRTOS.org web site.
|
||||||
*
|
*
|
||||||
* See http://www.freertos.org/a00110.html
|
* See http://www.freertos.org/a00110.html
|
||||||
*----------------------------------------------------------*/
|
*----------------------------------------------------------*/
|
||||||
|
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
/* Section where include file can be added */
|
/* Section where include file can be added */
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Ensure definitions are only used by the compiler, and not by the assembler. */
|
/* Ensure definitions are only used by the compiler, and not by the assembler. */
|
||||||
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
|
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
extern uint32_t SystemCoreClock;
|
extern uint32_t SystemCoreClock;
|
||||||
void xPortSysTickHandler(void);
|
void xPortSysTickHandler(void);
|
||||||
#endif
|
#endif
|
||||||
#ifndef CMSIS_device_header
|
#ifndef CMSIS_device_header
|
||||||
#define CMSIS_device_header "stm32f4xx.h"
|
#define CMSIS_device_header "stm32f4xx.h"
|
||||||
#endif /* CMSIS_device_header */
|
#endif /* CMSIS_device_header */
|
||||||
|
|
||||||
#define configENABLE_FPU 0
|
#define configENABLE_FPU 0
|
||||||
#define configENABLE_MPU 0
|
#define configENABLE_MPU 0
|
||||||
|
|
||||||
#define configUSE_PREEMPTION 1
|
#define configUSE_PREEMPTION 1
|
||||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||||
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||||
#define configUSE_IDLE_HOOK 0
|
#define configUSE_IDLE_HOOK 0
|
||||||
#define configUSE_TICK_HOOK 0
|
#define configUSE_TICK_HOOK 0
|
||||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||||
#define configTICK_RATE_HZ ((TickType_t)1000)
|
#define configTICK_RATE_HZ ((TickType_t)1000)
|
||||||
#define configMAX_PRIORITIES ( 56 )
|
#define configMAX_PRIORITIES ( 56 )
|
||||||
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
|
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
|
||||||
#define configTOTAL_HEAP_SIZE ((size_t)0x10000)
|
#define configTOTAL_HEAP_SIZE ((size_t)0x10000)
|
||||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||||
#define configUSE_TRACE_FACILITY 1
|
#define configUSE_TRACE_FACILITY 1
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
#define configUSE_MUTEXES 1
|
#define configUSE_MUTEXES 1
|
||||||
#define configQUEUE_REGISTRY_SIZE 8
|
#define configQUEUE_REGISTRY_SIZE 8
|
||||||
#define configUSE_RECURSIVE_MUTEXES 1
|
#define configUSE_RECURSIVE_MUTEXES 1
|
||||||
#define configUSE_COUNTING_SEMAPHORES 1
|
#define configUSE_COUNTING_SEMAPHORES 1
|
||||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||||
/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */
|
/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */
|
||||||
/* Defaults to size_t for backward compatibility, but can be changed
|
/* Defaults to size_t for backward compatibility, but can be changed
|
||||||
if lengths will always be less than the number of bytes in a size_t. */
|
if lengths will always be less than the number of bytes in a size_t. */
|
||||||
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
|
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
|
||||||
/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */
|
/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */
|
||||||
|
|
||||||
/* Co-routine definitions. */
|
/* Co-routine definitions. */
|
||||||
#define configUSE_CO_ROUTINES 0
|
#define configUSE_CO_ROUTINES 0
|
||||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||||
|
|
||||||
/* Software timer definitions. */
|
/* Software timer definitions. */
|
||||||
#define configUSE_TIMERS 1
|
#define configUSE_TIMERS 1
|
||||||
#define configTIMER_TASK_PRIORITY ( 2 )
|
#define configTIMER_TASK_PRIORITY ( 2 )
|
||||||
#define configTIMER_QUEUE_LENGTH 10
|
#define configTIMER_QUEUE_LENGTH 10
|
||||||
#define configTIMER_TASK_STACK_DEPTH 256
|
#define configTIMER_TASK_STACK_DEPTH 256
|
||||||
|
|
||||||
/* CMSIS-RTOS V2 flags */
|
/* CMSIS-RTOS V2 flags */
|
||||||
#define configUSE_OS2_THREAD_SUSPEND_RESUME 1
|
#define configUSE_OS2_THREAD_SUSPEND_RESUME 1
|
||||||
#define configUSE_OS2_THREAD_ENUMERATE 1
|
#define configUSE_OS2_THREAD_ENUMERATE 1
|
||||||
#define configUSE_OS2_EVENTFLAGS_FROM_ISR 1
|
#define configUSE_OS2_EVENTFLAGS_FROM_ISR 1
|
||||||
#define configUSE_OS2_THREAD_FLAGS 1
|
#define configUSE_OS2_THREAD_FLAGS 1
|
||||||
#define configUSE_OS2_TIMER 1
|
#define configUSE_OS2_TIMER 1
|
||||||
#define configUSE_OS2_MUTEX 1
|
#define configUSE_OS2_MUTEX 1
|
||||||
|
|
||||||
/* Set the following definitions to 1 to include the API function, or zero
|
/* Set the following definitions to 1 to include the API function, or zero
|
||||||
to exclude the API function. */
|
to exclude the API function. */
|
||||||
#define INCLUDE_vTaskPrioritySet 1
|
#define INCLUDE_vTaskPrioritySet 1
|
||||||
#define INCLUDE_uxTaskPriorityGet 1
|
#define INCLUDE_uxTaskPriorityGet 1
|
||||||
#define INCLUDE_vTaskDelete 1
|
#define INCLUDE_vTaskDelete 1
|
||||||
#define INCLUDE_vTaskCleanUpResources 0
|
#define INCLUDE_vTaskCleanUpResources 0
|
||||||
#define INCLUDE_vTaskSuspend 1
|
#define INCLUDE_vTaskSuspend 1
|
||||||
#define INCLUDE_vTaskDelayUntil 1
|
#define INCLUDE_vTaskDelayUntil 1
|
||||||
#define INCLUDE_vTaskDelay 1
|
#define INCLUDE_vTaskDelay 1
|
||||||
#define INCLUDE_xTaskGetSchedulerState 1
|
#define INCLUDE_xTaskGetSchedulerState 1
|
||||||
#define INCLUDE_xTimerPendFunctionCall 1
|
#define INCLUDE_xTimerPendFunctionCall 1
|
||||||
#define INCLUDE_xQueueGetMutexHolder 1
|
#define INCLUDE_xQueueGetMutexHolder 1
|
||||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||||
#define INCLUDE_eTaskGetState 1
|
#define INCLUDE_eTaskGetState 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used
|
* The CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used
|
||||||
* by the application thus the correct define need to be enabled below
|
* by the application thus the correct define need to be enabled below
|
||||||
*/
|
*/
|
||||||
#define USE_FreeRTOS_HEAP_4
|
#define USE_FreeRTOS_HEAP_4
|
||||||
|
|
||||||
/* Cortex-M specific definitions. */
|
/* Cortex-M specific definitions. */
|
||||||
#ifdef __NVIC_PRIO_BITS
|
#ifdef __NVIC_PRIO_BITS
|
||||||
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
||||||
#define configPRIO_BITS __NVIC_PRIO_BITS
|
#define configPRIO_BITS __NVIC_PRIO_BITS
|
||||||
#else
|
#else
|
||||||
#define configPRIO_BITS 4
|
#define configPRIO_BITS 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
||||||
function. */
|
function. */
|
||||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
|
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
|
||||||
|
|
||||||
/* The highest interrupt priority that can be used by any interrupt service
|
/* The highest interrupt priority that can be used by any interrupt service
|
||||||
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||||
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||||
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
|
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
|
||||||
|
|
||||||
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
||||||
to all Cortex-M ports, and do not rely on any particular library functions. */
|
to all Cortex-M ports, and do not rely on any particular library functions. */
|
||||||
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||||
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||||
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||||
|
|
||||||
/* Normal assert() semantics without relying on the provision of an assert.h
|
/* Normal assert() semantics without relying on the provision of an assert.h
|
||||||
header file. */
|
header file. */
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
|
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
|
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
|
||||||
standard names. */
|
standard names. */
|
||||||
#define vPortSVCHandler SVC_Handler
|
#define vPortSVCHandler SVC_Handler
|
||||||
#define xPortPendSVHandler PendSV_Handler
|
#define xPortPendSVHandler PendSV_Handler
|
||||||
|
|
||||||
/* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */
|
/* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */
|
||||||
|
|
||||||
#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 1
|
#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 1
|
||||||
|
|
||||||
/* USER CODE BEGIN Defines */
|
/* USER CODE BEGIN Defines */
|
||||||
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
|
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
|
||||||
/* USER CODE END Defines */
|
/* USER CODE END Defines */
|
||||||
|
|
||||||
#endif /* FREERTOS_CONFIG_H */
|
#endif /* FREERTOS_CONFIG_H */
|
||||||
|
|||||||
@ -27,4 +27,3 @@ void power_out_calu(power_model_t* param,float scale,float* in_array,float* rpm_
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -1,50 +1,50 @@
|
|||||||
/*
|
/*
|
||||||
blink Task
|
blink Task
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "task/user_task.h"
|
#include "task/user_task.h"
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
#include "bsp/pwm.h"
|
#include "bsp/pwm.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
/* Private define ----------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
/* USER STRUCT BEGIN */
|
/* USER STRUCT BEGIN */
|
||||||
|
|
||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
/* Private function --------------------------------------------------------- */
|
/* Private function --------------------------------------------------------- */
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void Task_blink(void *argument) {
|
void Task_blink(void *argument) {
|
||||||
(void)argument; /* 未使用argument,消除警告 */
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
|
|
||||||
|
|
||||||
/* 计算任务运行到指定频率需要等待的tick数 */
|
/* 计算任务运行到指定频率需要等待的tick数 */
|
||||||
const uint32_t delay_tick = osKernelGetTickFreq() / BLINK_FREQ;
|
const uint32_t delay_tick = osKernelGetTickFreq() / BLINK_FREQ;
|
||||||
|
|
||||||
osDelay(BLINK_INIT_DELAY); /* 延时一段时间再开启任务 */
|
osDelay(BLINK_INIT_DELAY); /* 延时一段时间再开启任务 */
|
||||||
|
|
||||||
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||||
/* USER CODE INIT BEGIN */
|
/* USER CODE INIT BEGIN */
|
||||||
BSP_PWM_Stop(BSP_PWM_LED_R);
|
BSP_PWM_Stop(BSP_PWM_LED_R);
|
||||||
BSP_PWM_Stop(BSP_PWM_LED_B);
|
BSP_PWM_Stop(BSP_PWM_LED_B);
|
||||||
BSP_PWM_SetComp(BSP_PWM_LED_G, 0.0f);
|
BSP_PWM_SetComp(BSP_PWM_LED_G, 0.0f);
|
||||||
BSP_PWM_Start(BSP_PWM_LED_G);
|
BSP_PWM_Start(BSP_PWM_LED_G);
|
||||||
/* USER CODE INIT END */
|
/* USER CODE INIT END */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
/* USER CODE BEGIN */
|
/* USER CODE BEGIN */
|
||||||
// 呼吸灯 - 基于tick的正弦波
|
// 呼吸灯 - 基于tick的正弦波
|
||||||
float duty = (sinf(tick * 0.003f) + 1.0f) * 0.5f; // 0到1之间的正弦波,加快频率
|
float duty = (sinf(tick * 0.003f) + 1.0f) * 0.5f; // 0到1之间的正弦波,加快频率
|
||||||
BSP_PWM_SetComp(BSP_PWM_LED_G, duty);
|
BSP_PWM_SetComp(BSP_PWM_LED_G, duty);
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
150
User/task/cmd.c
150
User/task/cmd.c
@ -1,75 +1,75 @@
|
|||||||
/*
|
/*
|
||||||
cmd Task
|
cmd Task
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "task/user_task.h"
|
#include "task/user_task.h"
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
#include "device/dr16.h"
|
#include "device/dr16.h"
|
||||||
#include "device/AT9S_Pro.h"
|
#include "device/AT9S_Pro.h"
|
||||||
#include "module/config.h"
|
#include "module/config.h"
|
||||||
#include "module/chassis.h"
|
#include "module/chassis.h"
|
||||||
#include "module/gimbal.h"
|
#include "module/gimbal.h"
|
||||||
#include "module/shoot.h"
|
#include "module/shoot.h"
|
||||||
#include "module/cmd.h"
|
#include "module/cmd.h"
|
||||||
//#define DEAD_AREA 0.05f
|
//#define DEAD_AREA 0.05f
|
||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
/* Private define ----------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
/* USER STRUCT BEGIN */
|
/* USER STRUCT BEGIN */
|
||||||
#if CMD_RCTypeTable_Index == 0
|
#if CMD_RCTypeTable_Index == 0
|
||||||
DR16_t cmd_dr16;
|
DR16_t cmd_dr16;
|
||||||
#elif CMD_RCTypeTable_Index == 1
|
#elif CMD_RCTypeTable_Index == 1
|
||||||
AT9S_t cmd_at9s;
|
AT9S_t cmd_at9s;
|
||||||
#endif
|
#endif
|
||||||
Shoot_CMD_t cmd_for_shoot;
|
Shoot_CMD_t cmd_for_shoot;
|
||||||
Chassis_CMD_t cmd_for_chassis;
|
Chassis_CMD_t cmd_for_chassis;
|
||||||
Gimbal_CMD_t cmd_for_gimbal;
|
Gimbal_CMD_t cmd_for_gimbal;
|
||||||
|
|
||||||
CMD_t cmd;
|
CMD_t cmd;
|
||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
/* Private function --------------------------------------------------------- */
|
/* Private function --------------------------------------------------------- */
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void Task_cmd(void *argument) {
|
void Task_cmd(void *argument) {
|
||||||
(void)argument; /* 未使用argument,消除警告 */
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
|
|
||||||
|
|
||||||
/* 计算任务运行到指定频率需要等待的tick数 */
|
/* 计算任务运行到指定频率需要等待的tick数 */
|
||||||
const uint32_t delay_tick = osKernelGetTickFreq() / CMD_FREQ;
|
const uint32_t delay_tick = osKernelGetTickFreq() / CMD_FREQ;
|
||||||
|
|
||||||
osDelay(CMD_INIT_DELAY); /* 延时一段时间再开启任务 */
|
osDelay(CMD_INIT_DELAY); /* 延时一段时间再开启任务 */
|
||||||
|
|
||||||
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||||
/* USER CODE INIT BEGIN */
|
/* USER CODE INIT BEGIN */
|
||||||
Cmd_Init(&cmd, &Config_GetRobotParam()->cmd_param);
|
Cmd_Init(&cmd, &Config_GetRobotParam()->cmd_param);
|
||||||
/* USER CODE INIT END */
|
/* USER CODE INIT END */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
/* USER CODE BEGIN */
|
/* USER CODE BEGIN */
|
||||||
#if CMD_RCTypeTable_Index == 0
|
#if CMD_RCTypeTable_Index == 0
|
||||||
osMessageQueueGet(task_runtime.msgq.cmd.rc, &cmd_dr16, NULL, 0);
|
osMessageQueueGet(task_runtime.msgq.cmd.rc, &cmd_dr16, NULL, 0);
|
||||||
#elif CMD_RCTypeTable_Index == 1
|
#elif CMD_RCTypeTable_Index == 1
|
||||||
osMessageQueueGet(task_runtime.msgq.cmd.rc, &cmd_at9s, NULL, 0);
|
osMessageQueueGet(task_runtime.msgq.cmd.rc, &cmd_at9s, NULL, 0);
|
||||||
#endif
|
#endif
|
||||||
Cmd_Get(&cmd,cmd_dr16);
|
Cmd_Get(&cmd,cmd_dr16);
|
||||||
Cmd_GenerateCommand(&cmd);
|
Cmd_GenerateCommand(&cmd);
|
||||||
cmd_for_shoot=cmd.output.shoot.cmd;
|
cmd_for_shoot=cmd.output.shoot.cmd;
|
||||||
cmd_for_chassis=cmd.output.chassis.cmd;
|
cmd_for_chassis=cmd.output.chassis.cmd;
|
||||||
cmd_for_gimbal=cmd.output.gimbal.cmd;
|
cmd_for_gimbal=cmd.output.gimbal.cmd;
|
||||||
osMessageQueueReset(task_runtime.msgq.gimbal.cmd);
|
osMessageQueueReset(task_runtime.msgq.gimbal.cmd);
|
||||||
osMessageQueuePut(task_runtime.msgq.gimbal.cmd, &cmd_for_gimbal, 0, 0);
|
osMessageQueuePut(task_runtime.msgq.gimbal.cmd, &cmd_for_gimbal, 0, 0);
|
||||||
osMessageQueueReset(task_runtime.msgq.shoot.cmd);
|
osMessageQueueReset(task_runtime.msgq.shoot.cmd);
|
||||||
osMessageQueuePut(task_runtime.msgq.shoot.cmd, &cmd_for_shoot, 0, 0);
|
osMessageQueuePut(task_runtime.msgq.shoot.cmd, &cmd_for_shoot, 0, 0);
|
||||||
osMessageQueueReset(task_runtime.msgq.chassis.cmd);
|
osMessageQueueReset(task_runtime.msgq.chassis.cmd);
|
||||||
osMessageQueuePut(task_runtime.msgq.chassis.cmd, &cmd_for_chassis, 0, 0);
|
osMessageQueuePut(task_runtime.msgq.chassis.cmd, &cmd_for_chassis, 0, 0);
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,56 +1,56 @@
|
|||||||
- delay: 0
|
- delay: 0
|
||||||
description: ''
|
description: ''
|
||||||
freq_control: true
|
freq_control: true
|
||||||
frequency: 500.0
|
frequency: 500.0
|
||||||
function: Task_rc
|
function: Task_rc
|
||||||
name: rc
|
name: rc
|
||||||
stack: 256
|
stack: 256
|
||||||
- delay: 0
|
- delay: 0
|
||||||
description: ''
|
description: ''
|
||||||
freq_control: true
|
freq_control: true
|
||||||
frequency: 1000.0
|
frequency: 1000.0
|
||||||
function: Task_atti_esti
|
function: Task_atti_esti
|
||||||
name: atti_esti
|
name: atti_esti
|
||||||
stack: 256
|
stack: 256
|
||||||
- delay: 0
|
- delay: 0
|
||||||
description: ''
|
description: ''
|
||||||
freq_control: true
|
freq_control: true
|
||||||
frequency: 100.0
|
frequency: 100.0
|
||||||
function: Task_blink
|
function: Task_blink
|
||||||
name: blink
|
name: blink
|
||||||
stack: 256
|
stack: 256
|
||||||
- delay: 0
|
- delay: 0
|
||||||
description: ''
|
description: ''
|
||||||
freq_control: true
|
freq_control: true
|
||||||
frequency: 500.0
|
frequency: 500.0
|
||||||
function: Task_ctrl_chassis
|
function: Task_ctrl_chassis
|
||||||
name: ctrl_chassis
|
name: ctrl_chassis
|
||||||
stack: 256
|
stack: 256
|
||||||
- delay: 0
|
- delay: 0
|
||||||
description: ''
|
description: ''
|
||||||
freq_control: true
|
freq_control: true
|
||||||
frequency: 500.0
|
frequency: 500.0
|
||||||
function: Task_ctrl_gimbal
|
function: Task_ctrl_gimbal
|
||||||
name: ctrl_gimbal
|
name: ctrl_gimbal
|
||||||
stack: 256
|
stack: 256
|
||||||
- delay: 0
|
- delay: 0
|
||||||
description: ''
|
description: ''
|
||||||
freq_control: true
|
freq_control: true
|
||||||
frequency: 500.0
|
frequency: 500.0
|
||||||
function: Task_ctrl_shoot
|
function: Task_ctrl_shoot
|
||||||
name: ctrl_shoot
|
name: ctrl_shoot
|
||||||
stack: 256
|
stack: 256
|
||||||
- delay: 0
|
- delay: 0
|
||||||
description: ''
|
description: ''
|
||||||
freq_control: true
|
freq_control: true
|
||||||
frequency: 500.0
|
frequency: 500.0
|
||||||
function: Task_cmd
|
function: Task_cmd
|
||||||
name: cmd
|
name: cmd
|
||||||
stack: 256
|
stack: 256
|
||||||
- delay: 0
|
- delay: 0
|
||||||
description: ''
|
description: ''
|
||||||
freq_control: true
|
freq_control: true
|
||||||
frequency: 500.0
|
frequency: 500.0
|
||||||
function: Task_supercap
|
function: Task_supercap
|
||||||
name: supercap
|
name: supercap
|
||||||
stack: 512
|
stack: 512
|
||||||
|
|||||||
@ -1,61 +1,61 @@
|
|||||||
/*
|
/*
|
||||||
ctrl_chassis Task
|
ctrl_chassis Task
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "task/user_task.h"
|
#include "task/user_task.h"
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
#include "module/chassis.h"
|
#include "module/chassis.h"
|
||||||
#include "module/config.h"
|
#include "module/config.h"
|
||||||
#include "device/supercap.h"
|
#include "device/supercap.h"
|
||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
/* Private define ----------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
/* USER STRUCT BEGIN */
|
/* USER STRUCT BEGIN */
|
||||||
Chassis_t chassis;
|
Chassis_t chassis;
|
||||||
Chassis_CMD_t chassis_cmd;
|
Chassis_CMD_t chassis_cmd;
|
||||||
Chassis_IMU_t chassis_imu;
|
Chassis_IMU_t chassis_imu;
|
||||||
float max =50;
|
float max =50;
|
||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
/* Private function --------------------------------------------------------- */
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
void Task_ctrl_chassis(void *argument) {
|
|
||||||
(void)argument; /* 未使用argument,消除警告 */
|
|
||||||
|
|
||||||
|
|
||||||
/* 计算任务运行到指定频率需要等待的tick数 */
|
|
||||||
const uint32_t delay_tick = osKernelGetTickFreq() / CTRL_CHASSIS_FREQ;
|
|
||||||
|
|
||||||
osDelay(CTRL_CHASSIS_INIT_DELAY); /* 延时一段时间再开启任务 */
|
|
||||||
|
|
||||||
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
|
||||||
/* USER CODE INIT BEGIN */
|
|
||||||
|
|
||||||
Config_RobotParam_t *cfg = Config_GetRobotParam();
|
/* Private function --------------------------------------------------------- */
|
||||||
Chassis_Init(&chassis, &cfg->chassis_param, (float)CTRL_CHASSIS_FREQ);
|
/* Exported functions ------------------------------------------------------- */
|
||||||
chassis.mech_zero=0.57f;
|
void Task_ctrl_chassis(void *argument) {
|
||||||
/* USER CODE INIT END */
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
|
|
||||||
while (1) {
|
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
|
||||||
/* USER CODE BEGIN */
|
|
||||||
|
|
||||||
osMessageQueueGet(task_runtime.msgq.chassis.yaw, &chassis.feedback.encoder_gimbalYawMotor, NULL, 0);
|
|
||||||
osMessageQueueGet(task_runtime.msgq.chassis.cmd, &chassis_cmd, NULL, 0);//遥控器
|
/* 计算任务运行到指定频率需要等待的tick数 */
|
||||||
|
const uint32_t delay_tick = osKernelGetTickFreq() / CTRL_CHASSIS_FREQ;
|
||||||
Chassis_UpdateFeedback(&chassis);
|
|
||||||
Chassis_Control(&chassis, &chassis_cmd, osKernelGetTickCount());
|
osDelay(CTRL_CHASSIS_INIT_DELAY); /* 延时一段时间再开启任务 */
|
||||||
|
|
||||||
|
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||||
|
/* USER CODE INIT BEGIN */
|
||||||
|
|
||||||
|
Config_RobotParam_t *cfg = Config_GetRobotParam();
|
||||||
|
Chassis_Init(&chassis, &cfg->chassis_param, (float)CTRL_CHASSIS_FREQ);
|
||||||
|
chassis.mech_zero=0.57f;
|
||||||
|
/* USER CODE INIT END */
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
|
/* USER CODE BEGIN */
|
||||||
|
|
||||||
|
osMessageQueueGet(task_runtime.msgq.chassis.yaw, &chassis.feedback.encoder_gimbalYawMotor, NULL, 0);
|
||||||
|
osMessageQueueGet(task_runtime.msgq.chassis.cmd, &chassis_cmd, NULL, 0);//遥控器
|
||||||
|
|
||||||
|
Chassis_UpdateFeedback(&chassis);
|
||||||
|
Chassis_Control(&chassis, &chassis_cmd, osKernelGetTickCount());
|
||||||
|
|
||||||
Chassis_Power_Control(&chassis,max);
|
Chassis_Power_Control(&chassis,max);
|
||||||
|
|
||||||
Chassis_Output(&chassis);
|
Chassis_Output(&chassis);
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
130
User/task/init.c
130
User/task/init.c
@ -1,65 +1,65 @@
|
|||||||
/*
|
/*
|
||||||
Init Task
|
Init Task
|
||||||
任务初始化,创建各个线程任务和消息队列
|
任务初始化,创建各个线程任务和消息队列
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "task/user_task.h"
|
#include "task/user_task.h"
|
||||||
|
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
#include "device/dr16.h"
|
#include "device/dr16.h"
|
||||||
#include "device/AT9S_Pro.h"
|
#include "device/AT9S_Pro.h"
|
||||||
#include "module/gimbal.h"
|
#include "module/gimbal.h"
|
||||||
#include "module/shoot.h"
|
#include "module/shoot.h"
|
||||||
#include "module/chassis.h"
|
#include "module/chassis.h"
|
||||||
|
|
||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
/* Private define ----------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
/* Private function --------------------------------------------------------- */
|
/* Private function --------------------------------------------------------- */
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief 初始化
|
* \brief 初始化
|
||||||
*
|
*
|
||||||
* \param argument 未使用
|
* \param argument 未使用
|
||||||
*/
|
*/
|
||||||
void Task_Init(void *argument) {
|
void Task_Init(void *argument) {
|
||||||
(void)argument; /* 未使用argument,消除警告 */
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
/* USER CODE INIT BEGIN */
|
/* USER CODE INIT BEGIN */
|
||||||
|
|
||||||
/* USER CODE INIT END */
|
/* USER CODE INIT END */
|
||||||
osKernelLock(); /* 锁定内核,防止任务切换 */
|
osKernelLock(); /* 锁定内核,防止任务切换 */
|
||||||
|
|
||||||
/* 创建任务线程 */
|
/* 创建任务线程 */
|
||||||
task_runtime.thread.rc = osThreadNew(Task_rc, NULL, &attr_rc);
|
task_runtime.thread.rc = osThreadNew(Task_rc, NULL, &attr_rc);
|
||||||
task_runtime.thread.atti_esti = osThreadNew(Task_atti_esti, NULL, &attr_atti_esti);
|
task_runtime.thread.atti_esti = osThreadNew(Task_atti_esti, NULL, &attr_atti_esti);
|
||||||
task_runtime.thread.blink = osThreadNew(Task_blink, NULL, &attr_blink);
|
task_runtime.thread.blink = osThreadNew(Task_blink, NULL, &attr_blink);
|
||||||
task_runtime.thread.ctrl_chassis = osThreadNew(Task_ctrl_chassis, NULL, &attr_ctrl_chassis);
|
task_runtime.thread.ctrl_chassis = osThreadNew(Task_ctrl_chassis, NULL, &attr_ctrl_chassis);
|
||||||
task_runtime.thread.ctrl_gimbal = osThreadNew(Task_ctrl_gimbal, NULL, &attr_ctrl_gimbal);
|
task_runtime.thread.ctrl_gimbal = osThreadNew(Task_ctrl_gimbal, NULL, &attr_ctrl_gimbal);
|
||||||
task_runtime.thread.ctrl_shoot = osThreadNew(Task_ctrl_shoot, NULL, &attr_ctrl_shoot);
|
task_runtime.thread.ctrl_shoot = osThreadNew(Task_ctrl_shoot, NULL, &attr_ctrl_shoot);
|
||||||
task_runtime.thread.cmd = osThreadNew(Task_cmd, NULL, &attr_cmd);
|
task_runtime.thread.cmd = osThreadNew(Task_cmd, NULL, &attr_cmd);
|
||||||
task_runtime.thread.supercap = osThreadNew(Task_supercap, NULL, &attr_supercap);
|
task_runtime.thread.supercap = osThreadNew(Task_supercap, NULL, &attr_supercap);
|
||||||
|
|
||||||
// 创建消息队列
|
// 创建消息队列
|
||||||
/* USER MESSAGE BEGIN */
|
/* USER MESSAGE BEGIN */
|
||||||
task_runtime.msgq.user_msg= osMessageQueueNew(2u, 10, NULL);
|
task_runtime.msgq.user_msg= osMessageQueueNew(2u, 10, NULL);
|
||||||
#if CMD_RCTypeTable_Index == 0
|
#if CMD_RCTypeTable_Index == 0
|
||||||
task_runtime.msgq.cmd.rc= osMessageQueueNew(3u, sizeof(DR16_t), NULL);
|
task_runtime.msgq.cmd.rc= osMessageQueueNew(3u, sizeof(DR16_t), NULL);
|
||||||
#elif CMD_RCTypeTable_Index == 1
|
#elif CMD_RCTypeTable_Index == 1
|
||||||
task_runtime.msgq.cmd.rc= osMessageQueueNew(3u, sizeof(AT9S_t), NULL);
|
task_runtime.msgq.cmd.rc= osMessageQueueNew(3u, sizeof(AT9S_t), NULL);
|
||||||
#endif
|
#endif
|
||||||
task_runtime.msgq.chassis.yaw = osMessageQueueNew(2u, sizeof(float), NULL);
|
task_runtime.msgq.chassis.yaw = osMessageQueueNew(2u, sizeof(float), NULL);
|
||||||
task_runtime.msgq.chassis.cmd= osMessageQueueNew(3u, sizeof(Chassis_CMD_t), NULL);
|
task_runtime.msgq.chassis.cmd= osMessageQueueNew(3u, sizeof(Chassis_CMD_t), NULL);
|
||||||
task_runtime.msgq.gimbal.imu= osMessageQueueNew(2u, sizeof(Gimbal_IMU_t), NULL);
|
task_runtime.msgq.gimbal.imu= osMessageQueueNew(2u, sizeof(Gimbal_IMU_t), NULL);
|
||||||
task_runtime.msgq.gimbal.cmd= osMessageQueueNew(2u, sizeof(Gimbal_CMD_t), NULL);
|
task_runtime.msgq.gimbal.cmd= osMessageQueueNew(2u, sizeof(Gimbal_CMD_t), NULL);
|
||||||
task_runtime.msgq.shoot.cmd = osMessageQueueNew(2u, sizeof(Shoot_CMD_t), NULL);
|
task_runtime.msgq.shoot.cmd = osMessageQueueNew(2u, sizeof(Shoot_CMD_t), NULL);
|
||||||
|
|
||||||
/* USER MESSAGE END */
|
/* USER MESSAGE END */
|
||||||
|
|
||||||
osKernelUnlock(); // 解锁内核
|
osKernelUnlock(); // 解锁内核
|
||||||
osThreadTerminate(osThreadGetId()); // 任务完成后结束自身
|
osThreadTerminate(osThreadGetId()); // 任务完成后结束自身
|
||||||
}
|
}
|
||||||
|
|||||||
160
User/task/rc.c
160
User/task/rc.c
@ -1,80 +1,80 @@
|
|||||||
/*
|
/*
|
||||||
rc Task
|
rc Task
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "task/user_task.h"
|
#include "task/user_task.h"
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
|
|
||||||
#define DR16
|
#define DR16
|
||||||
#ifdef AT9S
|
#ifdef AT9S
|
||||||
#include "device/at9s_pro.h"
|
#include "device/at9s_pro.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DR16
|
#ifdef DR16
|
||||||
#include "device/dr16.h"
|
#include "device/dr16.h"
|
||||||
#endif
|
#endif
|
||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
/* Private define ----------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
/* USER STRUCT BEGIN */
|
/* USER STRUCT BEGIN */
|
||||||
#ifdef AT9S
|
#ifdef AT9S
|
||||||
uint8_t cmd_buffer[AT9S_FRAME_LEN];
|
uint8_t cmd_buffer[AT9S_FRAME_LEN];
|
||||||
AT9S_t at9s;
|
AT9S_t at9s;
|
||||||
#endif
|
#endif
|
||||||
#ifdef DR16
|
#ifdef DR16
|
||||||
DR16_t dr16;
|
DR16_t dr16;
|
||||||
#endif
|
#endif
|
||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
/* Private function --------------------------------------------------------- */
|
/* Private function --------------------------------------------------------- */
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void Task_rc(void *argument) {
|
void Task_rc(void *argument) {
|
||||||
(void)argument; /* 未使用argument,消除警告 */
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
|
|
||||||
|
|
||||||
/* 计算任务运行到指定频率需要等待的tick数 */
|
/* 计算任务运行到指定频率需要等待的tick数 */
|
||||||
const uint32_t delay_tick = osKernelGetTickFreq() / RC_FREQ;
|
const uint32_t delay_tick = osKernelGetTickFreq() / RC_FREQ;
|
||||||
|
|
||||||
osDelay(RC_INIT_DELAY); /* 延时一段时间再开启任务 */
|
osDelay(RC_INIT_DELAY); /* 延时一段时间再开启任务 */
|
||||||
|
|
||||||
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||||
/* USER CODE INIT BEGIN */
|
/* USER CODE INIT BEGIN */
|
||||||
#ifdef AT9S
|
#ifdef AT9S
|
||||||
AT9S_Init(&at9s);
|
AT9S_Init(&at9s);
|
||||||
AT9S_StartDmaRecv(cmd_buffer);
|
AT9S_StartDmaRecv(cmd_buffer);
|
||||||
#endif
|
#endif
|
||||||
#ifdef DR16
|
#ifdef DR16
|
||||||
DR16_Init(&dr16);
|
DR16_Init(&dr16);
|
||||||
#endif
|
#endif
|
||||||
/* USER CODE INIT END */
|
/* USER CODE INIT END */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
/* USER CODE BEGIN */
|
/* USER CODE BEGIN */
|
||||||
#ifdef AT9S
|
#ifdef AT9S
|
||||||
if (AT9S_WaitDmaCplt(10)) {
|
if (AT9S_WaitDmaCplt(10)) {
|
||||||
AT9S_ParseRaw(cmd_buffer, &at9s);
|
AT9S_ParseRaw(cmd_buffer, &at9s);
|
||||||
AT9S_StartDmaRecv(cmd_buffer);
|
AT9S_StartDmaRecv(cmd_buffer);
|
||||||
}
|
}
|
||||||
osMessageQueuePut(task_runtime.msgq.cmd.rc, &at9s, 0, 0);
|
osMessageQueuePut(task_runtime.msgq.cmd.rc, &at9s, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef DR16
|
#ifdef DR16
|
||||||
DR16_StartDmaRecv(&dr16);
|
DR16_StartDmaRecv(&dr16);
|
||||||
if (DR16_WaitDmaCplt(20)) {
|
if (DR16_WaitDmaCplt(20)) {
|
||||||
DR16_ParseData(&dr16);
|
DR16_ParseData(&dr16);
|
||||||
} else {
|
} else {
|
||||||
DR16_Offline(&dr16);
|
DR16_Offline(&dr16);
|
||||||
}
|
}
|
||||||
osMessageQueueReset(task_runtime.msgq.cmd.rc);
|
osMessageQueueReset(task_runtime.msgq.cmd.rc);
|
||||||
osMessageQueuePut(task_runtime.msgq.cmd.rc, &dr16, 0, 0);
|
osMessageQueuePut(task_runtime.msgq.cmd.rc, &dr16, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,4 +48,4 @@ const osThreadAttr_t attr_supercap = {
|
|||||||
.name = "supercap",
|
.name = "supercap",
|
||||||
.priority = osPriorityNormal,
|
.priority = osPriorityNormal,
|
||||||
.stack_size = 512 * 4,
|
.stack_size = 512 * 4,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,157 +1,157 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include <cmsis_os2.h>
|
#include <cmsis_os2.h>
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
|
|
||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
/* Exported constants ------------------------------------------------------- */
|
/* Exported constants ------------------------------------------------------- */
|
||||||
/* 任务运行频率 */
|
/* 任务运行频率 */
|
||||||
#define RC_FREQ (500.0)
|
#define RC_FREQ (500.0)
|
||||||
#define ATTI_ESTI_FREQ (1000.0)
|
#define ATTI_ESTI_FREQ (1000.0)
|
||||||
#define BLINK_FREQ (100.0)
|
#define BLINK_FREQ (100.0)
|
||||||
#define CTRL_CHASSIS_FREQ (500.0)
|
#define CTRL_CHASSIS_FREQ (500.0)
|
||||||
#define CTRL_GIMBAL_FREQ (500.0)
|
#define CTRL_GIMBAL_FREQ (500.0)
|
||||||
#define CTRL_SHOOT_FREQ (500.0)
|
#define CTRL_SHOOT_FREQ (500.0)
|
||||||
#define CMD_FREQ (500.0)
|
#define CMD_FREQ (500.0)
|
||||||
#define SUPERCAP_FREQ (500.0)
|
#define SUPERCAP_FREQ (500.0)
|
||||||
|
|
||||||
/* 任务初始化延时ms */
|
/* 任务初始化延时ms */
|
||||||
#define TASK_INIT_DELAY (100u)
|
#define TASK_INIT_DELAY (100u)
|
||||||
#define RC_INIT_DELAY (0)
|
#define RC_INIT_DELAY (0)
|
||||||
#define ATTI_ESTI_INIT_DELAY (0)
|
#define ATTI_ESTI_INIT_DELAY (0)
|
||||||
#define BLINK_INIT_DELAY (0)
|
#define BLINK_INIT_DELAY (0)
|
||||||
#define CTRL_CHASSIS_INIT_DELAY (0)
|
#define CTRL_CHASSIS_INIT_DELAY (0)
|
||||||
#define CTRL_GIMBAL_INIT_DELAY (0)
|
#define CTRL_GIMBAL_INIT_DELAY (0)
|
||||||
#define CTRL_SHOOT_INIT_DELAY (0)
|
#define CTRL_SHOOT_INIT_DELAY (0)
|
||||||
#define CMD_INIT_DELAY (0)
|
#define CMD_INIT_DELAY (0)
|
||||||
#define SUPERCAP_INIT_DELAY (0)
|
#define SUPERCAP_INIT_DELAY (0)
|
||||||
|
|
||||||
/* Exported defines --------------------------------------------------------- */
|
/* Exported defines --------------------------------------------------------- */
|
||||||
/* Exported macro ----------------------------------------------------------- */
|
/* Exported macro ----------------------------------------------------------- */
|
||||||
/* Exported types ----------------------------------------------------------- */
|
/* Exported types ----------------------------------------------------------- */
|
||||||
|
|
||||||
/* 任务运行时结构体 */
|
/* 任务运行时结构体 */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 各任务,也可以叫做线程 */
|
/* 各任务,也可以叫做线程 */
|
||||||
struct {
|
struct {
|
||||||
osThreadId_t rc;
|
osThreadId_t rc;
|
||||||
osThreadId_t atti_esti;
|
osThreadId_t atti_esti;
|
||||||
osThreadId_t blink;
|
osThreadId_t blink;
|
||||||
osThreadId_t ctrl_chassis;
|
osThreadId_t ctrl_chassis;
|
||||||
osThreadId_t ctrl_gimbal;
|
osThreadId_t ctrl_gimbal;
|
||||||
osThreadId_t ctrl_shoot;
|
osThreadId_t ctrl_shoot;
|
||||||
osThreadId_t cmd;
|
osThreadId_t cmd;
|
||||||
osThreadId_t supercap;
|
osThreadId_t supercap;
|
||||||
} thread;
|
} thread;
|
||||||
|
|
||||||
/* USER MESSAGE BEGIN */
|
/* USER MESSAGE BEGIN */
|
||||||
struct {
|
struct {
|
||||||
osMessageQueueId_t user_msg; /* 用户自定义任务消息队列 */
|
osMessageQueueId_t user_msg; /* 用户自定义任务消息队列 */
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
osMessageQueueId_t imu;
|
osMessageQueueId_t imu;
|
||||||
osMessageQueueId_t cmd;
|
osMessageQueueId_t cmd;
|
||||||
osMessageQueueId_t yaw;
|
osMessageQueueId_t yaw;
|
||||||
}chassis;
|
}chassis;
|
||||||
struct {
|
struct {
|
||||||
osMessageQueueId_t imu;
|
osMessageQueueId_t imu;
|
||||||
osMessageQueueId_t cmd;
|
osMessageQueueId_t cmd;
|
||||||
}gimbal;
|
}gimbal;
|
||||||
struct{
|
struct{
|
||||||
osMessageQueueId_t cmd;
|
osMessageQueueId_t cmd;
|
||||||
}shoot;
|
}shoot;
|
||||||
struct{
|
struct{
|
||||||
osMessageQueueId_t rc;
|
osMessageQueueId_t rc;
|
||||||
osMessageQueueId_t pc;
|
osMessageQueueId_t pc;
|
||||||
osMessageQueueId_t nuc;
|
osMessageQueueId_t nuc;
|
||||||
osMessageQueueId_t ref;
|
osMessageQueueId_t ref;
|
||||||
}cmd;
|
}cmd;
|
||||||
|
|
||||||
|
|
||||||
} msgq;
|
} msgq;
|
||||||
/* USER MESSAGE END */
|
/* USER MESSAGE END */
|
||||||
|
|
||||||
/* 机器人状态 */
|
/* 机器人状态 */
|
||||||
struct {
|
struct {
|
||||||
float battery; /* 电池电量百分比 */
|
float battery; /* 电池电量百分比 */
|
||||||
float vbat; /* 电池电压 */
|
float vbat; /* 电池电压 */
|
||||||
float cpu_temp; /* CPU温度 */
|
float cpu_temp; /* CPU温度 */
|
||||||
} status;
|
} status;
|
||||||
|
|
||||||
/* USER CONFIG BEGIN */
|
/* USER CONFIG BEGIN */
|
||||||
|
|
||||||
/* USER CONFIG END */
|
/* USER CONFIG END */
|
||||||
|
|
||||||
/* 各任务的stack使用 */
|
/* 各任务的stack使用 */
|
||||||
struct {
|
struct {
|
||||||
UBaseType_t rc;
|
UBaseType_t rc;
|
||||||
UBaseType_t atti_esti;
|
UBaseType_t atti_esti;
|
||||||
UBaseType_t blink;
|
UBaseType_t blink;
|
||||||
UBaseType_t ctrl_chassis;
|
UBaseType_t ctrl_chassis;
|
||||||
UBaseType_t ctrl_gimbal;
|
UBaseType_t ctrl_gimbal;
|
||||||
UBaseType_t ctrl_shoot;
|
UBaseType_t ctrl_shoot;
|
||||||
UBaseType_t cmd;
|
UBaseType_t cmd;
|
||||||
UBaseType_t supercap;
|
UBaseType_t supercap;
|
||||||
} stack_water_mark;
|
} stack_water_mark;
|
||||||
|
|
||||||
/* 各任务运行频率 */
|
/* 各任务运行频率 */
|
||||||
struct {
|
struct {
|
||||||
float rc;
|
float rc;
|
||||||
float atti_esti;
|
float atti_esti;
|
||||||
float blink;
|
float blink;
|
||||||
float ctrl_chassis;
|
float ctrl_chassis;
|
||||||
float ctrl_gimbal;
|
float ctrl_gimbal;
|
||||||
float ctrl_shoot;
|
float ctrl_shoot;
|
||||||
float cmd;
|
float cmd;
|
||||||
float supercap;
|
float supercap;
|
||||||
} freq;
|
} freq;
|
||||||
|
|
||||||
/* 任务最近运行时间 */
|
/* 任务最近运行时间 */
|
||||||
struct {
|
struct {
|
||||||
float rc;
|
float rc;
|
||||||
float atti_esti;
|
float atti_esti;
|
||||||
float blink;
|
float blink;
|
||||||
float ctrl_chassis;
|
float ctrl_chassis;
|
||||||
float ctrl_gimbal;
|
float ctrl_gimbal;
|
||||||
float ctrl_shoot;
|
float ctrl_shoot;
|
||||||
float cmd;
|
float cmd;
|
||||||
float supercap;
|
float supercap;
|
||||||
} last_up_time;
|
} last_up_time;
|
||||||
|
|
||||||
} Task_Runtime_t;
|
} Task_Runtime_t;
|
||||||
|
|
||||||
/* 任务运行时结构体 */
|
/* 任务运行时结构体 */
|
||||||
extern Task_Runtime_t task_runtime;
|
extern Task_Runtime_t task_runtime;
|
||||||
|
|
||||||
/* 初始化任务句柄 */
|
/* 初始化任务句柄 */
|
||||||
extern const osThreadAttr_t attr_init;
|
extern const osThreadAttr_t attr_init;
|
||||||
extern const osThreadAttr_t attr_rc;
|
extern const osThreadAttr_t attr_rc;
|
||||||
extern const osThreadAttr_t attr_atti_esti;
|
extern const osThreadAttr_t attr_atti_esti;
|
||||||
extern const osThreadAttr_t attr_blink;
|
extern const osThreadAttr_t attr_blink;
|
||||||
extern const osThreadAttr_t attr_ctrl_chassis;
|
extern const osThreadAttr_t attr_ctrl_chassis;
|
||||||
extern const osThreadAttr_t attr_ctrl_gimbal;
|
extern const osThreadAttr_t attr_ctrl_gimbal;
|
||||||
extern const osThreadAttr_t attr_ctrl_shoot;
|
extern const osThreadAttr_t attr_ctrl_shoot;
|
||||||
extern const osThreadAttr_t attr_cmd;
|
extern const osThreadAttr_t attr_cmd;
|
||||||
extern const osThreadAttr_t attr_supercap;
|
extern const osThreadAttr_t attr_supercap;
|
||||||
|
|
||||||
/* 任务函数声明 */
|
/* 任务函数声明 */
|
||||||
void Task_Init(void *argument);
|
void Task_Init(void *argument);
|
||||||
void Task_rc(void *argument);
|
void Task_rc(void *argument);
|
||||||
void Task_atti_esti(void *argument);
|
void Task_atti_esti(void *argument);
|
||||||
void Task_blink(void *argument);
|
void Task_blink(void *argument);
|
||||||
void Task_ctrl_chassis(void *argument);
|
void Task_ctrl_chassis(void *argument);
|
||||||
void Task_ctrl_gimbal(void *argument);
|
void Task_ctrl_gimbal(void *argument);
|
||||||
void Task_ctrl_shoot(void *argument);
|
void Task_ctrl_shoot(void *argument);
|
||||||
void Task_cmd(void *argument);
|
void Task_cmd(void *argument);
|
||||||
void Task_supercap(void *argument);
|
void Task_supercap(void *argument);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user