Skip to content

Instantly share code, notes, and snippets.

@ixnisarg
Created March 11, 2022 12:58
Show Gist options
  • Save ixnisarg/cd7b9084d3d5de2028d696c5552c7a29 to your computer and use it in GitHub Desktop.
Save ixnisarg/cd7b9084d3d5de2028d696c5552c7a29 to your computer and use it in GitHub Desktop.
my_printf
#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