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

开始调试


结果如下:

相关推荐
handler011 小时前
Linux基础知识(1)
linux·服务器·c语言·开发语言·数据结构·c++
yashuk1 小时前
C语言实现PAT习题题解及算法学习笔记,附SQLite介绍
c语言·sqlite·开源项目·算法学习·pat习题
良木生香1 小时前
【C++ 初阶】:内存管理的迭代革新——从malloc/free 到 new/delete 的时代更迭
c语言·开发语言·c++
code_li1 小时前
▍Type-C 不等于 Type-C,是看起来已经「统一」了
c语言·开发语言·type-c
CHANG_THE_WORLD1 小时前
C 语言的 `fread` 与 C++ 的 `ifstream::read` 区别及设计哲学
java·c语言·c++
zore_c1 小时前
【C++】C++——类的默认成员函数(构造、析构、拷贝构造函数)
java·c语言·c++·笔记·算法·排序算法
itman30112 小时前
C语言、C++与C#深度研究:从底层到现代开发演进全解析
c语言·c++·c·内存管理·编译模型
爱编码的小八嘎13 小时前
C语言完美演绎8-2
c语言
zopple15 小时前
汇编、C、C++和Java核心技术对比
c语言·汇编·c++
leaves falling16 小时前
C/C++ 的内存管理,函数栈帧详讲
java·c语言·c++