Skip to content

Commit

Permalink
change PROGMEM to __flash
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdralph committed Mar 24, 2021
1 parent 8f4beb0 commit acaeb65
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
9 changes: 4 additions & 5 deletions firmware/main.c
Expand Up @@ -13,7 +13,7 @@

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
//#include <avr/pgmspace.h>
#include <avr/wdt.h>

#include "usbasp.h"
Expand Down Expand Up @@ -115,7 +115,7 @@ static uchar prog_pagecounter;

/* For Windows OS Descriptors we need to report that we support USB 2.0 */

PROGMEM const char usbDescriptorDevice[18] = { /* USB device descriptor */
__flash const char usbDescriptorDevice[18] = { /* USB device descriptor */
18, /* sizeof(usbDescriptorDevice): length of descriptor in bytes */
USBDESCR_DEVICE, /* descriptor type */
0x00, 0x02, /* USB version supported */
Expand All @@ -137,8 +137,7 @@ PROGMEM const char usbDescriptorDevice[18] = { /* USB device descriptor */

/* OS Extended Compat ID feature descriptor */

PROGMEM
const char OS_EXTENDED_COMPAT_ID[40] = {
__flash const char OS_EXTENDED_COMPAT_ID[40] = {
/* Header */
0x28, 0x00, 0x00, 0x00, /* OS Extended Compat ID feature descriptor length */
0x00, 0x01, /* OS Extended Compat ID version */
Expand All @@ -154,7 +153,7 @@ const char OS_EXTENDED_COMPAT_ID[40] = {
};

#define MS_VENDOR_CODE 0x5D
PROGMEM const char OS_STRING_DESCRIPTOR[18] = {
__flash const char OS_STRING_DESCRIPTOR[18] = {
0x12, /* Length: An unsigned byte and MUST be set to 0x12. */
/* https://docs.microsoft.com/en-us/windows-hardware/drivers/network/mb-interface-model-supplement */
0x03, /* Type: An unsigned byte and MUST be set to 0x03. */
Expand Down
12 changes: 6 additions & 6 deletions firmware/usbdrv/usbdrv.c
Expand Up @@ -64,7 +64,7 @@ optimizing hints:
#if USB_CFG_DESCR_PROPS_STRING_0 == 0
#undef USB_CFG_DESCR_PROPS_STRING_0
#define USB_CFG_DESCR_PROPS_STRING_0 sizeof(usbDescriptorString0)
PROGMEM const char usbDescriptorString0[] = { /* language descriptor */
__flash const char usbDescriptorString0[] = { /* language descriptor */
4, /* sizeof(usbDescriptorString0): length of descriptor in bytes */
3, /* descriptor type */
0x09, 0x04, /* language index (0x0409 = US-English) */
Expand All @@ -74,7 +74,7 @@ PROGMEM const char usbDescriptorString0[] = { /* language descriptor */
#if USB_CFG_DESCR_PROPS_STRING_VENDOR == 0 && USB_CFG_VENDOR_NAME_LEN
#undef USB_CFG_DESCR_PROPS_STRING_VENDOR
#define USB_CFG_DESCR_PROPS_STRING_VENDOR sizeof(usbDescriptorStringVendor)
PROGMEM const int usbDescriptorStringVendor[] = {
__flash const int usbDescriptorStringVendor[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_VENDOR_NAME_LEN),
USB_CFG_VENDOR_NAME
};
Expand All @@ -83,7 +83,7 @@ PROGMEM const int usbDescriptorStringVendor[] = {
#if USB_CFG_DESCR_PROPS_STRING_PRODUCT == 0 && USB_CFG_DEVICE_NAME_LEN
#undef USB_CFG_DESCR_PROPS_STRING_PRODUCT
#define USB_CFG_DESCR_PROPS_STRING_PRODUCT sizeof(usbDescriptorStringDevice)
PROGMEM const int usbDescriptorStringDevice[] = {
__flash const int usbDescriptorStringDevice[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_DEVICE_NAME_LEN),
USB_CFG_DEVICE_NAME
};
Expand All @@ -92,7 +92,7 @@ PROGMEM const int usbDescriptorStringDevice[] = {
#if USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER == 0 && USB_CFG_SERIAL_NUMBER_LEN
#undef USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER sizeof(usbDescriptorStringSerialNumber)
PROGMEM const int usbDescriptorStringSerialNumber[] = {
__flash const int usbDescriptorStringSerialNumber[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_SERIAL_NUMBER_LEN),
USB_CFG_SERIAL_NUMBER
};
Expand All @@ -105,7 +105,7 @@ PROGMEM const int usbDescriptorStringSerialNumber[] = {
#if USB_CFG_DESCR_PROPS_DEVICE == 0
#undef USB_CFG_DESCR_PROPS_DEVICE
#define USB_CFG_DESCR_PROPS_DEVICE sizeof(usbDescriptorDevice)
PROGMEM const char usbDescriptorDevice[] = { /* USB device descriptor */
__flash const char usbDescriptorDevice[] = { /* USB device descriptor */
18, /* sizeof(usbDescriptorDevice): length of descriptor in bytes */
USBDESCR_DEVICE, /* descriptor type */
0x10, 0x01, /* USB version supported */
Expand Down Expand Up @@ -136,7 +136,7 @@ PROGMEM const char usbDescriptorDevice[] = { /* USB device descriptor */
#if USB_CFG_DESCR_PROPS_CONFIGURATION == 0
#undef USB_CFG_DESCR_PROPS_CONFIGURATION
#define USB_CFG_DESCR_PROPS_CONFIGURATION sizeof(usbDescriptorConfiguration)
PROGMEM const char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
__flash const char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
USBDESCR_CONFIG, /* descriptor type */
18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 +
Expand Down
16 changes: 8 additions & 8 deletions firmware/usbdrv/usbdrv.h
Expand Up @@ -271,7 +271,7 @@ USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len);
#endif /* USB_CFG_HAVE_INTRIN_ENDPOINT */
#if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH /* simplified interface for backward compatibility */
#define usbHidReportDescriptor usbDescriptorHidReport
/* should be declared as: PROGMEM char usbHidReportDescriptor[]; */
/* should be declared as: __flash char usbHidReportDescriptor[]; */
/* If you implement an HID device, you need to provide a report descriptor.
* The HID report descriptor syntax is a bit complex. If you understand how
* report descriptors are constructed, we recommend that you use the HID
Expand Down Expand Up @@ -484,43 +484,43 @@ extern volatile schar usbRxLen;
#ifndef __ASSEMBLER__
extern
#if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM)
PROGMEM const
__flash const
#endif
char usbDescriptorDevice[];

extern
#if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM)
PROGMEM const
__flash const
#endif
char usbDescriptorConfiguration[];

extern
#if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM)
PROGMEM const
__flash const
#endif
char usbDescriptorHidReport[];

extern
#if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM)
PROGMEM const
__flash const
#endif
char usbDescriptorString0[];

extern
#if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM)
PROGMEM const
__flash const
#endif
int usbDescriptorStringVendor[];

extern
#if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM)
PROGMEM const
__flash const
#endif
int usbDescriptorStringDevice[];

extern
#if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM)
PROGMEM const
__flash const
#endif
int usbDescriptorStringSerialNumber[];

Expand Down

0 comments on commit acaeb65

Please sign in to comment.