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);
}

开始调试


结果如下:

相关推荐
2601_949146532 小时前
C语言语音通知接口接入教程:如何使用C语言直接调用语音预警API
c语言·开发语言
知南x4 小时前
【Ascend C系列课程(高级)】(1) 算子调试+调优
c语言·开发语言
2的n次方_6 小时前
Runtime 执行提交机制:NPU 硬件队列的管理与任务原子化下发
c语言·开发语言
凡人叶枫7 小时前
C++中智能指针详解(Linux实战版)| 彻底解决内存泄漏,新手也能吃透
java·linux·c语言·开发语言·c++·嵌入式开发
凡人叶枫9 小时前
C++中输入、输出和文件操作详解(Linux实战版)| 从基础到项目落地,避坑指南
linux·服务器·c语言·开发语言·c++
傻乐u兔9 小时前
C语言进阶————指针3
c语言·开发语言
CodeSheep程序羊11 小时前
拼多多春节加班工资曝光,没几个敢给这个数的。
java·c语言·开发语言·c++·python·程序人生·职场和发展
I'mChloe11 小时前
PTO-ISA 深度解析:PyPTO 范式生成的底层指令集与 NPU 算子执行的硬件映射
c语言·开发语言
2的n次方_11 小时前
Runtime 内存管理深化:推理批处理下的内存复用与生命周期精细控制
c语言·网络·架构
嵌入小生00712 小时前
标准IO---核心函数接口延续(嵌入式Linux)
c语言·vscode·vim·嵌入式·小白·标准io·函数接口