Created
March 11, 2022 12:58
-
-
Save ixnisarg/cd7b9084d3d5de2028d696c5552c7a29 to your computer and use it in GitHub Desktop.
my_printf
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 <stdio.h> | |
#include <stdarg.h> | |
#include <string.h> | |
void vprint(const char *fmt, va_list argp) | |
{ | |
char string[200]; | |
if(0 < vsprintf(string,fmt,argp)) // build string | |
{ | |
HAL_UART_Transmit(&huart1, (uint8_t*)string, strlen(string), 0xffffff); // send message via UART | |
} | |
} | |
void my_printf(const char *fmt, ...) // custom printf() function | |
{ | |
va_list argp; | |
va_start(argp, fmt); | |
vprint(fmt, argp); | |
va_end(argp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment