📄 profile.c
字号:
#include <system/uart270.h>
#include <system/tmr270.h>
#include <user/intc.h>
#define PROFILE_POINT_MAX 20
Uint32 tick_cnt[PROFILE_POINT_MAX];
Uint32 tick_tot[PROFILE_POINT_MAX];
Uint32 profile_tmr_ticks=0;
static char profile_out_buff[80];
void profile_show() ;
void profile_clear_all() ;
void profile_clear(int point) ;
void profile_start(int point) ;
void profile_end(int point) ;
void profile_tmr_isr() ;
void profile_init(Uint16 tmrID, Uint16 reso) {
TMR_ConfigData tmr;
INTC_enable( (INT_ID)tmrID, FALSE);
profile_clear_all();
tmr.mode = TMR_FREE_RUN;
tmr.prescalar = 1000;
tmr.div = 27*reso;
tmr.referenceClock = TMR_REF_CLK_PLLIN;
TMR_setConfig( tmrID, &tmr);
INTCAttachISR( (INT_ID)tmrID, profile_tmr_isr );
INTC_enable( (INT_ID)tmrID, TRUE);
}
void profile_show() {
int i;
UART_sendString( UART0, "\r\n"
"\r\n Profile Results"
"\r\n ===============" );
for(i=0; i<PROFILE_POINT_MAX; i++ ) {
if(tick_tot[i] != 0 ) {
sprintf( profile_out_buff, "\r\n point %3d : %6ld ticks", i, tick_tot[i]);
UART_sendString( UART0, profile_out_buff );
}
}
UART_sendString( UART0, "\r\n\r\n");
}
void profile_clear_all() {
int i;
profile_tmr_ticks=0;
for(i=0; i<PROFILE_POINT_MAX; i++ )
profile_clear(i);
}
void profile_clear(int point) {
tick_cnt[point] = tick_tot[point] = 0;
}
void profile_start(int point) {
tick_cnt[point] = profile_tmr_ticks;
}
void profile_end(int point) {
tick_cnt[point] = profile_tmr_ticks - tick_cnt[point];
tick_tot[point] += tick_cnt[point];
}
void profile_tmr_isr() {
profile_tmr_ticks++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -