CC 2640 R 2 F学習ノート(24)――システム遅延使用

2542 ワード

一、ヘッダファイル
ヘッダファイルを含める必要がある
二、元の関数
//! 
ote 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);

入力パラメータ値3000は250 us
三、パッケージ関数
/**
 @brief        
 @param time -[in]     (  )
 @return  
*/
void delayMs(uint8_t time)
{
    CPUdelay(12000 * time);
}

四、呼び出し関数
delayMs(5);    //   5ms

•Leungが2019年8月30日に書いた