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

开始调试


结果如下:

相关推荐
奶黄小甜包3 小时前
C语言零基础第16讲:内存函数
c语言·笔记·学习
源远流长jerry10 小时前
OpenHarmony概述与使用
c语言·c++·鸿蒙系统
艾莉丝努力练剑10 小时前
深入详解C语言的循环结构:while循环、do-while循环、for循环,结合实例,讲透C语言的循环结构
c语言·开发语言·c++·学习
晨非辰11 小时前
#C语言——学习攻略:自定义类型路线--结构体--结构体类型,结构体变量的创建和初始化,结构体内存对齐,结构体传参,结构体实现位段
c语言·开发语言·经验分享·学习·其他·学习方法·visual studio
·白小白12 小时前
【数据结构】——栈(Stack)的原理与实现
c语言·开发语言·数据结构
KFCgrandpahhh13 小时前
从0开始跟小甲鱼C语言视频使用linux一步步学习C语言(持续更新)8.13
linux·c语言·学习
Rain_is_bad15 小时前
初识c语言————排序方法
c语言·开发语言·数据结构
一支闲人16 小时前
C语言相关简单数据结构:顺序表
c语言·数据结构·基础知识·适用新手小白
John.Lewis20 小时前
数据结构初阶(11)排序的概念与运用
c语言·数据结构·排序算法
daiyanyun21 小时前
Ubuntu 20.04 虚拟机安装完整教程:从 VMware 到 VMware Tools
linux·c语言·c++·ubuntu