?? delay.c
字號:
#include "delay.h"#define CLOCK_FREQ_MHZ (300) // 8634 CPU clock speedRMuint32 g_cpu_freq = CLOCK_FREQ_MHZ;/* DELAY Method: * * Assumes that the inner loop will take 2 cycles * - 1 for conditional check * - 1 for the increment. * * The clock_freq is hard-coded , TODO: determine clock frequency * from using the 27MHz timer. * * Be careful. This delay has potential overflow problems depending * on the frequency of the CPU, ... It is recommended to not exceed * 1000000 for the input argument (x) => 1 second worth of delay. */void delay_us(RMuint32 period_us){ RMuint32 ct= 0; RMuint32 period_ct = g_cpu_freq * period_us/5; for(;ct< period_ct; ct++) { #ifdef USE_WIN_CE __asm(".set noreorder\n\t" "nop"); #else asm("nop"); #endif }}/* * delay_set_cpu_freq_mhz * * Sets the internal CPU frequency for use by * */void delay_set_cpu_freq_mhz(RMuint32 freq){ g_cpu_freq = freq;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -