@@ -65,12 +65,21 @@ along with Hoodloader2. If not, see <http://www.gnu.org/licenses/>.
65
65
#define ARDUINO_MEGA_PID 0x0042 // R3 (0010 R1)
66
66
#define ARDUINO_MEGA_ADK_PID 0x0044 // R3 (003F R1)
67
67
68
+ // Only use RAM Descriptors if we have enough ram
69
+ #ifdef USE_RAM_DESCRIPTORS
70
+ #define DESCRIPTOR_PROGMEM
71
+ #define STRING_PROGMEM (x ) (x)
72
+ #else // PROGMEM descriptors
73
+ #define DESCRIPTOR_PROGMEM PROGMEM
74
+ #define STRING_PROGMEM (x ) pgm_read_byte(x)
75
+ #endif
76
+
68
77
/** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall
69
78
* device characteristics, including the supported USB version, control endpoint size and the
70
79
* number of device configurations. The descriptor is read out by the USB host when the enumeration
71
80
* process begins.
72
81
*/
73
- const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
82
+ const USB_Descriptor_Device_t DESCRIPTOR_PROGMEM DeviceDescriptor =
74
83
{
75
84
.Header = {.Size = sizeof (USB_Descriptor_Device_t ), .Type = DTYPE_Device },
76
85
@@ -98,7 +107,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
98
107
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
99
108
* a configuration so that the host may correctly communicate with the USB device.
100
109
*/
101
- const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
110
+ const USB_Descriptor_Configuration_t DESCRIPTOR_PROGMEM ConfigurationDescriptor =
102
111
{
103
112
.Config =
104
113
{
@@ -207,26 +216,26 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
207
216
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
208
217
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
209
218
*/
210
- const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARRAY (LANGUAGE_ID_ENG );
219
+ const USB_Descriptor_String_t DESCRIPTOR_PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARRAY (LANGUAGE_ID_ENG );
211
220
212
221
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
213
222
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
214
223
* Descriptor.
215
224
*/
216
- const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR (L"NicoHood" );
225
+ const USB_Descriptor_String_t DESCRIPTOR_PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR (L"NicoHood" );
217
226
218
227
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
219
228
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
220
229
* Descriptor.
221
230
*/
222
231
#if (PRODUCTID == ARDUINO_UNO_PID )
223
- const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR (L"HoodLoader2 Uno" );
232
+ const USB_Descriptor_String_t DESCRIPTOR_PROGMEM ProductString = USB_STRING_DESCRIPTOR (L"HoodLoader2 Uno" );
224
233
#elif (PRODUCTID == ARDUINO_MEGA_PID )
225
- const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR (L"HoodLoader2 Mega" );
234
+ const USB_Descriptor_String_t DESCRIPTOR_PROGMEM ProductString = USB_STRING_DESCRIPTOR (L"HoodLoader2 Mega" );
226
235
#elif (PRODUCTID == ARDUINO_ADK_PID )
227
- const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR (L"HoodLoader2 ADK" );
236
+ const USB_Descriptor_String_t DESCRIPTOR_PROGMEM ProductString = USB_STRING_DESCRIPTOR (L"HoodLoader2 ADK" );
228
237
#else
229
- const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR (L"HoodLoader2 Lufa" );
238
+ const USB_Descriptor_String_t DESCRIPTOR_PROGMEM ProductString = USB_STRING_DESCRIPTOR (L"HoodLoader2 Lufa" );
230
239
#endif
231
240
232
241
/** This function is called by the library when in device mode, and must be overridden (see LUFA library "USB Descriptors"
@@ -259,17 +268,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
259
268
if (DescriptorNumber == STRING_ID_Language )
260
269
{
261
270
Address = & LanguageString ;
262
- Size = pgm_read_byte (& LanguageString .Header .Size );
271
+ Size = STRING_PROGMEM (& LanguageString .Header .Size );
263
272
}
264
273
else if (DescriptorNumber == STRING_ID_Manufacturer )
265
274
{
266
275
Address = & ManufacturerString ;
267
- Size = pgm_read_byte (& ManufacturerString .Header .Size );
276
+ Size = STRING_PROGMEM (& ManufacturerString .Header .Size );
268
277
}
269
278
else if (DescriptorNumber == STRING_ID_Product )
270
279
{
271
280
Address = & ProductString ;
272
- Size = pgm_read_byte (& ProductString .Header .Size );
281
+ Size = STRING_PROGMEM (& ProductString .Header .Size );
273
282
}
274
283
275
284
break ;
0 commit comments