working printf
diff --git a/sam3s_example/Makefile b/sam3s_example/Makefile
index 0686704..b5097bc 100644
--- a/sam3s_example/Makefile
+++ b/sam3s_example/Makefile
@@ -72,7 +72,7 @@
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 @@
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 += -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 @@
# 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)
diff --git a/sam3s_example/atmel_softpack_libraries/libboard_sam3s-ek/include/uart_console.h b/sam3s_example/atmel_softpack_libraries/libboard_sam3s-ek/include/uart_console.h
index c48c2c1..28e7bc1 100644
--- a/sam3s_example/atmel_softpack_libraries/libboard_sam3s-ek/include/uart_console.h
+++ b/sam3s_example/atmel_softpack_libraries/libboard_sam3s-ek/include/uart_console.h
@@ -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 ) ;
diff --git a/sam3s_example/atmel_softpack_libraries/libboard_sam3s-ek/source/uart_console.c b/sam3s_example/atmel_softpack_libraries/libboard_sam3s-ek/source/uart_console.c
index 1c4cbd9..9fb7a4a 100644
--- a/sam3s_example/atmel_softpack_libraries/libboard_sam3s-ek/source/uart_console.c
+++ b/sam3s_example/atmel_softpack_libraries/libboard_sam3s-ek/source/uart_console.c
@@ -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.
*
diff --git a/sam3s_example/atmel_softpack_libraries/libchip_sam3s/include/trace.h b/sam3s_example/atmel_softpack_libraries/libchip_sam3s/include/trace.h
index 012b880..5da90a2 100644
--- a/sam3s_example/atmel_softpack_libraries/libchip_sam3s/include/trace.h
+++ b/sam3s_example/atmel_softpack_libraries/libchip_sam3s/include/trace.h
@@ -67,7 +67,7 @@
/*
* Headers
*/
-
+#include "board.h"
#include "pio.h"
#include <stdio.h>
diff --git a/sam3s_example/include/board.h b/sam3s_example/include/board.h
index d67a1cd..2ddd2ff 100644
--- a/sam3s_example/include/board.h
+++ b/sam3s_example/include/board.h
@@ -12,6 +12,7 @@
/** Highlevel */
#include "trace.h"
#include "stdio.h"
+#include "stdlib.h"
#include "string.h"
#ifdef __GNUC__