delay.c

来自「SigmDesign SMP8634 media decode chip dev」· C语言 代码 · 共 42 行

C
42
字号
#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++) {		asm("nop");	}}/*  * 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;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?