Make USB_SERIAL fit for the Arduino IDE.

This also includes renaming of USE_USB to USB_SERIAL for more
consistency.
This commit is contained in:
Markus Hitter 2012-11-24 15:12:24 +01:00
parent ef6036c724
commit 9b018b7433
14 changed files with 123 additions and 49 deletions

View File

@ -94,7 +94,10 @@ PROGID = stk500v2
PROGRAM = mendel 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 serial.c SOURCES = $(PROGRAM).c gcode_parse.c gcode_process.c dda.c dda_maths.c
SOURCES += dda_queue.c timer.c temp.c sermsg.c watchdog.c debug.c sersendf.c
SOURCES += heater.c analog.c intercom.c pinio.c clock.c home.c crc.c delay.c
SOURCES += serial.c usb_serial.c
ARCH = avr- ARCH = avr-
CC = $(ARCH)gcc CC = $(ARCH)gcc
@ -111,17 +114,6 @@ LIBS = -lm
LIBDEPS = LIBDEPS =
SUBDIRS = SUBDIRS =
ifneq (,$(findstring usb,$(MCU_TARGET)))
USE_USB = true
endif
ifneq (,$(findstring u4,$(MCU_TARGET)))
USE_USB = true
endif
ifdef USE_USB
CFLAGS += -DUSE_USB
SOURCES += usb_serial.c
endif
ifeq ($(PROGBAUD),0) ifeq ($(PROGBAUD),0)
PROGBAUD_FLAG = PROGBAUD_FLAG =
else else

View File

@ -384,10 +384,18 @@ DEFINE_HEATER(bed, PB4, 1)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 115200 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
// #define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -388,10 +388,18 @@ DEFINE_TEMP_SENSOR(bed, TT_INTERCOM, AIO1, 0)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 115200 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
// #define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -372,10 +372,18 @@ DEFINE_HEATER(extruder, PD6, 1)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 115200 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
// #define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -383,10 +383,18 @@ DEFINE_HEATER(bed, DIO3, 1)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 115200 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
// #define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -383,10 +383,18 @@ DEFINE_HEATER(bed, DIO3, 1)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 115200 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
// #define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -381,10 +381,18 @@ DEFINE_HEATER(fan, PH6, 1)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 115200 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
// #define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -383,10 +383,18 @@ DEFINE_HEATER(extruder, PB4, 1)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 115200 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
// #define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -379,10 +379,18 @@ DEFINE_HEATER(bed, PD6, 1)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 115200 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
// #define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -379,10 +379,18 @@ DEFINE_HEATER(bed, PD4, 1)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 115200 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
// #define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -438,10 +438,18 @@ DEFINE_HEATER(fan, DIO8, 0)
// #define REPRAP_HOST_COMPATIBILITY 20110509 // #define REPRAP_HOST_COMPATIBILITY 20110509
// #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
/** /** \def BAUD
Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. Baud rate for the serial RS232 protocol connection to the host. Usually
115200, other common values are 19200, 38400 or 57600. Ignored when USB_SERIAL
is defined.
*/ */
#define BAUD 57600 #define BAUD 115200
/** \def USB_SERIAL
Define this for using USB instead of the serial RS232 protocol. Works on
USB-equipped ATmegas, like the ATmega32U4, only.
*/
#define USB_SERIAL
/** \def XONXOFF /** \def XONXOFF
Xon/Xoff flow control. Xon/Xoff flow control.

View File

@ -13,7 +13,6 @@
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include "memory_barrier.h" #include "memory_barrier.h"
#include "config.h"
#include "arduino.h" #include "arduino.h"
/// size of TX and RX buffers. MUST be a \f$2^n\f$ value /// size of TX and RX buffers. MUST be a \f$2^n\f$ value
@ -24,7 +23,7 @@
/// ascii XON character /// ascii XON character
#define ASCII_XON 17 #define ASCII_XON 17
#ifndef USE_USB #ifndef USB_SERIAL
/// rx buffer head pointer. Points to next available space. /// rx buffer head pointer. Points to next available space.
volatile uint8_t rxhead = 0; volatile uint8_t rxhead = 0;
/// rx buffer tail pointer. Points to last character in buffer /// rx buffer tail pointer. Points to last character in buffer
@ -224,7 +223,7 @@ void serial_writechar(uint8_t data)
// enable TX interrupt so we can send this character // enable TX interrupt so we can send this character
UCSR0B |= MASK(UDRIE0); UCSR0B |= MASK(UDRIE0);
} }
#endif /* USE_USB */ #endif /* USB_SERIAL */
/// send a whole block /// send a whole block
void serial_writeblock(void *data, int datalen) void serial_writeblock(void *data, int datalen)

View File

@ -1,11 +1,12 @@
#ifndef _SERIAL_H #ifndef _SERIAL_H
#define _SERIAL_H #define _SERIAL_H
#include "config.h"
#include <stdint.h> #include <stdint.h>
#include <avr/io.h> #include <avr/io.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#ifdef USE_USB #ifdef USB_SERIAL
#include "usb_serial.h" #include "usb_serial.h"
#define serial_init() usb_init() #define serial_init() usb_init()
#define serial_rxchars() usb_serial_available() #define serial_rxchars() usb_serial_available()
@ -24,7 +25,7 @@
uint8_t serial_popchar(void); uint8_t serial_popchar(void);
// send one character // send one character
void serial_writechar(uint8_t data); void serial_writechar(uint8_t data);
#endif #endif /* USB_SERIAL */
// read/write many characters // read/write many characters
// uint8_t serial_recvblock(uint8_t *block, int blocksize); // uint8_t serial_recvblock(uint8_t *block, int blocksize);

View File

@ -31,8 +31,10 @@
// Version 1.7: fix usb_serial_set_control // Version 1.7: fix usb_serial_set_control
// 2012-10-17: Import to Teacup firmware // 2012-10-17: Import to Teacup firmware
#include "config.h"
/* protect this file from Arduino IDE */ /* protect this file from Arduino IDE */
#ifdef USE_USB #ifdef USB_SERIAL
#define USB_SERIAL_PRIVATE_INCLUDE #define USB_SERIAL_PRIVATE_INCLUDE
#include "usb_serial.h" #include "usb_serial.h"
@ -937,4 +939,4 @@ ISR(USB_COM_vect)
UECONX = (1<<STALLRQ) | (1<<EPEN); // stall UECONX = (1<<STALLRQ) | (1<<EPEN); // stall
} }
#endif /* USE_USB */ #endif /* USB_SERIAL */