* SOFTWARE. | * SOFTWARE. | ||||
*/ | */ | ||||
#if F_CPU >= 20000000 | |||||
#include "usb_desc.h" | #include "usb_desc.h" | ||||
#include "usb_names.h" | #include "usb_names.h" | ||||
#include "mk20dx128.h" | #include "mk20dx128.h" | ||||
#endif // F_CPU >= 20 MHz |
#ifndef _usb_desc_h_ | #ifndef _usb_desc_h_ | ||||
#define _usb_desc_h_ | #define _usb_desc_h_ | ||||
#if F_CPU >= 20000000 | |||||
// This header is NOT meant to be included when compiling | // This header is NOT meant to be included when compiling | ||||
// user sketches in Arduino. The low-level functions | // user sketches in Arduino. The low-level functions | ||||
// provided by usb_dev.c are meant to be called only by | // provided by usb_dev.c are meant to be called only by | ||||
extern const usb_descriptor_list_t usb_descriptor_list[]; | extern const usb_descriptor_list_t usb_descriptor_list[]; | ||||
#endif // F_CPU >= 20 MHz | |||||
#endif | #endif |
* SOFTWARE. | * SOFTWARE. | ||||
*/ | */ | ||||
#if F_CPU >= 20000000 | |||||
#include "mk20dx128.h" | #include "mk20dx128.h" | ||||
//#include "HardwareSerial.h" | //#include "HardwareSerial.h" | ||||
#include "usb_dev.h" | #include "usb_dev.h" | ||||
} | } | ||||
#else // F_CPU < 20 MHz | |||||
void usb_init(void) | |||||
{ | |||||
} | |||||
#endif // F_CPU >= 20 MHz |
#ifndef _usb_dev_h_ | #ifndef _usb_dev_h_ | ||||
#define _usb_dev_h_ | #define _usb_dev_h_ | ||||
#if F_CPU >= 20000000 | |||||
// This header is NOT meant to be included when compiling | // This header is NOT meant to be included when compiling | ||||
// user sketches in Arduino. The low-level functions | // user sketches in Arduino. The low-level functions | ||||
// provided by usb_dev.c are meant to be called only by | // provided by usb_dev.c are meant to be called only by | ||||
#endif | #endif | ||||
#endif // F_CPU >= 20 MHz | |||||
#endif | #endif |
#include "WProgram.h" | #include "WProgram.h" | ||||
#if F_CPU >= 20000000 | |||||
#ifdef USB_SERIAL | #ifdef USB_SERIAL | ||||
usb_serial_class Serial; | usb_serial_class Serial; | ||||
#endif | #endif | ||||
usb_seremu_class Serial; | usb_seremu_class Serial; | ||||
#endif | #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 |
* SOFTWARE. | * SOFTWARE. | ||||
*/ | */ | ||||
#if F_CPU >= 20000000 | |||||
#include "mk20dx128.h" | #include "mk20dx128.h" | ||||
//#include "HardwareSerial.h" | //#include "HardwareSerial.h" | ||||
#include "usb_dev.h" | #include "usb_dev.h" | ||||
//serial_print("\n"); | //serial_print("\n"); | ||||
} | } | ||||
#endif // F_CPU >= 20 MHz |
* SOFTWARE. | * SOFTWARE. | ||||
*/ | */ | ||||
#if F_CPU >= 20000000 | |||||
//#include "mk20dx128.h" | //#include "mk20dx128.h" | ||||
#include "usb_dev.h" | #include "usb_dev.h" | ||||
#include "usb_seremu.h" | #include "usb_seremu.h" | ||||
} | } | ||||
#endif // SEREMU_INTERFACE | #endif // SEREMU_INTERFACE | ||||
#endif // F_CPU >= 20 MHz |
#include <inttypes.h> | #include <inttypes.h> | ||||
#if F_CPU >= 20000000 | |||||
// C language implementation | // C language implementation | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
extern "C" { | extern "C" { | ||||
} | } | ||||
#endif | #endif | ||||
// C++ interface | // C++ interface | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
#include "Stream.h" | #include "Stream.h" | ||||
uint8_t rts(void) { return 1; } | uint8_t rts(void) { return 1; } | ||||
operator bool() { return usb_configuration; } | operator bool() { return usb_configuration; } | ||||
}; | }; | ||||
extern usb_seremu_class Serial; | 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 // __cplusplus | ||||
#endif // F_CPU >= 20 MHz | |||||
#endif // USB_HID | #endif // USB_HID | ||||
#endif // USBseremu_h_ | #endif // USBseremu_h_ |
#include <inttypes.h> | #include <inttypes.h> | ||||
#if F_CPU >= 20000000 | |||||
// C language implementation | // C language implementation | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
extern "C" { | extern "C" { | ||||
#define USB_SERIAL_DTR 0x01 | #define USB_SERIAL_DTR 0x01 | ||||
#define USB_SERIAL_RTS 0x02 | #define USB_SERIAL_RTS 0x02 | ||||
// C++ interface | // C++ interface | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
#include "Stream.h" | #include "Stream.h" | ||||
} | } | ||||
}; | }; | ||||
extern usb_serial_class Serial; | 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 // __cplusplus | ||||
#endif // F_CPU | |||||
#endif // USB_SERIAL || USB_SERIAL_HID | #endif // USB_SERIAL || USB_SERIAL_HID | ||||
#endif // USBserial_h_ | #endif // USBserial_h_ |