removed old comments and unused USB core code

This commit is contained in:
Zach Eveland 2011-10-27 10:45:13 -04:00
parent 3d848a5b9a
commit 9dc9e60704
6 changed files with 2 additions and 190 deletions

View File

@ -23,13 +23,6 @@
#if defined(USBCON) #if defined(USBCON)
#ifdef CDC_ENABLED #ifdef CDC_ENABLED
void Reboot()
{
USB.detach();
cli();
asm volatile("jmp 0x7800"); // jump to bootloader - DiskLoader takes up last 2 kB
}
typedef struct typedef struct
{ {
u32 dwDTERate; u32 dwDTERate;
@ -92,8 +85,6 @@ bool WEAK CDC_Setup(Setup& setup)
if (CDC_SET_CONTROL_LINE_STATE == r) 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; _usbLineInfo.lineState = setup.wValueL;
return true; return true;
} }
@ -101,73 +92,5 @@ bool WEAK CDC_Setup(Setup& setup)
return false; 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
#endif /* if defined(USBCON) */ #endif /* if defined(USBCON) */

View File

@ -32,10 +32,6 @@ typedef unsigned long u32;
#define USB_VID 0x2341 // arduino LLC vid #define USB_VID 0x2341 // arduino LLC vid
#define USB_PID ARDUINO_MODEL_PID // passed in by Makefile - 0x0034 for Leonardo, 0x0035 for MIcro #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 min(a,b) ((a)<(b)?(a):(b))
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))

View File

@ -21,24 +21,6 @@ public:
}; };
extern USB_ USB; 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 // Low level API
@ -79,5 +61,4 @@ int USB_Recv(uint8_t ep); // non-blocking
void USB_Flush(uint8_t ep); void USB_Flush(uint8_t ep);
#endif #endif
#endif /* if defined(USBCON) */ #endif /* if defined(USBCON) */

View File

@ -1,5 +1,4 @@
/* Copyright (c) 2010, Peter Barrett /* Copyright (c) 2010, Peter Barrett
** **
** Permission to use, copy, modify, and/or distribute this software for ** 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) void USB_Recv_block(u8 ep, u8* dst, int len)
{ {
// SetEP(ep & 7);
LockEP lock(ep); LockEP lock(ep);
while (len--) while (len--)
{ {
@ -277,16 +275,11 @@ int USB_Send(u8 ep, const void* d, int len)
int r = len; int r = len;
const u8* data = (const u8*)d; const u8* data = (const u8*)d;
// u8 zero = ep & TRANSFER_ZERO;
u8 timeout = 250; // 250ms timeout on send? TODO
while (len) while (len)
{ {
u8 n = USB_SendSpace(ep); u8 n = USB_SendSpace(ep);
if (n == 0) if (n == 0)
{ {
// if (!(--timeout))
// return -1;
// delay(1);
_delay_ms(1); _delay_ms(1);
continue; continue;
} }
@ -333,10 +326,6 @@ const u8 _initEndpoints[] =
EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT
EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN
#endif #endif
#ifdef HID_ENABLED
EP_TYPE_INTERRUPT_IN // HID_ENDPOINT_INT
#endif
}; };
#define EP_SINGLE_64 0x32 // EP0 #define EP_SINGLE_64 0x32 // EP0
@ -469,10 +458,6 @@ bool SendDescriptor(Setup& setup)
return SendConfiguration(setup.wLength); return SendConfiguration(setup.wLength);
InitControl(setup.wLength); InitControl(setup.wLength);
#ifdef HID_ENABLED
if (HID_REPORT_DESCRIPTOR_TYPE == t)
return HID_GetDescriptor(t);
#endif
u8 desc_length = 0; u8 desc_length = 0;
const u8* desc_addr = 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 // Start of Frame - happens every millisecond so we use it for TX and RX LED one-shot timing, too
if (udint & (1<<SOFI)) if (udint & (1<<SOFI))
{ {
//#ifdef CDC_ENABLED
USB_Flush(CDC_TX); // Send a tx frame if found 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 // check whether the one-shot period has elapsed. if so, turn off the LED
if (TxLEDPulse && !(--TxLEDPulse)) if (TxLEDPulse && !(--TxLEDPulse))

View File

@ -56,16 +56,6 @@
#define CDC_GET_LINE_CODING 0x21 #define CDC_GET_LINE_CODING 0x21
#define CDC_SET_CONTROL_LINE_STATE 0x22 #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 // Descriptors
#define USB_DEVICE_DESC_SIZE 18 #define USB_DEVICE_DESC_SIZE 18
@ -117,14 +107,6 @@
#define CDC_CS_ENDPOINT 0x25 #define CDC_CS_ENDPOINT 0x25
#define CDC_DATA_INTERFACE_CLASS 0x0A #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 // Device
typedef struct { typedef struct {
u8 len; // 18 u8 len; // 18
@ -250,34 +232,6 @@ typedef struct
EndpointDescriptor out; EndpointDescriptor out;
} CDCDescriptor; } 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) \ #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 } { 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) \ #define D_IAD(_firstInterface, _count, _class, _subClass, _protocol) \
{ 8, 11, _firstInterface, _count, _class, _subClass, _protocol, 0 } { 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_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 }
#define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 } #define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 }

View File

@ -26,14 +26,6 @@
#define CDC_ENPOINT_COUNT 0 #define CDC_ENPOINT_COUNT 0
#endif #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_ACM_INTERFACE 0 // CDC ACM
#define CDC_DATA_INTERFACE 1 // CDC Data #define CDC_DATA_INTERFACE 1 // CDC Data
#define CDC_FIRST_ENDPOINT 1 #define CDC_FIRST_ENDPOINT 1
@ -41,25 +33,11 @@
#define CDC_ENDPOINT_OUT (CDC_FIRST_ENDPOINT+1) #define CDC_ENDPOINT_OUT (CDC_FIRST_ENDPOINT+1)
#define CDC_ENDPOINT_IN (CDC_FIRST_ENDPOINT+2) #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 #ifdef CDC_ENABLED
#define CDC_RX CDC_ENDPOINT_OUT #define CDC_RX CDC_ENDPOINT_OUT
#define CDC_TX CDC_ENDPOINT_IN #define CDC_TX CDC_ENDPOINT_IN
#endif #endif
#ifdef HID_ENABLED
#define HID_TX HID_ENDPOINT_INT
#endif
#define IMANUFACTURER 1 #define IMANUFACTURER 1
#define IPRODUCT 2 #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