当前位置:网站首页>STM32 printf redirection virtual oscilloscope
STM32 printf redirection virtual oscilloscope
2022-04-22 06:06:00 【sameTimer】
KEIL MDK Use in DEBUG_VIEWER
#define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n)))
#define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n)))
#define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n)))
#define DEMCR (*((volatile unsigned long *)(0xE000EDFC)))
#define TRCENA 0x01000000
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f)
{
#ifdef DEBUGVIEWER // Use DEBUG_VIEWER
if (DEMCR & TRCENA)
{
while (ITM_Port32(0) == 0);
ITM_Port8(0) = ch;
}
return(ch);
#else // Use Usart Output Printf
HAL_UART_Transmit(&huart2,(uint8_t*)&ch,1,0xFFFF);
return (ch);
#endif
}
Virtual oscilloscope using Shanwai multifunctional debugging assistant
The data transmission format is 0x03 0xFC .....0x03 0xFC
#define CMD_WARE 0x03
void Putbuff(UART_HandleTypeDef *huart,uint8_t *buff,uint32_t len)
{
while(len--)
{
HAL_UART_Transmit(huart,(uint8_t*)buff,1,0xFF);
buff++;
}
}
void SendData(void* dat,uint16_t size)
{
uint8_t cmdf[2] = {CMD_WARE, ~CMD_WARE};
uint8_t cmdr[2] = {~CMD_WARE, CMD_WARE};
Putbuff(&huart2, cmdf, sizeof(cmdf));
Putbuff(&huart2, (uint8_t *)dat, size);
Putbuff(&huart2, cmdr, sizeof(cmdr));
}
版权声明
本文为[sameTimer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220542044737.html
边栏推荐
- WGS84 coordinate conversion, map picking, WGS84 coordinate tool recommended
- DS18B20 of Blue Bridge Cup embedded expansion board learning
- PyGame simple aircraft war
- Standard input, standard output, standard error redirection and pipeline
- dlopen调用动态库
- 蓝桥杯嵌入式学习之双路AD采集
- 第90篇 LeetCode剑指Offer动态规划(七)最长不包含重复字符的子字符串
- 蓝桥杯嵌入式扩展板学习之数码管
- 本地搭建服务器后的访问问题
- Dlopen calls dynamic library
猜你喜欢

第73篇 LeetCode题目练习(六) 6.Z字形变换

正点原子stm32f429官方列程编译之后用J-LINK无法下载

Chapter 86 leetcode refers to offer dynamic programming (III) maximum profit of stock

stm32学习笔记5——RGB屏相对位置计算

STM32学习笔记1——最简单的GPIO

STM32学习笔记4——HC_SR04超声波测距模块的调试记录

第72篇 LeetCode题目练习(五) 5.最长回文子串

蓝桥杯嵌入式扩展板学习之光敏电阻

Error in QT: undefined reference to ` widget:: settime()‘

第84篇 LeetCode剑指Offer动态规划(一)斐波那契数列
随机推荐
Blue Bridge Cup 31 day sprint Day8
第89篇 LeetCode剑指Offer动态规划(六)把数字翻译成字符串
After compiling the official program of punctual atom stm32f429, it cannot be downloaded with j-link
pykmip测试
Chapter 89 leetcode refers to offer dynamic programming (6) translating numbers into strings
15 - container - Dictionary
蓝桥杯嵌入式学习之双路AD采集
Chapter 88 leetcode sword refers to offer dynamic programming (V) maximum value of gifts
07 operator
日常学习记录——解决graphviz中文乱码问题
Part 72 leetcode exercise (V) 5 Longest Palindromic Substring
Blue Bridge Cup 31 day sprint day14
Apple CMS sets the local player ckplayer (version: ckplayerx)
Introduction to Intel SGX development
第74篇 LeetCode题目练习(七) 7.整数反转
QT信号与槽的特点和用法
jeecgboot-online表单开发-控件配置
AD5724 双极性ADC
Subsets and problems (backtracking & branch and bound)
hp unix上编译openssl并使用