aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Starkjohann <cs+github@obdev.at>2010-05-30 17:57:07 +0000
committerChristian Starkjohann <cs+github@obdev.at>2010-05-30 17:57:07 +0000
commit52b4b9131636c6c45678f266acaa04f6f3a5015d (patch)
treeb29076f053f47cf256bba63c1c512ac1f7282cbb
parentfd4af416f2d68f270d36cf02515c755f66955bd7 (diff)
downloadv-usb-52b4b9131636c6c45678f266acaa04f6f3a5015d.tar.gz
v-usb-52b4b9131636c6c45678f266acaa04f6f3a5015d.tar.bz2
v-usb-52b4b9131636c6c45678f266acaa04f6f3a5015d.zip
- introduced USB_CFG_DRIVER_FLASH_PAGE config option
-rw-r--r--usbdrv/Changelog.txt2
-rw-r--r--usbdrv/usbconfig-prototype.h14
-rw-r--r--usbdrv/usbdrvasm.S6
-rw-r--r--usbdrv/usbportability.h6
4 files changed, 23 insertions, 5 deletions
diff --git a/usbdrv/Changelog.txt b/usbdrv/Changelog.txt
index 3c528ee..88e3d74 100644
--- a/usbdrv/Changelog.txt
+++ b/usbdrv/Changelog.txt
@@ -300,3 +300,5 @@ Scroll down to the bottom to see the most recent changes.
V-USB compatible with the new "p" suffix devices (e.g. ATMega328p).
- USB_CFG_CLOCK_KHZ setting is now required in usbconfig.h (no default any
more).
+ - New USB_CFG_DRIVER_FLASH_PAGE allows boot loaders on devices with more
+ than 64 kB flash.
diff --git a/usbdrv/usbconfig-prototype.h b/usbdrv/usbconfig-prototype.h
index 8adc728..826f026 100644
--- a/usbdrv/usbconfig-prototype.h
+++ b/usbdrv/usbconfig-prototype.h
@@ -45,9 +45,12 @@ section at the end of this file).
*/
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
- * 16500 and 20000. The 12.8 MHz and 16.5 MHz versions of the code require no
- * crystal, they tolerate +/- 1% deviation from the nominal frequency. All
- * other rates require a precision of 2000 ppm and thus a crystal!
+ * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code
+ * require no crystal, they tolerate +/- 1% deviation from the nominal
+ * frequency. All other rates require a precision of 2000 ppm and thus a
+ * crystal!
+ * Since F_CPU should be defined to your actual clock rate anyway, you should
+ * not need to modify this setting.
*/
#define USB_CFG_CHECK_CRC 0
/* Define this to 1 if you want that the driver checks integrity of incoming
@@ -143,6 +146,11 @@ section at the end of this file).
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
* usbdrv.h.
*/
+#define USB_CFG_DRIVER_FLASH_PAGE 0
+/* If the device has more than 64 kBytes of flash, define this to the 64 k page
+ * where the driver's constants (descriptors) are located. Or in other words:
+ * Define this to 1 for boot loaders on the ATMega128.
+ */
#define USB_CFG_LONG_TRANSFERS 0
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
* in a single control-in or control-out transfer. Note that the capability
diff --git a/usbdrv/usbdrvasm.S b/usbdrv/usbdrvasm.S
index c9a65b7..4e6158c 100644
--- a/usbdrv/usbdrvasm.S
+++ b/usbdrv/usbdrvasm.S
@@ -361,7 +361,11 @@ usbMFTimeout:
;----------------------------------------------------------------------------
#ifndef USB_CFG_CLOCK_KHZ
-# error "USB_CFG_CLOCK_KHZ not defined in usbconfig.h!"
+# ifdef F_CPU
+# define USB_CFG_CLOCK_KHZ (F_CPU/1000)
+# else
+# error "USB_CFG_CLOCK_KHZ not defined in usbconfig.h and no F_CPU set!"
+# endif
#endif
#if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */
diff --git a/usbdrv/usbportability.h b/usbdrv/usbportability.h
index 62a35d9..a1ea93b 100644
--- a/usbdrv/usbportability.h
+++ b/usbdrv/usbportability.h
@@ -125,7 +125,11 @@ static inline void sei(void)
# include <avr/pgmspace.h>
#endif
-#define USB_READ_FLASH(addr) pgm_read_byte(addr)
+#if USB_CFG_DRIVER_FLASH_PAGE
+# define USB_READ_FLASH(addr) pgm_read_byte_far(((long)USB_CFG_DRIVER_FLASH_PAGE << 16) | (long)(addr))
+#else
+# define USB_READ_FLASH(addr) pgm_read_byte(addr)
+#endif
#define macro .macro
#define endm .endm