| @@ -28,6 +28,8 @@ | |||
| * SOFTWARE. | |||
| */ | |||
| #if F_CPU >= 20000000 | |||
| #include "usb_desc.h" | |||
| #include "usb_names.h" | |||
| #include "mk20dx128.h" | |||
| @@ -890,4 +892,4 @@ const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] = | |||
| #endif // F_CPU >= 20 MHz | |||
| @@ -31,6 +31,8 @@ | |||
| #ifndef _usb_desc_h_ | |||
| #define _usb_desc_h_ | |||
| #if F_CPU >= 20000000 | |||
| // This header is NOT meant to be included when compiling | |||
| // user sketches in Arduino. The low-level functions | |||
| // provided by usb_dev.c are meant to be called only by | |||
| @@ -306,4 +308,6 @@ typedef struct { | |||
| extern const usb_descriptor_list_t usb_descriptor_list[]; | |||
| #endif // F_CPU >= 20 MHz | |||
| #endif | |||
| @@ -28,6 +28,8 @@ | |||
| * SOFTWARE. | |||
| */ | |||
| #if F_CPU >= 20000000 | |||
| #include "mk20dx128.h" | |||
| //#include "HardwareSerial.h" | |||
| #include "usb_dev.h" | |||
| @@ -969,4 +971,10 @@ void usb_init(void) | |||
| } | |||
| #else // F_CPU < 20 MHz | |||
| void usb_init(void) | |||
| { | |||
| } | |||
| #endif // F_CPU >= 20 MHz | |||
| @@ -31,6 +31,8 @@ | |||
| #ifndef _usb_dev_h_ | |||
| #define _usb_dev_h_ | |||
| #if F_CPU >= 20000000 | |||
| // This header is NOT meant to be included when compiling | |||
| // user sketches in Arduino. The low-level functions | |||
| // provided by usb_dev.c are meant to be called only by | |||
| @@ -101,5 +103,6 @@ extern void usb_flightsim_flush_callback(void); | |||
| #endif | |||
| #endif // F_CPU >= 20 MHz | |||
| #endif | |||
| @@ -30,6 +30,8 @@ | |||
| #include "WProgram.h" | |||
| #if F_CPU >= 20000000 | |||
| #ifdef USB_SERIAL | |||
| usb_serial_class Serial; | |||
| #endif | |||
| @@ -65,3 +67,13 @@ FlightSimClass FlightSim; | |||
| usb_seremu_class Serial; | |||
| #endif | |||
| #else // F_CPU < 20 MHz | |||
| #if defined(USB_SERIAL) || defined(USB_SERIAL_HID) | |||
| usb_serial_class Serial; | |||
| #else | |||
| usb_seremu_class Serial; | |||
| #endif | |||
| #endif // F_CPU | |||
| @@ -28,6 +28,8 @@ | |||
| * SOFTWARE. | |||
| */ | |||
| #if F_CPU >= 20000000 | |||
| #include "mk20dx128.h" | |||
| //#include "HardwareSerial.h" | |||
| #include "usb_dev.h" | |||
| @@ -104,3 +106,4 @@ void usb_free(usb_packet_t *p) | |||
| //serial_print("\n"); | |||
| } | |||
| #endif // F_CPU >= 20 MHz | |||
| @@ -28,6 +28,8 @@ | |||
| * SOFTWARE. | |||
| */ | |||
| #if F_CPU >= 20000000 | |||
| //#include "mk20dx128.h" | |||
| #include "usb_dev.h" | |||
| #include "usb_seremu.h" | |||
| @@ -256,3 +258,5 @@ void usb_seremu_flush_callback(void) | |||
| } | |||
| #endif // SEREMU_INTERFACE | |||
| #endif // F_CPU >= 20 MHz | |||
| @@ -35,6 +35,8 @@ | |||
| #include <inttypes.h> | |||
| #if F_CPU >= 20000000 | |||
| // C language implementation | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| @@ -53,7 +55,6 @@ extern volatile uint8_t usb_configuration; | |||
| } | |||
| #endif | |||
| // C++ interface | |||
| #ifdef __cplusplus | |||
| #include "Stream.h" | |||
| @@ -82,10 +83,48 @@ public: | |||
| uint8_t rts(void) { return 1; } | |||
| operator bool() { return usb_configuration; } | |||
| }; | |||
| extern usb_seremu_class Serial; | |||
| #endif // __cplusplus | |||
| #else // F_CPU < 20 MHz | |||
| // Allow Arduino programs using Serial to compile, but Serial will do nothing. | |||
| #ifdef __cplusplus | |||
| #include "Stream.h" | |||
| class usb_seremu_class : public Stream | |||
| { | |||
| public: | |||
| void begin(long) { }; | |||
| void end() { }; | |||
| virtual int available() { return 0; } | |||
| virtual int read() { return -1; } | |||
| virtual int peek() { return -1; } | |||
| virtual void flush() { } | |||
| virtual size_t write(uint8_t c) { return 1; } | |||
| virtual size_t write(const uint8_t *buffer, size_t size) { return size; } | |||
| size_t write(unsigned long n) { return 1; } | |||
| size_t write(long n) { return 1; } | |||
| size_t write(unsigned int n) { return 1; } | |||
| size_t write(int n) { return 1; } | |||
| using Print::write; | |||
| void send_now(void) { } | |||
| uint32_t baud(void) { return 0; } | |||
| uint8_t stopbits(void) { return 1; } | |||
| uint8_t paritytype(void) { return 0; } | |||
| uint8_t numbits(void) { return 8; } | |||
| uint8_t dtr(void) { return 1; } | |||
| uint8_t rts(void) { return 1; } | |||
| operator bool() { return true; } | |||
| }; | |||
| extern usb_seremu_class Serial; | |||
| #endif // __cplusplus | |||
| #endif // F_CPU >= 20 MHz | |||
| #endif // USB_HID | |||
| #endif // USBseremu_h_ | |||
| @@ -35,6 +35,8 @@ | |||
| #include <inttypes.h> | |||
| #if F_CPU >= 20000000 | |||
| // C language implementation | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| @@ -58,7 +60,6 @@ extern volatile uint8_t usb_configuration; | |||
| #define USB_SERIAL_DTR 0x01 | |||
| #define USB_SERIAL_RTS 0x02 | |||
| // C++ interface | |||
| #ifdef __cplusplus | |||
| #include "Stream.h" | |||
| @@ -98,10 +99,46 @@ public: | |||
| } | |||
| }; | |||
| extern usb_serial_class Serial; | |||
| #endif // __cplusplus | |||
| #else // F_CPU < 20 MHz | |||
| // Allow Arduino programs using Serial to compile, but Serial will do nothing. | |||
| #ifdef __cplusplus | |||
| #include "Stream.h" | |||
| class usb_serial_class : public Stream | |||
| { | |||
| public: | |||
| void begin(long) { }; | |||
| void end() { }; | |||
| virtual int available() { return 0; } | |||
| virtual int read() { return -1; } | |||
| virtual int peek() { return -1; } | |||
| virtual void flush() { } | |||
| virtual size_t write(uint8_t c) { return 1; } | |||
| virtual size_t write(const uint8_t *buffer, size_t size) { return size; } | |||
| size_t write(unsigned long n) { return 1; } | |||
| size_t write(long n) { return 1; } | |||
| size_t write(unsigned int n) { return 1; } | |||
| size_t write(int n) { return 1; } | |||
| using Print::write; | |||
| void send_now(void) { } | |||
| uint32_t baud(void) { return 0; } | |||
| uint8_t stopbits(void) { return 1; } | |||
| uint8_t paritytype(void) { return 0; } | |||
| uint8_t numbits(void) { return 8; } | |||
| uint8_t dtr(void) { return 1; } | |||
| uint8_t rts(void) { return 1; } | |||
| operator bool() { return true; } | |||
| }; | |||
| extern usb_serial_class Serial; | |||
| #endif // __cplusplus | |||
| #endif // F_CPU | |||
| #endif // USB_SERIAL || USB_SERIAL_HID | |||
| #endif // USBserial_h_ | |||