没有看的很明白,能不能麻烦稍微解释一下?
- /*以下统计相关功能*/
- #if USE_STATISTICAL
- /*---------------------------------------------------------
- 设置CPU使用率: CPUUsage 每秒更新一次
- ----------------------------------------------------------*/
- static void Set_CPUUsage(void)
- {
- static u32 xdata st_cu=0;
- static u16 xdata st_nu=0;
-
- st_cu += Stat_counting;
- Stat_counting = 0;
- if(++st_nu>=TICKS_PER_SEC){
- if(st_cu>Stat_base)Stat_base=st_cu;
- CPUUsage = (Stat_base-st_cu)/(Stat_base/1000UL);
- st_cu = st_nu = 0;
- }
- }
-
- /*---------------------------------------------------------------
- 统计初始化, 一个时钟滴答Stat_counting加了多少次, 结果存于Stat_base
- ----------------------------------------------------------------*/
- static void Statistical_init(void)
- {
- Timer0Init(); //Timer0 初始化
- Frame_TICK = 0;
- Stat_counting=0;
- TR0=ET0=EA=1;
- while(1){
- if(Frame_TICK){
- TR0=ET0=EA=0;
- Stat_base = Stat_counting*TICKS_PER_SEC;
- Stat_counting = 0;
- return;
- }else{
- Stat_counting++;
- }
- }
- }
- #endif
复制代码
|