mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +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"
|
#include "common/utils.h"
|
||||||
|
|
||||||
|
#ifdef SERIAL_PORT_COUNT
|
||||||
#include "drivers/serial.h"
|
#include "drivers/serial.h"
|
||||||
#include "io/serial.h"
|
#include "io/serial.h"
|
||||||
|
|
||||||
|
static serialPort_t *printfSerialPort;
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
|
||||||
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
#include "typeconversion.h"
|
#include "typeconversion.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static serialPort_t *printfSerialPort;
|
|
||||||
|
|
||||||
#ifdef REQUIRE_CC_ARM_PRINTF_SUPPORT
|
#ifdef REQUIRE_CC_ARM_PRINTF_SUPPORT
|
||||||
|
|
||||||
|
@ -166,6 +169,7 @@ void init_printf(void *putp, void (*putf) (void *, char))
|
||||||
stdout_putp = putp;
|
stdout_putp = putp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SERIAL_PORT_COUNT
|
||||||
int tfp_printf(const char *fmt, ...)
|
int tfp_printf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
|
@ -175,6 +179,7 @@ int tfp_printf(const char *fmt, ...)
|
||||||
while (!isSerialTransmitBufferEmpty(printfSerialPort));
|
while (!isSerialTransmitBufferEmpty(printfSerialPort));
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void putcp(void *p, char c)
|
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)
|
static void _putc(void *p, char c)
|
||||||
{
|
{
|
||||||
UNUSED(p);
|
UNUSED(p);
|
||||||
serialWrite(printfSerialPort, c);
|
serialWrite(printfSerialPort, c);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void printfSupportInit(void)
|
void printfSupportInit(void)
|
||||||
{
|
{
|
||||||
|
#ifdef SERIAL_PORT_COUNT
|
||||||
init_printf(NULL, _putc);
|
init_printf(NULL, _putc);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#ifdef SERIAL_PORT_COUNT
|
||||||
// keil/armcc version
|
// keil/armcc version
|
||||||
int fputc(int c, FILE *f)
|
int fputc(int c, FILE *f)
|
||||||
{
|
{
|
||||||
|
@ -214,14 +224,20 @@ int fputc(int c, FILE *f)
|
||||||
serialWrite(printfSerialPort, c);
|
serialWrite(printfSerialPort, c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void printfSupportInit(void)
|
void printfSupportInit(void)
|
||||||
{
|
{
|
||||||
|
#ifdef SERIAL_PORT_COUNT
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SERIAL_PORT_COUNT
|
||||||
void setPrintfSerialPort(serialPort_t *serialPort)
|
void setPrintfSerialPort(serialPort_t *serialPort)
|
||||||
{
|
{
|
||||||
printfSerialPort = serialPort;
|
printfSerialPort = serialPort;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue