working printf

This commit is contained in:
Christina Quast
2014-12-13 13:30:31 +01:00
parent dcb67a2843
commit 99f9f7b504
5 changed files with 35 additions and 5 deletions

View File

@@ -33,6 +33,8 @@
#include <stdint.h>
extern int printf(const char *, ...);
extern void UART_Configure( uint32_t dwBaudrate, uint32_t dwMasterClock ) ;
extern void UART_PutChar( uint8_t uc ) ;
extern uint32_t UART_GetChar( void ) ;

View File

@@ -63,6 +63,32 @@
/** Is Console Initialized. */
static uint8_t _ucIsConsoleInitialized=0 ;
extern void UART_PutString(const char *str, int len) {
int i;
for (i=0; i<len; i++) {
UART_PutChar(*str++);
}
}
extern int printf(const char *fmt, ...)
{
char *cmdp;
size_t ret = 0;
va_list va;
va_start(va, fmt);
ret = vasprintf(&cmdp, fmt, va);
va_end(va);
if (ret == strlen(cmdp)) {
UART_PutString(cmdp, strlen(cmdp));
free(cmdp);
} else {
return -1;
}
return ret;
}
/**
* \brief Configures an USART peripheral with the specified parameters.
*

View File

@@ -67,7 +67,7 @@
/*
* Headers
*/
#include "board.h"
#include "pio.h"
#include <stdio.h>