aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootloaders/diskloader/DiskLoader.hex209
-rw-r--r--bootloaders/diskloader/src/DiskLoader.cpp8
-rw-r--r--bootloaders/diskloader/src/Platform.h2
-rw-r--r--bootloaders/diskloader/src/USBCore.cpp4
-rw-r--r--bootloaders/diskloader/src/USBDesc.cpp19
-rw-r--r--bootloaders/diskloader/src/USBDesc.h8
-rw-r--r--cores/arduino/USBCore.cpp87
-rw-r--r--cores/arduino/USBDesc.h37
-rw-r--r--variants/leonardo/pins_arduino.h5
9 files changed, 194 insertions, 185 deletions
diff --git a/bootloaders/diskloader/DiskLoader.hex b/bootloaders/diskloader/DiskLoader.hex
index 3a7ab54..ce0ec5e 100644
--- a/bootloaders/diskloader/DiskLoader.hex
+++ b/bootloaders/diskloader/DiskLoader.hex
@@ -1,106 +1,113 @@
-:1078000011241FBECFEFDAE0DEBFCDBFC5C04101FE
+:1078000011241FBECFEFDAE0DEBFCDBFF2C04101D1
:1078100042144505560455026403740300001E9586
:1078200087020110030000C18081C106C0FF0A0069
:107830000CA10185037508150026FF00954009017C
-:107840008102954009029102C0040309041201005B
-:107850000202000040412334000001000001011237
-:10786000010002000000404123340000010000013B
-:1078700001090264000301008032080B00020202C9
-:1078800001000904000001020200000524001001AB
-:107890000524010101042402020524060001070554
-:1078A000810310004009040100020A0000000705DE
-:1078B00002024000000705830240000009040200A4
-:1078C0000103000000092101010001221E0007053B
-:1078D00084034000400020918A0130918B012F5F8A
-:1078E0003F4F30938B0120938A01832F9927982F44
-:1078F00087FD9095990F921710F447980895479A2D
-:107900000895769A289A81E08093E0001092E20030
-:10791000EE27FF27099408950F931F93CF93DF93CA
-:10792000982FEB01042F10E088E76030780730F4DF
-:1079300011E083E0FB0180935700E895892F68E010
-:1079400071E0402FF8D0112311F107B600FCFDCFF4
-:10795000402F4695FE01A8E0B1E020E031E009C0EB
-:107960008D919D910C0130935700E895112432962A
-:107970002F5F2417A8F385E0FE0180935700E89558
-:1079800007B600FCFDCF81E180935700E895DF91B9
-:10799000CF911F910F91089588E10FB6F8948093CD
-:1079A0006000109260000FBE769A289A47983F9A1E
-:1079B000209A6E9A90E8909361001092610081E89D
-:1079C00085BF95BF9FD084E18093880180E180933B
-:1079D0008901E0E0F0E0859194918F5F9F4F19F06D
-:1079E00081E080938F01EE24FF24BB24B39424EF25
-:1079F000C22E21E0D22E03D2082F8EE098E7FC01A0
-:107A00002491319602964491201711F02223B9F760
-:107A1000109291011092900182E068E071E08BD0A9
-:107A2000013479F4609108016058633028F06831BE
-:107A300011F064E001C063E0C62FD0E0CF5DD7480D
-:107A40000EC0063571F480910801803311F011E009
-:107A500022C080910A01C82FD0E0C25ED74811E051
-:107A600022C0053721F413E0CEE1D8E71CC005356C
-:107A700039F4E0900801F0900901EE0CFF1C0AC0F7
-:107A8000043631F482E0B7014091090145DF02C0BC
-:107A9000043721F010E0C5E2D8E705C010910901D4
-:107AA000E701E10EF11CABD18097B1F483E068E807
-:107AB00071E041E050E059D0112329F0412F50E00E
-:107AC00083E8BE0152D083E469E871E041E050E010
-:107AD0004CD0013509F08FCFD0929101C092900126
-:107AE000B0928F01EE24FF2486CFFC01289884E613
-:107AF00080938D0104C08091F100819361506623D1
-:107B0000D1F70895109291011092900110928E0178
-:107B100010928F0181E08093D70080EA8093D80093
-:107B200082E189BD09B400FEFDCF80E98093D800D1
-:107B30001092E0000895FB018093E90024E69BE6A3
-:107B400011C08091E80085FFFCCF289820938D011B
-:107B50008091F10081938091E80085FD02C09093AF
-:107B6000E8004150442369F70895982FFB01282F1E
-:107B7000207287708093E90064E63AE317C0809131
-:107B8000E80085FFFCCF97FF02C0849101C080818F
-:107B90003196211180E0769860938C018093F100FA
-:107BA0008091E80085FD02C03093E80041505040CC
-:107BB0008FEF4F3F580719F796FF03C08AE3809372
-:107BC000E800089580919301813299F4769884E6D3
-:107BD00080938C0120E030E003C080818093F1002D
-:107BE000F901E050FF4F2F5F3F4F28303105A9F7D3
-:107BF00014C0803261F48091E80082FFFCCF80E005
-:107C000091E067E072DF8BEF8093E80006C082327C
-:107C100021F4809194018093070181E008952091DF
-:107C20009501223209F1213081F4809198019091DF
-:107C30009901089711F420939A0180919A01882361
-:107C400009F03FC0EFE5F8E73EC0223021F484E6BA
-:107C5000E1E7F8E70CC0233091F580919401882387
-:107C600071F5E9E4F8E72FC081E0EBE2F8E79091E5
-:107C70009801382F981708F4392F90918C0120E043
-:107C80004EEF8091E8008570E1F38091E80082FD7D
-:107C900012C02F5F849176988093F100822F8F73AA
-:107CA00011F44093E800319694E6231750F3909333
-:107CB0008C0181E0089590938C0180E0089580E02C
-:107CC0000895EDE4F8E78491D2CF1092E900809115
-:107CD000E80083FF61C082E991E068E006DF82EF9F
-:107CE0008093E8008091920187FF05C08091E800B1
-:107CF00080FFFCCF03C08EEF8093E800809193015A
-:107D0000853051F48091E80080FFFCCF8091940190
-:107D100080688093E30039C08930E1F48091940158
-:107D200080938E01E7E2F8E791E031E026E390935B
-:107D3000E9003093EB0084918093EC002093ED00F8
-:107D40009F5F3196953099F78EE78093EA00109205
-:107D5000EA001BC0883049F490918E01769884E641
-:107D600080938C019093F10010C0882339F47698A9
-:107D700084E680938C011092F10007C0863011F4E4
-:107D80004EDF01C01FDF882321F08EEF8093E800D3
-:107D9000089581E28093EB0008958091E1001092B4
-:107DA000E100282F83FF0CC01092E90081E080934E
-:107DB000EB001092EC0082E38093ED0010928E01B4
-:107DC00022FF1CC080918C01882331F08150809368
-:107DD0008C01882309F4769A80918D01882331F0F3
-:107DE000815080938D01882309F4289A80918F0116
-:107DF000882321F4109291011092900108951F930D
-:107E0000CF93DF9312E0C0E9D1E05FDFC6DF1093CC
-:107E1000E9008091E80085FF13C0289884E68093EC
-:107E20008D019091F1008091E80085FD03C08BE603
-:107E30008093E800892F90E0DF91CF911F91089502
-:107E4000809190019091910101979093910180937D
-:107E500090018091900190919101892B09F451DD5D
-:0A7E6000CE010197F1F737DDD0CF16
-:087E6A0000E10000000000002F
+:107840008102954009029102C004030904380341F2
+:107850000072006400750069006E006F0020004C2B
+:107860000065006F006E006100720064006F002010
+:107870000062006F006F0074006C006F00610064B4
+:107880000065007200180341007200640075006911
+:10789000006E006F0020004C004C004300120100FD
+:1078A00002020000404123340000010102000112E5
+:1078B00001000200000040412334000001010200E9
+:1078C00001090264000301008032080B0002020279
+:1078D000010009040000010202000005240010015B
+:1078E0000524010101042402020524060001070504
+:1078F000810310004009040100020A00000007058E
+:107900000202400000070583024000000904020053
+:107910000103000000092101010001221E000705EA
+:1079200084034000400020918A0130918B012C5F3C
+:107930003F4F30938B0120938A01C901892F9927EA
+:107940008695982F803418F08FE7891B982F990F10
+:10795000921710F447980895479A0895769A289AAE
+:1079600081E08093E0001092E200EE27FF27099467
+:1079700008950F931F93CF93DF93982FEB01042F5C
+:1079800010E088E76030780730F411E083E0FB0115
+:1079900080935700E895892F68E071E0402FF8D078
+:1079A000112311F107B600FCFDCF402F4695FE01D3
+:1079B000A8E0B1E020E031E009C08D919D910C017B
+:1079C00030935700E895112432962F5F2417A8F3BF
+:1079D00085E0FE0180935700E89507B600FCFDCFD7
+:1079E00081E180935700E895DF91CF911F910F912E
+:1079F000089588E10FB6F8948093600010926000BB
+:107A00000FBE769A289A47983F9A209A6E9A90E8E5
+:107A1000909361001092610081E885BF95BF9FD06F
+:107A200084E18093880180E180938901E0E0F0E0C7
+:107A3000859194918F5F9F4F19F081E080938F0122
+:107A4000EE24FF24BB24B39454EFC52E51E0D52E71
+:107A50000ED2082F8EE098E7FC0124913196029611
+:107A60004491201711F02223B9F71092910110923E
+:107A7000900182E068E071E08BD0013479F460918C
+:107A800008016058633028F0683111F064E001C0EB
+:107A900063E0C62FD0E0CF5DD7480EC0063571F445
+:107AA00080910801803311F011E022C080910A0119
+:107AB000C82FD0E0C25ED74811E022C0053721F4BC
+:107AC00013E0CEE1D8E71CC0053539F4E090080199
+:107AD000F0900901EE0CFF1C0AC0043631F482E07C
+:107AE000B7014091090145DF02C0043721F010E0E1
+:107AF000C5E2D8E705C010910901E701E10EF11CCC
+:107B0000B6D18097B1F483E068E871E041E050E0DD
+:107B100059D0112329F0412F50E083E8BE0152D003
+:107B200083E469E871E041E050E04CD0013509F0B0
+:107B30008FCFD0929101C0929001B0928F01EE242C
+:107B4000FF2486CFFC01289884E680938D0104C031
+:107B50008091F100819361506623D1F708951092CE
+:107B600091011092900110928E0110928F0181E08C
+:107B70008093D70080EA8093D80082E189BD09B460
+:107B800000FEFDCF80E98093D8001092E0000895B8
+:107B9000FB018093E90024E69BE611C08091E80098
+:107BA00085FFFCCF289820938D018091F10081936F
+:107BB0008091E80085FD02C09093E8004150442385
+:107BC00069F70895982FFB01282F20728770809302
+:107BD000E90064E63AE317C08091E80085FFFCCF36
+:107BE00097FF02C0849101C080813196211180E00D
+:107BF000769860938C018093F1008091E80085FD78
+:107C000002C03093E800415050408FEF4F3F58077B
+:107C100019F796FF03C08AE38093E80008958091E6
+:107C20009301813299F4769884E680938C0120E068
+:107C300030E003C080818093F100F901E050FF4FF4
+:107C40002F5F3F4F28303105A9F714C0803261F40F
+:107C50008091E80082FFFCCF80E091E067E072DF76
+:107C60008BEF8093E80006C0823221F4809194016A
+:107C70008093070181E0089520919501223261F1FE
+:107C8000213081F48091980190919901089711F425
+:107C900020939A0180919A01882309F04AC0EFEA63
+:107CA000F8E749C0223021F484E6E1ECF8E717C098
+:107CB000233009F03CC080919401882319F4E9E451
+:107CC000F8E739C0823019F4EDE4F8E734C08130C8
+:107CD00071F5E5E8F8E72FC081E0EBE2F8E7909175
+:107CE0009801382F981708F4392F90918C0120E0D3
+:107CF0004EEF8091E8008570E1F38091E80082FD0D
+:107D000012C02F5F849176988093F100822F8F7339
+:107D100011F44093E800319694E6231750F39093C2
+:107D20008C0181E0089590938C0180E0089580E0BB
+:107D30000895EDE9F8E78491D2CF1092E90080919F
+:107D4000E80083FF61C082E991E068E0FBDE82EF3A
+:107D50008093E8008091920187FF05C08091E80040
+:107D600080FFFCCF03C08EEF8093E80080919301E9
+:107D7000853051F48091E80080FFFCCF8091940120
+:107D800080688093E30039C08930E1F480919401E8
+:107D900080938E01E7E2F8E791E031E026E39093EB
+:107DA000E9003093EB0084918093EC002093ED0088
+:107DB0009F5F3196953099F78EE78093EA00109295
+:107DC000EA001BC0883049F490918E01769884E6D1
+:107DD00080938C019093F10010C0882339F4769839
+:107DE00084E680938C011092F10007C0863011F474
+:107DF00043DF01C014DF882321F08EEF8093E80079
+:107E0000089581E28093EB0008958091E100109243
+:107E1000E100282F83FF0CC01092E90081E08093DD
+:107E2000EB001092EC0082E38093ED0010928E0143
+:107E300022FF1CC080918C01882331F081508093F7
+:107E40008C01882309F4769A80918D01882331F082
+:107E5000815080938D01882309F4289A80918F01A5
+:107E6000882321F4109291011092900108951F939C
+:107E7000CF93DF9312E0C0E9D1E05FDFC6DF10935C
+:107E8000E9008091E80085FF13C0289884E680937C
+:107E90008D019091F1008091E80085FD03C08BE693
+:107EA0008093E800892F90E0DF91CF911F91089592
+:107EB000809190019091910101979093910180930D
+:107EC00090018091900190919101892B09F446DDF8
+:0A7ED000CE010197F1F727DDD0CFB6
+:087EDA0000E1000000000000BF
:040000030000780081
:00000001FF
diff --git a/bootloaders/diskloader/src/DiskLoader.cpp b/bootloaders/diskloader/src/DiskLoader.cpp
index f854fd1..1771d02 100644
--- a/bootloaders/diskloader/src/DiskLoader.cpp
+++ b/bootloaders/diskloader/src/DiskLoader.cpp
@@ -220,10 +220,10 @@ int main()
u16 _pulse;
void LEDPulse()
{
- _pulse++;
- u8 p = _pulse >> 8;
- if (p > 127)
- p = 255-p;
+ _pulse += 4;
+ u8 p = _pulse >> 9;
+ if (p > 63)
+ p = 127-p;
p += p;
if (((u8)_pulse) > p)
LED0;
diff --git a/bootloaders/diskloader/src/Platform.h b/bootloaders/diskloader/src/Platform.h
index 2b00b71..471bc90 100644
--- a/bootloaders/diskloader/src/Platform.h
+++ b/bootloaders/diskloader/src/Platform.h
@@ -19,6 +19,8 @@ typedef unsigned long u32;
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
#define DISABLE_JTAG() MCUCR = (1 << JTD) | (1 << IVCE) | (0 << PUD); MCUCR = (1 << JTD) | (0 << IVSEL) | (0 << IVCE) | (0 << PUD);
+#define USB_PID_LEONARDO 0x0034
+#define USB_PID_MICRO 0x0035
#define USB_VID 0x2341 // arduino LLC vid
#define USB_PID ARDUINO_MODEL_PID // passed in by Makefile - 0x0034 for Leonardo, 0x0035 for MIcro
diff --git a/bootloaders/diskloader/src/USBCore.cpp b/bootloaders/diskloader/src/USBCore.cpp
index 1a8f2d0..ca74721 100644
--- a/bootloaders/diskloader/src/USBCore.cpp
+++ b/bootloaders/diskloader/src/USBCore.cpp
@@ -374,6 +374,10 @@ bool SendDescriptor()
{
if (setup.wValueL == 0)
desc_addr = (const u8*)&STRING_LANGUAGE;
+ else if (setup.wValueL == IPRODUCT)
+ desc_addr = (const u8*)&STRING_IPRODUCT;
+ else if (setup.wValueL == IMANUFACTURER)
+ desc_addr = (const u8*)&STRING_IMANUFACTURER;
else
return false;
} else
diff --git a/bootloaders/diskloader/src/USBDesc.cpp b/bootloaders/diskloader/src/USBDesc.cpp
index ec7cf7d..c8ea9c6 100644
--- a/bootloaders/diskloader/src/USBDesc.cpp
+++ b/bootloaders/diskloader/src/USBDesc.cpp
@@ -28,10 +28,25 @@ const u16 STRING_LANGUAGE[2] = {
};
+const u16 STRING_IPRODUCT[28] = {
+ (3<<8) | (2+2*27),
+#if USB_PID == USB_PID_LEONARDO
+ 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o',' ','b','o','o','t','l','o','a','d','e','r'
+#elif USB_PID == USB_PID_MICRO
+ 'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ','b','o','o','t','l','o','a','d','e','r',' ',' ',' '
+#endif
+};
+
+const u16 STRING_IMANUFACTURER[12] = {
+ (3<<8) | (2+2*11),
+ 'A','r','d','u','i','n','o',' ','L','L','C'
+};
+
+
//#ifdef CDC_ENABLED
-DeviceDescriptor USB_DeviceDescriptorA = D_DEVICE(0X02,0X00,0X00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1);
+DeviceDescriptor USB_DeviceDescriptorA = D_DEVICE(0X02,0X00,0X00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
//#else
-DeviceDescriptor USB_DeviceDescriptor = D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1);
+DeviceDescriptor USB_DeviceDescriptor = D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
//#endif
Config USB_ConfigDescriptor =
diff --git a/bootloaders/diskloader/src/USBDesc.h b/bootloaders/diskloader/src/USBDesc.h
index 589dfa9..094dba5 100644
--- a/bootloaders/diskloader/src/USBDesc.h
+++ b/bootloaders/diskloader/src/USBDesc.h
@@ -53,11 +53,11 @@ extern DeviceDescriptor USB_DeviceDescriptor PROGMEM;
extern DeviceDescriptor USB_DeviceDescriptorA PROGMEM;
extern const u16 STRING_LANGUAGE[2] PROGMEM;
-extern const u16 STRING_SERIAL[13] PROGMEM;
+extern const u16 STRING_IPRODUCT[28] PROGMEM;
+extern const u16 STRING_IMANUFACTURER[12] PROGMEM;
-#define IMANUFACTURER 0
-#define IPRODUCT 0
-#define ISERIAL 1 // Only need this for MSC
+#define IMANUFACTURER 1
+#define IPRODUCT 2
#define CDC_TX CDC_ENDPOINT_IN
#define CDC_RX CDC_ENDPOINT_OUT \ No newline at end of file
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp
index 9ce2e00..398bc73 100644
--- a/cores/arduino/USBCore.cpp
+++ b/cores/arduino/USBCore.cpp
@@ -30,11 +30,17 @@
#define EP_TYPE_ISOCHRONOUS_IN 0x41
#define EP_TYPE_ISOCHRONOUS_OUT 0x40
+/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */
+#define TX_RX_LED_PULSE_MS 100
+volatile u8 TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */
+volatile u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */
+
//==================================================================
//==================================================================
extern const u16 STRING_LANGUAGE[] PROGMEM;
-extern const u16 STRING_SERIAL[] PROGMEM;
+extern const u16 STRING_IPRODUCT[] PROGMEM;
+extern const u16 STRING_IMANUFACTURER[] PROGMEM;
extern const DeviceDescriptor USB_DeviceDescriptor PROGMEM;
extern const DeviceDescriptor USB_DeviceDescriptorA PROGMEM;
@@ -43,16 +49,18 @@ const u16 STRING_LANGUAGE[2] = {
0x0409 // English
};
-#if 0
-const u16 STRING_PRODUCT[] = {
- (3<<8) | (2+2*10),
- PRODUCT_NAME
-};
+const u16 STRING_IPRODUCT[17] = {
+ (3<<8) | (2+2*16),
+#if USB_PID == USB_PID_LEONARDO
+ 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o'
+#elif USB_PID == USB_PID_MICRO
+ 'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ',' ',' '
#endif
+};
-const u16 STRING_SERIAL[13] = {
- (3<<8) | (2+2*12),
- MSC_DISK_SERIAL
+const u16 STRING_IMANUFACTURER[12] = {
+ (3<<8) | (2+2*11),
+ 'A','r','d','u','i','n','o',' ','L','L','C'
};
#ifdef CDC_ENABLED
@@ -63,10 +71,10 @@ const u16 STRING_SERIAL[13] = {
// DEVICE DESCRIPTOR
const DeviceDescriptor USB_DeviceDescriptor =
- D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1);
+ D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
const DeviceDescriptor USB_DeviceDescriptorA =
- D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1);
+ D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
//==================================================================
//==================================================================
@@ -105,11 +113,17 @@ void Recv(volatile u8* data, u8 count)
{
while (count--)
*data++ = UEDATX;
+
+ RXLED1; // light the RX LED
+ RxLEDPulse = TX_RX_LED_PULSE_MS;
}
static inline u8 Recv8()
{
- return UEDATX;
+ RXLED1; // light the RX LED
+ RxLEDPulse = TX_RX_LED_PULSE_MS;
+
+ return UEDATX;
}
static inline void Send8(u8 d)
@@ -203,13 +217,13 @@ u8 USB_Available(u8 ep)
return FifoByteCount();
}
-// Non Blocking recieve
+// Non Blocking receive
// Return number of bytes read
int USB_Recv(u8 ep, void* d, int len)
{
if (!_usbConfiguration || len < 0)
return -1;
-
+
LockEP lock(ep);
u8 n = FifoByteCount();
len = min(n,len);
@@ -219,7 +233,7 @@ int USB_Recv(u8 ep, void* d, int len)
*dst++ = Recv8();
if (len && !FifoByteCount()) // release empty buffer
ReleaseRX();
-
+
return len;
}
@@ -286,6 +300,8 @@ int USB_Send(u8 ep, const void* d, int len)
ReleaseTX();
}
}
+ TXLED1; // light the TX LED
+ TxLEDPulse = TX_RX_LED_PULSE_MS;
return r;
}
@@ -303,11 +319,6 @@ const u8 _initEndpoints[] =
#ifdef HID_ENABLED
EP_TYPE_INTERRUPT_IN // HID_ENDPOINT_INT
#endif
-
-#ifdef MSC_ENABLED
- EP_TYPE_BULK_OUT, // MSC_ENDPOINT_OUT
- EP_TYPE_BULK_IN, // MSC_ENDPOINT_IN
-#endif
};
#define EP_SINGLE_64 0x32 // EP0
@@ -347,11 +358,6 @@ bool ClassInterfaceRequest(Setup& setup)
return CDC_Setup(setup);
#endif
-#ifdef MSC_ENABLED
- if (MSC_INTERFACE == i)
- return MSC_Setup(setup);
-#endif
-
#ifdef HID_ENABLED
if (HID_INTERFACE == i)
return HID_Setup(setup);
@@ -422,9 +428,6 @@ int SendInterfaces()
total += HID_GetInterface(&interfaces);
#endif
-#ifdef MSC_ENABLED
- total += MSC_GetInterface(&interfaces);
-#endif
return interfaces;
}
@@ -473,8 +476,12 @@ bool SendDescriptor(Setup& setup)
{
if (setup.wValueL == 0)
desc_addr = (const u8*)&STRING_LANGUAGE;
- if (setup.wValueL == ISERIAL)
- desc_addr = (const u8*)&STRING_SERIAL;
+ else if (setup.wValueL == IPRODUCT)
+ desc_addr = (const u8*)&STRING_IPRODUCT;
+ else if (setup.wValueL == IMANUFACTURER)
+ desc_addr = (const u8*)&STRING_IMANUFACTURER;
+ else
+ return false;
}
if (desc_addr == 0)
@@ -497,8 +504,6 @@ ISR(USB_COM_vect)
Recv((u8*)&setup,8);
ClearSetupInt();
- //printHex((u8*)&setup,8);
-
u8 requestType = setup.bmRequestType;
if (requestType & REQUEST_DEVICETOHOST)
WaitIN();
@@ -589,12 +594,18 @@ ISR(USB_GEN_vect)
UEIENX = 1 << RXSTPE; // Enable interrupts for ep0
}
- // Start of Frame
+ // 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))
+ TXLED0;
+ if (RxLEDPulse && !(--RxLEDPulse))
+ RXLED0;
}
}
@@ -627,6 +638,8 @@ void USB_::attach()
USBCON = ((1<<USBE)|(1<<OTGPADE)); // start USB clock
UDIEN = (1<<EORSTE)|(1<<SOFE); // Enable interrupts for EOR (End of Reset) and SOF (start of frame)
UDCON = 0; // enable attach resistor
+
+ TX_RX_LED_INIT;
}
void USB_::detach()
@@ -642,14 +655,6 @@ bool USB_::configured()
void USB_::poll()
{
-#ifdef MSC_ENABLED
- if (!_usbConfiguration)
- return;
-
- // Service disk
- if (USB_Available(MSC_RX))
- MSC_Data(MSC_RX,MSC_TX);
-#endif
}
#endif /* if defined(USBCON) */ \ No newline at end of file
diff --git a/cores/arduino/USBDesc.h b/cores/arduino/USBDesc.h
index 7d767d1..549ed9e 100644
--- a/cores/arduino/USBDesc.h
+++ b/cores/arduino/USBDesc.h
@@ -18,7 +18,6 @@
#define CDC_ENABLED
#define HID_ENABLED
-//#define MSC_ENABLED
#ifdef CDC_ENABLED
@@ -37,14 +36,6 @@
#define HID_ENPOINT_COUNT 0
#endif
-#ifdef MSC_ENABLED
-#define MSC_INTERFACE_COUNT 1
-#define MSC_ENPOINT_COUNT 2
-#else
-#define MSC_INTERFACE_COUNT 0
-#define MSC_ENPOINT_COUNT 0
-#endif
-
#define CDC_ACM_INTERFACE 0 // CDC ACM
#define CDC_DATA_INTERFACE 1 // CDC Data
#define CDC_FIRST_ENDPOINT 1
@@ -56,11 +47,6 @@
#define HID_FIRST_ENDPOINT (CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT)
#define HID_ENDPOINT_INT (HID_FIRST_ENDPOINT)
-#define MSC_INTERFACE (HID_INTERFACE + HID_INTERFACE_COUNT) // MSC Interface
-#define MSC_FIRST_ENDPOINT (HID_FIRST_ENDPOINT + HID_ENPOINT_COUNT)
-#define MSC_ENDPOINT_OUT (MSC_FIRST_ENDPOINT)
-#define MSC_ENDPOINT_IN (MSC_FIRST_ENDPOINT+1)
-
#define INTERFACE_COUNT (MSC_INTERFACE + MSC_INTERFACE_COUNT)
#ifdef CDC_ENABLED
@@ -72,25 +58,10 @@
#define HID_TX HID_ENDPOINT_INT
#endif
-#ifdef MSC_ENABLED
-#define MSC_RX MSC_ENDPOINT_OUT
-#define MSC_TX MSC_ENDPOINT_IN
-#endif
-
-
-#define IMANUFACTURER 0
-#define IPRODUCT 0
-#define ISERIAL 1 // Only need this for MSC
-
-
-#define WRITABLE_DIRECTORY // undef saved 56 + 512 RAM
-
-#define FAT_DISK_LABEL 'b','o','o','t','l','o','a','d','e','r',' ' // 11 chars (undef saves 12)
-#define FAT_FILE_NAME 'F','I','R','M','W','A','R','E','B','I','N' // 11 chars
-#define MSC_DISK_SERIAL '0','0','0','0','0','0','0','0','1','7','0','1' // 12 chars
-
+#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
-#define FAT_OEM_NAME 'l','e','o','n','a','r','d','o' // 8 chars
-#define PRODUCT_NAME 'A','r','d','u','i','n','o','l','l','c' // 10
diff --git a/variants/leonardo/pins_arduino.h b/variants/leonardo/pins_arduino.h
index 65ab5e2..7fb85b4 100644
--- a/variants/leonardo/pins_arduino.h
+++ b/variants/leonardo/pins_arduino.h
@@ -28,6 +28,11 @@
#include <avr/pgmspace.h>
#define ARDUINO_MODEL_USB_PID 0x0034
+#define TX_RX_LED_INIT DDRE |= (1<<6), DDRB |= (1<<0)
+#define TXLED0 PORTE |= (1<<6)
+#define TXLED1 PORTE &= ~(1<<6)
+#define RXLED0 PORTB |= (1<<0)
+#define RXLED1 PORTB &= ~(1<<0)
// Map SPI port to 'new' pins D14..D17
// D14 PB0 RXLED,SS/PCINT0