一、頭文件
需要包含頭文件
<ti/devices/cc26x0r2/driverlib/cpu.h>
二、原函數(shù)
//! \note If using an RTOS, consider using RTOS provided delay functions because
//! these will not block task scheduling and will potentially save power.
//!
//! Calculate delay count based on the wanted delay in microseconds (us):
//! - ui32Count = [delay in us] * [CPU clock in MHz] / [cycles per loop]
//!
//! Example: 250 us delay with code in flash and with cache and prefetch enabled:
//! - ui32Count = 250 * 48 / 4 = 3000
//!
//! \param ui32Count is the number of delay loop iterations to perform. Number must be greater than zero.
//!
//! \return None
//
//*****************************************************************************
extern void CPUdelay(uint32_t ui32Count);
傳入?yún)?shù)值 3000為 250us
三木张、封裝函數(shù)
/**
@brief 毫秒級(jí)延時(shí)函數(shù)
@param time -[in] 延時(shí)時(shí)間(毫秒)
@return 無(wú)
*/
void delayMs(uint8_t time)
{
CPUdelay(12000 * time);
}
四众辨、調(diào)用函數(shù)
delayMs(5); // 延時(shí)5ms
? 由 Leung 寫(xiě)于 2019 年 8 月 30 日