diff options
-rw-r--r-- | bootloaders/diskloader/src/CDC.cpp | 77 | ||||
-rw-r--r-- | bootloaders/diskloader/src/Platform.h | 4 | ||||
-rw-r--r-- | bootloaders/diskloader/src/USBAPI.h | 21 | ||||
-rw-r--r-- | bootloaders/diskloader/src/USBCore.cpp | 19 | ||||
-rw-r--r-- | bootloaders/diskloader/src/USBCore.h | 49 | ||||
-rw-r--r-- | bootloaders/diskloader/src/USBDesc.h | 22 |
6 files changed, 2 insertions, 190 deletions
diff --git a/bootloaders/diskloader/src/CDC.cpp b/bootloaders/diskloader/src/CDC.cpp index cc798b4..a542d3c 100644 --- a/bootloaders/diskloader/src/CDC.cpp +++ b/bootloaders/diskloader/src/CDC.cpp @@ -23,13 +23,6 @@ #if defined(USBCON) #ifdef CDC_ENABLED -void Reboot() -{ - USB.detach(); - cli(); - asm volatile("jmp 0x7800"); // jump to bootloader - DiskLoader takes up last 2 kB -} - typedef struct { u32 dwDTERate; @@ -92,8 +85,6 @@ bool WEAK CDC_Setup(Setup& setup) if (CDC_SET_CONTROL_LINE_STATE == r) { -// if (0 != _usbLineInfo.lineState && 1200 == _usbLineInfo.dwDTERate) // auto-reset is triggered when the port, already open at 1200 bps, is closed -// Reboot(); _usbLineInfo.lineState = setup.wValueL; return true; } @@ -101,73 +92,5 @@ bool WEAK CDC_Setup(Setup& setup) return false; } -/* -int _serialPeek = -1; -void Serial_::begin(uint16_t baud_count) -{ -} - -void Serial_::end(void) -{ -} - -int Serial_::available(void) -{ - u8 avail = USB_Available(CDC_RX); - if (_serialPeek != -1) - avail++; - return avail; -} - -// peek is nasty -int Serial_::peek(void) -{ - if (_serialPeek == -1) - _serialPeek = read(); - return _serialPeek; -} - -int Serial_::read(void) -{ - int c; - if (_serialPeek != -1) - { - c = _serialPeek; - _serialPeek = -1; - } else { - c = USB_Recv(CDC_RX); - } - return c; -} - - - -void Serial_::flush(void) -{ - USB_Flush(CDC_TX); -} - -size_t Serial_::write(uint8_t c) -{ - - // TODO - ZE - check behavior on different OSes and test what happens if an - // open connection isn't broken cleanly (cable is yanked out, host dies - // or locks up, or host virtual serial port hangs) - if (_usbLineInfo.lineState > 0) { - int r = USB_Send(CDC_TX,&c,1); - if (r > 0) { - return r; - } else { -// setWriteError(); - return 0; - } - } -// setWriteError(); - return 0; -} - -Serial_ Serial; -*/ - #endif #endif /* if defined(USBCON) */
\ No newline at end of file diff --git a/bootloaders/diskloader/src/Platform.h b/bootloaders/diskloader/src/Platform.h index 4b58f9f..9416c47 100644 --- a/bootloaders/diskloader/src/Platform.h +++ b/bootloaders/diskloader/src/Platform.h @@ -32,10 +32,6 @@ typedef unsigned long u32; #define USB_VID 0x2341 // arduino LLC vid #define USB_PID ARDUINO_MODEL_PID // passed in by Makefile - 0x0034 for Leonardo, 0x0035 for MIcro -//#include "USBDesc.h" -//#include "../../../cores/arduino/USBCore.h" - - #define min(a,b) ((a)<(b)?(a):(b)) #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) diff --git a/bootloaders/diskloader/src/USBAPI.h b/bootloaders/diskloader/src/USBAPI.h index 1724ce1..f8d71c8 100644 --- a/bootloaders/diskloader/src/USBAPI.h +++ b/bootloaders/diskloader/src/USBAPI.h @@ -23,24 +23,6 @@ extern USB_ USB; //================================================================================ //================================================================================ -// Serial over CDC (Serial1 is the physical port) - -class Serial_ -{ -public: - void begin(uint16_t baud_count); - void end(void); - - virtual int available(void); - virtual int peek(void); - virtual int read(void); - virtual void flush(void); - virtual size_t write(uint8_t); -}; -extern Serial_ Serial; - -//================================================================================ -//================================================================================ // Low level API typedef struct @@ -79,5 +61,4 @@ int USB_Recv(uint8_t ep); // non-blocking void USB_Flush(uint8_t ep); #endif - -#endif /* if defined(USBCON) */
\ No newline at end of file +#endif /* if defined(USBCON) */ diff --git a/bootloaders/diskloader/src/USBCore.cpp b/bootloaders/diskloader/src/USBCore.cpp index 56944e5..4771181 100644 --- a/bootloaders/diskloader/src/USBCore.cpp +++ b/bootloaders/diskloader/src/USBCore.cpp @@ -1,5 +1,4 @@ - /* Copyright (c) 2010, Peter Barrett ** ** Permission to use, copy, modify, and/or distribute this software for @@ -219,7 +218,6 @@ u8 USB_Available(u8 ep) void USB_Recv_block(u8 ep, u8* dst, int len) { -// SetEP(ep & 7); LockEP lock(ep); while (len--) { @@ -277,16 +275,11 @@ int USB_Send(u8 ep, const void* d, int len) int r = len; const u8* data = (const u8*)d; -// u8 zero = ep & TRANSFER_ZERO; - u8 timeout = 250; // 250ms timeout on send? TODO while (len) { u8 n = USB_SendSpace(ep); if (n == 0) { -// if (!(--timeout)) -// return -1; -// delay(1); _delay_ms(1); continue; } @@ -333,10 +326,6 @@ const u8 _initEndpoints[] = EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN #endif - -#ifdef HID_ENABLED - EP_TYPE_INTERRUPT_IN // HID_ENDPOINT_INT -#endif }; #define EP_SINGLE_64 0x32 // EP0 @@ -469,10 +458,6 @@ bool SendDescriptor(Setup& setup) return SendConfiguration(setup.wLength); InitControl(setup.wLength); -#ifdef HID_ENABLED - if (HID_REPORT_DESCRIPTOR_TYPE == t) - return HID_GetDescriptor(t); -#endif u8 desc_length = 0; const u8* desc_addr = 0; @@ -607,9 +592,7 @@ ISR(USB_GEN_vect) // Start of Frame - happens every millisecond so we use it for TX and RX LED one-shot timing, too if (udint & (1<<SOFI)) { -//#ifdef CDC_ENABLED USB_Flush(CDC_TX); // Send a tx frame if found -//#endif // check whether the one-shot period has elapsed. if so, turn off the LED if (TxLEDPulse && !(--TxLEDPulse)) @@ -666,4 +649,4 @@ void USB_::poll() { } -#endif /* if defined(USBCON) */
\ No newline at end of file +#endif /* if defined(USBCON) */ diff --git a/bootloaders/diskloader/src/USBCore.h b/bootloaders/diskloader/src/USBCore.h index 8d13806..511b57c 100644 --- a/bootloaders/diskloader/src/USBCore.h +++ b/bootloaders/diskloader/src/USBCore.h @@ -56,16 +56,6 @@ #define CDC_GET_LINE_CODING 0x21 #define CDC_SET_CONTROL_LINE_STATE 0x22 -#define MSC_RESET 0xFF -#define MSC_GET_MAX_LUN 0xFE - -#define HID_GET_REPORT 0x01 -#define HID_GET_IDLE 0x02 -#define HID_GET_PROTOCOL 0x03 -#define HID_SET_REPORT 0x09 -#define HID_SET_IDLE 0x0A -#define HID_SET_PROTOCOL 0x0B - // Descriptors #define USB_DEVICE_DESC_SIZE 18 @@ -117,14 +107,6 @@ #define CDC_CS_ENDPOINT 0x25 #define CDC_DATA_INTERFACE_CLASS 0x0A -#define MSC_SUBCLASS_SCSI 0x06 -#define MSC_PROTOCOL_BULK_ONLY 0x50 - -#define HID_HID_DESCRIPTOR_TYPE 0x21 -#define HID_REPORT_DESCRIPTOR_TYPE 0x22 -#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23 - - // Device typedef struct { u8 len; // 18 @@ -250,34 +232,6 @@ typedef struct EndpointDescriptor out; } CDCDescriptor; -typedef struct -{ - InterfaceDescriptor msc; - EndpointDescriptor in; - EndpointDescriptor out; -} MSCDescriptor; - -typedef struct -{ - u8 len; // 9 - u8 dtype; // 0x21 - u8 addr; - u8 versionL; // 0x101 - u8 versionH; // 0x101 - u8 country; - u8 desctype; // 0x22 report - u8 descLenL; - u8 descLenH; -} HIDDescDescriptor; - -typedef struct -{ - InterfaceDescriptor hid; - HIDDescDescriptor desc; - EndpointDescriptor in; -} HIDDescriptor; - - #define D_DEVICE(_class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs) \ { 18, 1, 0x200, _class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs } @@ -293,9 +247,6 @@ typedef struct #define D_IAD(_firstInterface, _count, _class, _subClass, _protocol) \ { 8, 11, _firstInterface, _count, _class, _subClass, _protocol, 0 } -#define D_HIDREPORT(_descriptorLength) \ - { 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, 0 } - #define D_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 } #define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 } diff --git a/bootloaders/diskloader/src/USBDesc.h b/bootloaders/diskloader/src/USBDesc.h index a3f1b0f..997ff61 100644 --- a/bootloaders/diskloader/src/USBDesc.h +++ b/bootloaders/diskloader/src/USBDesc.h @@ -26,14 +26,6 @@ #define CDC_ENPOINT_COUNT 0 #endif -#ifdef HID_ENABLED -#define HID_INTERFACE_COUNT 1 -#define HID_ENPOINT_COUNT 1 -#else -#define HID_INTERFACE_COUNT 0 -#define HID_ENPOINT_COUNT 0 -#endif - #define CDC_ACM_INTERFACE 0 // CDC ACM #define CDC_DATA_INTERFACE 1 // CDC Data #define CDC_FIRST_ENDPOINT 1 @@ -41,25 +33,11 @@ #define CDC_ENDPOINT_OUT (CDC_FIRST_ENDPOINT+1) #define CDC_ENDPOINT_IN (CDC_FIRST_ENDPOINT+2) -#define HID_INTERFACE (CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT) // HID Interface -#define HID_FIRST_ENDPOINT (CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT) -#define HID_ENDPOINT_INT (HID_FIRST_ENDPOINT) - -#define INTERFACE_COUNT (MSC_INTERFACE + MSC_INTERFACE_COUNT) - #ifdef CDC_ENABLED #define CDC_RX CDC_ENDPOINT_OUT #define CDC_TX CDC_ENDPOINT_IN #endif -#ifdef HID_ENABLED -#define HID_TX HID_ENDPOINT_INT -#endif - #define IMANUFACTURER 1 #define IPRODUCT 2 -#define USB_PID_LEONARDO 0x0034 -#define USB_PID_MICRO 0x0035 -#define USB_VID 0x2341 // arduino LLC vid -//#define USB_PID ARDUINO_MODEL_USB_PID |