mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-07-31 20:59:02 +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 ----------------------------------------------------------------- */
|
||||
#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函数
|
|
Loading…
Reference in New Issue
Block a user