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

开始调试


结果如下:

相关推荐
superman超哥2 小时前
仓颉语言中锁的实现机制深度剖析与并发实践
c语言·开发语言·c++·python·仓颉
夜月yeyue2 小时前
Linux 调度类(sched_class)
linux·运维·c语言·单片机·性能优化
json{shen:"jing"}4 小时前
1-C语言的数据类型
c语言·c++·算法
名誉寒冰4 小时前
GDB 调试与 Core Dump(段错误)排查指南(Linux/C/C++)
linux·c语言·c++
GoWjw6 小时前
在C&C++中结构体的惯用方法
c语言·开发语言·c++
fufu03117 小时前
Linux环境下的C语言编程(四十三)
linux·c语言·算法
Darken039 小时前
基于C语言的学习---if语句
c语言·学习·if语句
json{shen:"jing"}10 小时前
2-C语言的运算符和表达式
c语言·开发语言
沪漂的码农11 小时前
UDS诊断物理层时间参数详解技术文章
c语言·can·uds
黎雁·泠崖11 小时前
【C语言指针精讲】从内存到运算,吃透指针核心逻辑
c语言·开发语言