Created
February 20, 2025 09:58
-
-
Save wsxq2/297fcb421018d3ff70043694b88e6435 to your computer and use it in GitHub Desktop.
STM32环境下常用函数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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