/****************************************************************************** 版权所有: 文件名称: rt_stat.c 文件版本: 01.01 创建作者: sunxi 创建日期: 2020-06-18 功能说明: 实时统计。 其它说明: 修改记录: */ /*------------------------------- 头文件 -------------------------------------- */ #include "rt.h" /*------------------------------- 宏定义 -------------------------------------- */ /*------------------------------ 类型结构 ------------------------------------- */ /*------------------------------ 全局变量 ------------------------------------- */ struct rt_stat g_stat_other[RT_STAT_OTHER_NUM] = { {"other0", -1, 0, 0, 0}, {"other1", -1, 0, 0, 0}, {"other2", -1, 0, 0, 0}, {"other3", -1, 0, 0, 0}, {"other4", -1, 0, 0, 0}, {"other5", -1, 0, 0, 0}, {"other6", -1, 0, 0, 0}, {"other7", -1, 0, 0, 0}, }; /*------------------------------ 函数声明 ------------------------------------- */ /*------------------------------ 外部函数 ------------------------------------- 外部函数供其它实体文件引用,必须仔细检查传入参数的合法性. */ static char * q16_to_str(long q16) { static char str[32]; sprintf(str,"%f",(float)q16/Q16_BASE); return str; } void rt_stat_printf_q16(struct rt_stat *stat) { unsigned long avg = 0; if(stat->cnt) { avg = stat->sum/stat->cnt; } rt_printf("%-24s",stat->name); rt_printf("%s\t",q16_to_str((long)stat->min)); rt_printf("%s\t",q16_to_str((long)stat->max)); rt_printf("%s\t",q16_to_str((long)avg)); rt_printf("%-16lu%lu\r\n",stat->sum,stat->cnt); return; } int rt_stat_other_reset(void) { int i; for(i=0; i