gpio写完,延时不准
This commit is contained in:
+7
-7
@@ -14,7 +14,7 @@
|
||||
* @note void
|
||||
* @example void
|
||||
*/
|
||||
void SystemDelayConfig(void)
|
||||
void DelayConfig(void)
|
||||
{
|
||||
DEM_CR |= DEM_CR_TRCENA;
|
||||
DWT_CR |= DWT_CR_CYCCNTENA;
|
||||
@@ -28,7 +28,7 @@ void SystemDelayConfig(void)
|
||||
* @note void
|
||||
* @example void
|
||||
*/
|
||||
uint32_t SystemGetDwtCnt(void)
|
||||
unsigned int DwtCntGet(void)
|
||||
{
|
||||
return((uint32_t)DWT_CYCCNT);
|
||||
}
|
||||
@@ -40,16 +40,16 @@ uint32_t SystemGetDwtCnt(void)
|
||||
* @note void
|
||||
* @example void
|
||||
*/
|
||||
void SystemDelayUs(uint32_t Us)
|
||||
void DelayUs(unsigned int Us)
|
||||
{
|
||||
uint32_t Start = 0,End = 0,Ts = 0;
|
||||
Start = SystemGetDwtCnt();
|
||||
Start = DwtCntGet();
|
||||
|
||||
Ts = Us * (SystemCoreClock / 1000000U);
|
||||
|
||||
End = Start + Ts;
|
||||
|
||||
while(SystemGetDwtCnt() < End){;}
|
||||
while(DwtCntGet() < End){;}
|
||||
}
|
||||
/**
|
||||
* @brief 毫秒级延时函数
|
||||
@@ -58,7 +58,7 @@ void SystemDelayUs(uint32_t Us)
|
||||
* @note void
|
||||
* @example void
|
||||
*/
|
||||
void SystemDelayMs(uint32_t Ms)
|
||||
void DelayMs(unsigned int Ms)
|
||||
{
|
||||
SystemDelayUs(Ms * 1000);
|
||||
DelayUs(Ms * 1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user