mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-08-01 21:29:01 +08:00
修改模版代码
This commit is contained in:
parent
b4a4d87909
commit
89fbaf8e55
@ -1,24 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include <stdint.h>
|
||||
#include "bsp\delay.h"
|
||||
|
||||
#include "bsp/bsp.h"
|
||||
#include <cmsis_os2.h>
|
||||
#include <main.h>
|
||||
|
||||
/* Exported constants ------------------------------------------------------- */
|
||||
/* Exported macro ----------------------------------------------------------- */
|
||||
/* Exported types ----------------------------------------------------------- */
|
||||
/* Exported functions prototypes -------------------------------------------- */
|
||||
int8_t BSP_Delay(uint32_t ms);
|
||||
/* Private define ----------------------------------------------------------- */
|
||||
/* Private macro ------------------------------------------------------------ */
|
||||
/* Private typedef ---------------------------------------------------------- */
|
||||
/* Private variables -------------------------------------------------------- */
|
||||
/* Private function -------------------------------------------------------- */
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
int8_t BSP_Delay(uint32_t ms) {
|
||||
uint32_t tick_period = 1000u / osKernelGetTickFreq();
|
||||
uint32_t ticks = ms / tick_period;
|
||||
|
||||
int8_t BSP_Delay_Init(void);
|
||||
int8_t BSP_Delay_us(uint32_t us);
|
||||
int8_t BSP_Delay_ms(uint32_t ms);
|
||||
switch (osKernelGetState()) {
|
||||
case osKernelError:
|
||||
case osKernelReserved:
|
||||
case osKernelLocked:
|
||||
case osKernelSuspended:
|
||||
return BSP_ERR;
|
||||
|
||||
#ifdef __cplusplus
|
||||
case osKernelRunning:
|
||||
osDelay(ticks ? ticks : 1);
|
||||
break;
|
||||
|
||||
case osKernelInactive:
|
||||
case osKernelReady:
|
||||
HAL_Delay(ms);
|
||||
break;
|
||||
}
|
||||
return BSP_OK;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,2 +1,3 @@
|
||||
uart,要求开启dma和中断
|
||||
can,要求开启can的中断
|
||||
can,要求开启can的中断
|
||||
delay,暂时只有delay_ms函数
|
|
@ -5,17 +5,17 @@
|
||||
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include "task/user_task.h"
|
||||
/* USER INCLUDE BEGIN*/
|
||||
/* USER INCLUDE BEGIN */
|
||||
|
||||
/* USER INCLUDE END*/
|
||||
/* USER INCLUDE END */
|
||||
|
||||
/* Private typedef ---------------------------------------------------------- */
|
||||
/* Private define ----------------------------------------------------------- */
|
||||
/* Private macro ------------------------------------------------------------ */
|
||||
/* Private variables -------------------------------------------------------- */
|
||||
/* USER STRUCT BEGIN*/
|
||||
/* USER STRUCT BEGIN */
|
||||
|
||||
/* USER STRUCT END*/
|
||||
/* USER STRUCT END */
|
||||
|
||||
/* Private function --------------------------------------------------------- */
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
@ -28,11 +28,11 @@ void {{task_function}}(void *argument) {
|
||||
|
||||
osDelay({{task_delay}}); /* 延时一段时间再开启任务 */
|
||||
|
||||
/* USER CODE INIT BEGIN*/
|
||||
|
||||
/* USER CODE INIT END*/
|
||||
|
||||
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||
/* USER CODE INIT BEGIN */
|
||||
|
||||
/* USER CODE INIT END */
|
||||
|
||||
while (1) {
|
||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||
/* USER CODE BEGIN */
|
||||
@ -43,9 +43,9 @@ void {{task_function}}(void *argument) {
|
||||
{% else %}
|
||||
osDelay({{task_delay}}); /* 延时一段时间再开启任务 */
|
||||
|
||||
/* USER CODE INIT BEGIN*/
|
||||
/* USER CODE INIT BEGIN */
|
||||
|
||||
/* USER CODE INIT END*/
|
||||
/* USER CODE INIT END */
|
||||
|
||||
while (1) {
|
||||
/* USER CODE BEGIN */
|
||||
|
Loading…
Reference in New Issue
Block a user