summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile9
-rw-r--r--uart.c1
-rw-r--r--uart.h8
-rw-r--r--weak.c3
4 files changed, 18 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index ea5d872..ef5ba35 100644
--- a/Makefile
+++ b/Makefile
@@ -17,12 +17,17 @@ CFLAGS = -std=c11 $(WARNINGS) -O2 -flto -MMD -MP -ffreestanding -nostdlib
LDFLAGS = -T layout.ld -O2 -flto -ffreestanding -nostdlib
ASFLAGS = $(TARGET_ARCH)
-OBJ := vectors.o flashconf.o crt0.o setup.o fmk.o lib/le.o pit.o uart.o \
- usb/endpt0.o usb/endpt1.o usb/txhandler.o usb/usb.o
+OBJ := vectors.o flashconf.o crt0.o setup.o fmk.o lib/le.o pit.o \
+ usb/endpt0.o usb/endpt1.o usb/txhandler.o usb/usb.o weak.o
include $(MK20DX256)/mk20dx256.mk
CPPFLAGS += $(mk20dx256_CPPFLAGS)
+ifeq ("$(WITH_UART)", "yes")
+ CPPFLAGS += -DWITH_UART
+ OBJ += uart.o
+endif
+
%.bin: %
$(OBJCOPY) -O binary $< $@
diff --git a/uart.c b/uart.c
index 3ead880..ab3ca89 100644
--- a/uart.c
+++ b/uart.c
@@ -212,6 +212,7 @@ void uart_printf(const char *fmt, ...)
va_end(ap);
}
+void uart0_isr(void);
void uart0_isr(void)
{
int avail, start, end, tosend;
diff --git a/uart.h b/uart.h
index 5ff2d79..b60b250 100644
--- a/uart.h
+++ b/uart.h
@@ -19,10 +19,16 @@
#ifndef FMK_UART_H
#define FMK_UART_H
+#ifdef WITH_UART
void uart_setup(void);
void uart_putchar(int c);
void uart_printf(const char *fmt, ...);
void uart_puts(const char *s);
-void uart0_isr(void);
+#else
+static inline void uart_setup(void) { }
+static inline void uart_putchar(int c) { (void)c; }
+static inline void uart_printf(const char *fmt, ...) { (void)fmt; }
+static inline void uart_puts(const char *s) { (void)s; }
+#endif
#endif /* FMK_UART_H */
diff --git a/weak.c b/weak.c
new file mode 100644
index 0000000..8d8a726
--- /dev/null
+++ b/weak.c
@@ -0,0 +1,3 @@
+void uart0_isr(void);
+__attribute__ ((weak))
+void uart0_isr(void) { }