mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Allow compilation of the printf code when no serial ports are used.
This commit is contained in:
parent
dc48664371
commit
9a82a041f4
1 changed files with 17 additions and 1 deletions
|
@ -40,16 +40,19 @@
|
|||
|
||||
#include "common/utils.h"
|
||||
|
||||
#ifdef SERIAL_PORT_COUNT
|
||||
#include "drivers/serial.h"
|
||||
#include "io/serial.h"
|
||||
|
||||
static serialPort_t *printfSerialPort;
|
||||
#endif
|
||||
|
||||
#include "printf.h"
|
||||
|
||||
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||
#include "typeconversion.h"
|
||||
#endif
|
||||
|
||||
static serialPort_t *printfSerialPort;
|
||||
|
||||
#ifdef REQUIRE_CC_ARM_PRINTF_SUPPORT
|
||||
|
||||
|
@ -166,6 +169,7 @@ void init_printf(void *putp, void (*putf) (void *, char))
|
|||
stdout_putp = putp;
|
||||
}
|
||||
|
||||
#ifdef SERIAL_PORT_COUNT
|
||||
int tfp_printf(const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
@ -175,6 +179,7 @@ int tfp_printf(const char *fmt, ...)
|
|||
while (!isSerialTransmitBufferEmpty(printfSerialPort));
|
||||
return written;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void putcp(void *p, char c)
|
||||
{
|
||||
|
@ -193,19 +198,24 @@ int tfp_sprintf(char *s, const char *fmt, ...)
|
|||
}
|
||||
|
||||
|
||||
#ifdef SERIAL_PORT_COUNT
|
||||
static void _putc(void *p, char c)
|
||||
{
|
||||
UNUSED(p);
|
||||
serialWrite(printfSerialPort, c);
|
||||
}
|
||||
#endif
|
||||
|
||||
void printfSupportInit(void)
|
||||
{
|
||||
#ifdef SERIAL_PORT_COUNT
|
||||
init_printf(NULL, _putc);
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifdef SERIAL_PORT_COUNT
|
||||
// keil/armcc version
|
||||
int fputc(int c, FILE *f)
|
||||
{
|
||||
|
@ -214,14 +224,20 @@ int fputc(int c, FILE *f)
|
|||
serialWrite(printfSerialPort, c);
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
void printfSupportInit(void)
|
||||
{
|
||||
#ifdef SERIAL_PORT_COUNT
|
||||
// Nothing to do
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_COUNT
|
||||
void setPrintfSerialPort(serialPort_t *serialPort)
|
||||
{
|
||||
printfSerialPort = serialPort;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue