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

@ -72,7 +72,7 @@ LIBC_PATH=../Baselibc
LIBS = -Wl,--start-group -lgcc -lc -Wl,--end-group
#LIB_PATH+=-L=/lib/thumb2
#LIB_PATH+=-L=/../lib/gcc/arm-none-eabi/4.4.1/thumb2
LIB+=-L=$(LIBC_PATH) -lc
LIB += -L=$(LIBC_PATH)/include -lc
# Compilation tools
CC = $(CROSS_COMPILE)gcc
@ -84,7 +84,7 @@ GDB = $(CROSS_COMPILE)gdb
NM = $(CROSS_COMPILE)nm
# Flags
INCLUDES = -Iinclude -Isam3s_examples_include
INCLUDES = -Iinclude_board -Iinclude_sam3s -Iinclude -IBaselibcc/include
INCLUDES += -Icmsis
INCLUDES += -I$(LIBC_PATH)/include
#INCLUDES += -I$(LIBRARIES)
@ -96,9 +96,10 @@ CFLAGS += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef
CFLAGS += -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings
CFLAGS += -Wsign-compare -Waggregate-return
CFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations
CFLAGS += -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long
CFLAGS += -Wpacked -Wredundant-decls -Wnested-externs -Winline #-Wlong-long
CFLAGS += -Wunreachable-code
CFLAGS += -Wcast-align
CFLAGS += -std=c11
#CFLAGS += -Wmissing-noreturn
#CFLAGS += -Wconversion
@ -125,7 +126,7 @@ VPATH += src_board src_sam3s cmsis
# Objects built from C source files
C_CMSIS = core_cm3.o
C_LOWLEVEL = board_cstartup_gnu.o board_lowlevel.o syscalls.o exceptions.o
C_LIBLEVEL = spi.o pio.o pmc.o usart.o
C_LIBLEVEL = spi.o pio.o pmc.o usart.o pio_it.o pio_capture.o uart_console.o iso7816_4.o wdt.o
C_APPLEVEL = main.o
C_OBJECTS = $(C_CMSIS) $(C_LOWLEVEL) $(C_LIBLEVEL) $(C_APPLEVEL)

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>

View File

@ -12,6 +12,7 @@
/** Highlevel */
#include "trace.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#ifdef __GNUC__