From 0b11812ce58ec8b4faa857d6f5fa279b32a9b250 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Wed, 17 Oct 2012 12:44:30 +0200 Subject: [PATCH] Make use of the new usb_serial (and drop usage of lufa_serial). At this point in time not a single user of LUFA is known and here is reported how usb_serial apparently works more reliable: http://forums.reprap.org/read.php?147,33082,160724#msg-160724 So it's likely we can move from lufa_serial to usb_serial entirely. --- Makefile | 17 ++++++----------- serial.c | 2 ++ serial.h | 26 +++++++++++++++++--------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index fd45a25..6f1bb20 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ PROGID = stk500v2 PROGRAM = mendel -SOURCES = $(PROGRAM).c gcode_parse.c gcode_process.c dda.c dda_maths.c dda_queue.c timer.c temp.c sermsg.c watchdog.c debug.c sersendf.c heater.c analog.c intercom.c pinio.c clock.c home.c crc.c delay.c +SOURCES = $(PROGRAM).c gcode_parse.c gcode_process.c dda.c dda_maths.c dda_queue.c timer.c temp.c sermsg.c watchdog.c debug.c sersendf.c heater.c analog.c intercom.c pinio.c clock.c home.c crc.c delay.c serial.c ARCH = avr- CC = $(ARCH)gcc @@ -110,19 +110,14 @@ LIBDEPS = SUBDIRS = ifneq (,$(findstring usb,$(MCU_TARGET))) -USE_LUFA = true +USE_USB = true endif ifneq (,$(findstring u4,$(MCU_TARGET))) -USE_LUFA = true +USE_USB = true endif -ifdef USE_LUFA -LDFLAGS += -Llufa_serial - -LIBS += -llufa_serial -SUBDIRS += lufa_serial -LIBDEPS += lufa_serial/liblufa_serial.a -else -SOURCES += serial.c +ifdef USE_USB +CFLAGS += -DUSE_USB +SOURCES += usb_serial.c endif ifeq ($(PROGBAUD),0) diff --git a/serial.c b/serial.c index 5630016..da7ff61 100644 --- a/serial.c +++ b/serial.c @@ -24,6 +24,7 @@ /// ascii XON character #define ASCII_XON 17 +#ifndef USE_USB /// rx buffer head pointer. Points to next available space. volatile uint8_t rxhead = 0; /// rx buffer tail pointer. Points to last character in buffer @@ -223,6 +224,7 @@ void serial_writechar(uint8_t data) // enable TX interrupt so we can send this character UCSR0B |= MASK(UDRIE0); } +#endif /* USE_USB */ /// send a whole block void serial_writeblock(void *data, int datalen) diff --git a/serial.h b/serial.h index cd6a54f..a949bf3 100644 --- a/serial.h +++ b/serial.h @@ -5,17 +5,25 @@ #include #include -// initialise serial subsystem -void serial_init(void); +#ifdef USE_USB + #define serial_init() usb_init() + #define serial_rxchars() usb_serial_available() + #define serial_popchar() usb_serial_getchar() + #define serial_writechar(c) usb_serial_putchar(c) +#else + // initialise serial subsystem + void serial_init(void); -// return number of characters in the receive buffer, and number of spaces in the send buffer -uint8_t serial_rxchars(void); -// uint8_t serial_txchars(void); + // return number of characters in the receive buffer, + // and number of spaces in the send buffer + uint8_t serial_rxchars(void); + // uint8_t serial_txchars(void); -// read one character -uint8_t serial_popchar(void); -// send one character -void serial_writechar(uint8_t data); + // read one character + uint8_t serial_popchar(void); + // send one character + void serial_writechar(uint8_t data); +#endif // read/write many characters // uint8_t serial_recvblock(uint8_t *block, int blocksize);