summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-11-03 21:28:02 +0000
committerThomas Martitz <kugel@rockbox.org>2009-11-03 21:28:02 +0000
commit15667059849148e6ee1718966ad3791cc638f3dd (patch)
tree3ae7a4080df65bced5915ed9ed0856151445c075
parent1ddb91ad3643add8f4586f4e3be65712277fc2aa (diff)
downloadrockbox-15667059849148e6ee1718966ad3791cc638f3dd.tar.gz
rockbox-15667059849148e6ee1718966ad3791cc638f3dd.zip
Simplify uart_printf() a bit by using vuprintf(), that also makes removing a static buffer possible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23504 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/s3c2440/uart-s3c2440.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/firmware/target/arm/s3c2440/uart-s3c2440.c b/firmware/target/arm/s3c2440/uart-s3c2440.c
index 84282f731a..2308027218 100644
--- a/firmware/target/arm/s3c2440/uart-s3c2440.c
+++ b/firmware/target/arm/s3c2440/uart-s3c2440.c
@@ -23,6 +23,7 @@
23#include <stdlib.h> 23#include <stdlib.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <stdarg.h> 25#include <stdarg.h>
26#include <sprintf.h>
26#include "inttypes.h" 27#include "inttypes.h"
27#include "string.h" 28#include "string.h"
28#include "cpu.h" 29#include "cpu.h"
@@ -58,38 +59,33 @@ void tx_writec(unsigned char c)
58} 59}
59 60
60 61
62static int uart_push(void *user_data, unsigned char ch)
63{
64 (void)user_data;
65
66 uart_send_byte(DEBUG_UART_PORT, ch);
67 if (ch == '\n')
68 uart_send_byte(DEBUG_UART_PORT, '\r');
69 return 1;
70}
71
61/**************************************************************************** 72/****************************************************************************
62 * General purpose debug function 73 * General purpose debug function
63 ****************************************************************************/ 74 ****************************************************************************/
64
65void uart_printf (const char *format, ...) 75void uart_printf (const char *format, ...)
66{ 76{
67 static bool debug_uart_init = false; 77 static bool debug_uart_init = false;
68 static char tx_buf [MAX_PRINTF_BUF];
69
70 int len;
71 unsigned char *ptr;
72 int j;
73
74 va_list ap; 78 va_list ap;
75 va_start(ap, format);
76
77 ptr = tx_buf;
78 len = vsnprintf(ptr, sizeof(tx_buf), format, ap);
79 va_end(ap);
80 79
81 if (!debug_uart_init) 80 if (!debug_uart_init)
82 { 81 {
83 uart_init_device(DEBUG_UART_PORT); 82 uart_init_device(DEBUG_UART_PORT);
84 debug_uart_init = true; 83 debug_uart_init = true;
85 } 84 }
86 85
87 for (j=0; j<len; j++) 86 va_start(ap, format);
88 { 87 vuprintf(uart_push, NULL, format, ap);
89 uart_send_byte (DEBUG_UART_PORT, tx_buf[j]); 88 va_end(ap);
90 if ( tx_buf[j] == '\n')
91 uart_send_byte (DEBUG_UART_PORT, '\r');
92 }
93} 89}
94 90
95/**************************************************************************** 91/****************************************************************************