FastSerial: added a vprintf_P() function

used by CLI on UART2
This commit is contained in:
Andrew Tridgell 2012-11-21 16:17:50 +11:00
parent ba4b9b9961
commit d44ceb3fa5
2 changed files with 11 additions and 4 deletions

View File

@ -44,15 +44,21 @@ BetterStream::printf(const char *fmt, ...)
} }
void void
BetterStream::_printf_P(const prog_char *fmt, ...) BetterStream::_printf_P(const prog_char_t *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
_vprintf(1, fmt, ap); _vprintf(1, (const char *)fmt, ap);
va_end(ap); va_end(ap);
} }
void
BetterStream::vprintf_P(const prog_char_t *fmt, va_list ap)
{
_vprintf(1, (const char *)fmt, ap);
}
int int
BetterStream::txspace(void) BetterStream::txspace(void)
{ {

View File

@ -25,12 +25,13 @@ public:
void println_P(const prog_char_t *); void println_P(const prog_char_t *);
void printf(const char *, ...) void printf(const char *, ...)
__attribute__ ((format(__printf__, 2, 3))); __attribute__ ((format(__printf__, 2, 3)));
void _printf_P(const prog_char *, ...); void _printf_P(const prog_char_t *, ...);
__attribute__ ((format(__printf__, 2, 3))); __attribute__ ((format(__printf__, 2, 3)));
void vprintf_P(const prog_char_t *, va_list);
virtual int txspace(void); virtual int txspace(void);
#define printf_P(fmt, ...) _printf_P((const prog_char *)fmt, ## __VA_ARGS__) #define printf_P(fmt, ...) _printf_P((const prog_char_t *)fmt, ## __VA_ARGS__)
private: private:
void _vprintf(unsigned char, const char *, va_list) void _vprintf(unsigned char, const char *, va_list)