2.19 keil里面工具EventCorder使用方法

设置方法如下:

添加初始化代码如下:

eventRecord.c

c 复制代码
#include "eventRecord.h"
#include "usart.h"
extern	UART_HandleTypeDef *pcControlUart;

/*
RecordEvent初始化
*/
void InitEventRecorder(void)
{
	#ifdef RTE_Compiler_EventRecorder
	EventRecorderInitialize(EventRecordAll, 1);
	EventRecorderStart();
	#endif
}

/**
  * @brief  printf打印重定向
USER_REAL_PORT 决定使用虚拟串口还是真实串口打印
  */
#ifdef USER_REAL_PORT
int fputc(int ch, FILE *f)
{
	#if 1
	HAL_UART_Transmit(pcControlUart, (uint8_t *)&ch,1,0x10);//使用真实串口打印
	#endif
	return ch;
}
#else
	//使用虚拟串口打印,retarget_io.c有定义
#endif

//根据实际长度打印字符串,可进行一层封装
void virtual_debug(RxTx_t src,uint8_t *data,uint16_t len)
{
	printf("%s %s",__DATE__,__TIME__);
	if(src == usart_rx)
	{
		printf("rx:");
	}
	if(src == usart_tx)
	{
		printf("tx:");
	}
	for(uint8_t i=0;i<len;i++)
	{
		printf("%c",*data);
		data++;
	}
	printf("\r\n");
}

eventRecord.h

c 复制代码
#ifndef  _EVENTRECORD_H
#define  _EVENTRECORD_H
#include <stdio.h>
#include "EventRecorderConf.h"
#include "EventRecorder.h"
#include "RTE_Components.h"


void InitEventRecorder(void);
//#define USER_REAL_PORT

#endif

使用时,调用初始化函数InitEventRecorder()即可

测试函数如下:

c 复制代码
void Test(void)
{
		EventStartA(0);
		UART_tx_IT(pcControlUart,"ack",3);
		EventStopA(0);
		
		EventStartB(1);
		osDelay(1000);
		printf("aaaa\r\n");
		EventStopB(1);
}

开始调试


结果如下:

相关推荐
小莞尔1 天前
【51单片机】【protues仿真】基于51单片机的篮球计时计分器系统
c语言·stm32·单片机·嵌入式硬件·51单片机
小莞尔1 天前
【51单片机】【protues仿真】 基于51单片机八路抢答器系统
c语言·开发语言·单片机·嵌入式硬件·51单片机
liujing102329291 天前
Day03_刷题niuke20250915
c语言
第七序章2 天前
【C++STL】list的详细用法和底层实现
c语言·c++·自然语言处理·list
l1t2 天前
利用DeepSeek实现服务器客户端模式的DuckDB原型
服务器·c语言·数据库·人工智能·postgresql·协议·duckdb
l1t2 天前
利用美团龙猫用libxml2编写XML转CSV文件C程序
xml·c语言·libxml2·解析器
Gu_shiwww2 天前
数据结构8——双向链表
c语言·数据结构·python·链表·小白初步
你怎么知道我是队长2 天前
C语言---循环结构
c语言·开发语言·算法
程序猿编码2 天前
基于 Linux 内核模块的字符设备 FIFO 驱动设计与实现解析(C/C++代码实现)
linux·c语言·c++·内核模块·fifo·字符设备
mark-puls2 天前
C语言打印爱心
c语言·开发语言·算法