mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-08-01 21:29:01 +08:00
修改delay
This commit is contained in:
parent
5369861c88
commit
a91f175e9e
46
bsp/delay.h
46
bsp/delay.h
@ -1,24 +1,34 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include <stdint.h>
|
#include "bsp\delay.h"
|
||||||
|
|
||||||
#include "bsp/bsp.h"
|
#include <cmsis_os2.h>
|
||||||
|
#include <main.h>
|
||||||
|
|
||||||
/* Exported constants ------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
/* Exported macro ----------------------------------------------------------- */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Exported types ----------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
/* Exported functions prototypes -------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
int8_t BSP_Delay(uint32_t ms);
|
/* 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);
|
switch (osKernelGetState()) {
|
||||||
int8_t BSP_Delay_us(uint32_t us);
|
case osKernelError:
|
||||||
int8_t BSP_Delay_ms(uint32_t ms);
|
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和中断
|
uart,要求开启dma和中断
|
||||||
can,要求开启can的中断
|
can,要求开启can的中断
|
||||||
|
delay,暂时只有delay_ms函数
|
|
Loading…
Reference in New Issue
Block a user