Skip to content

Instantly share code, notes, and snippets.

@wsxq2
Created February 20, 2025 09:58
Show Gist options
  • Save wsxq2/297fcb421018d3ff70043694b88e6435 to your computer and use it in GitHub Desktop.
Save wsxq2/297fcb421018d3ff70043694b88e6435 to your computer and use it in GitHub Desktop.
STM32环境下常用函数
#include "common.h"
#include <stdio.h>
#include <string.h>
void cm_print_buf(const char*hint, const uint8_t *buf, int buflen)
{
char tmp_buf[DP_TXBUFF_LEN], *p=tmp_buf;
int len=strnlen(hint, DP_TXBUFF_LEN);
if(len+buflen*3+1>=DP_TXBUFF_LEN) return;
strncpy(p, hint, len);
p+=len;
for(int i =0;i<buflen;i++) {
p+=snprintf(p, 4, "%02X ", buf[i]);
}
*p = '\n';
*(p+1) = '\0';
_dbg_printf("%s",tmp_buf);
}
#ifndef COMMON_A89HJ_H
#define COMMON_A89HJ_H
#include "dbg_printf.h"
#include "hardware.h"
void cm_print_buf(const char*hint, const uint8_t *buf, int buflen);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment