常用STM32调试打印命令源程序
来源:互联网 发布:心书网络 更新朋友圈 编辑:程序博客网 时间:2024/06/05 05:41
/* 常用STM32调试打印命令源程序*/
/* putchar */
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/*1. STM32串口调试 STM32UartImpl.c*/
--------------------------------
#include <./Interface/UartIntf.h>
#include <STM32Impl.h>
#include <string.h>
#include <Debug.h>
static UART_HandleTypeDef* puartdebug = NULL;
void Stm32SendString(const char* str)
{
if(puartdebug == NULL)return;
HAL_UART_Transmit(puartdebug,(uint8_t*)str,strlen(str),1000);
}
VATAPI_RESULT UartOpenDebugPort(void* puart,fpSendString* fpsend)
{
puartdebug = (UART_HandleTypeDef*)puart;
*fpsend = Stm32SendString;
return SUCCESS;
}
/* 2. 调用DBGSTR() /SYSHANG()来调试STM32 Debug.C */
-----------------------------------------------------------------------
#define _DEBUG_
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
typedef void (*fpSendString)(const char* str);
void DebugInitPort(fpSendString fpstr);
void DebugPrintf(const char* fmt,...);
void DebugSystemHang(const char* fmt,...);
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__))
#define DBGSTR(format, args...) DebugPrintf("[%s:%d] "format"\r\n",__FILENAME__, __LINE__, ##args)
#define SYSHANG(format, args...) DebugSystemHang("[%s:%d] Hang : "format"\r\n",__FILENAME__, __LINE__, ##args)
static fpSendString fpsend = NULL;
static char bufoutput[128];
void DebugInitPort(fpSendString fpstr)
{
fpsend = fpstr;
}
void DebugPrintf(const char* fmt,...)
{
va_list args;
if(fpsend == NULL)return;
va_start(args,fmt);
vsprintf(bufoutput, fmt, args);
va_end(args);
fpsend(&bufoutput[0]);
}
void DebugSystemHang(const char* fmt,...)
{
va_list args;
if(fpsend == NULL)return;
va_start(args,fmt);
vsprintf(bufoutput, fmt, args);
va_end(args);
fpsend(&bufoutput[0]);
while(1);
}
#endif
--------------------------- ---------------------------------- --------------------------
#include <VATDebug.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
- 常用STM32调试打印命令源程序
- 调试常用打印方法
- stm32调试问题总结 打印"ERROR!!!问题"
- STM32--串口源程序
- STM32 flash读写源程序
- Bochs 常用调试命令
- WinDBG常用调试命令
- Bochs常用调试命令
- GDB 常用调试命令
- perl 常用调试命令
- vxworks常用调试命令
- gdb常用调试命令
- vxworks常用调试命令
- GDB常用调试命令
- gdb常用调试命令
- 常用调试命令
- GDB 常用调试命令
- GDB常用调试命令
- 哈希查找
- iOS开发中UITableViewCell选中无效问题
- 数据库、数据源、数据库连接池、JDBC,JNDI等知识点整理
- 组合数取模
- QML实现仿酷狗音乐播放器(支持在线和本地播放)
- 常用STM32调试打印命令源程序
- 正向代理、反向代理区别
- double计算分析
- StringBulider简单用法
- JS中null和undefine的区别
- 高斯判别法
- 分页逻辑设计
- iOS 保存图片到相册
- 转载-zookeeper在kafka中的作用