diff --git a/Bootloaders/CDC/BootloaderCDC.c b/Bootloaders/CDC/BootloaderCDC.c
index 654eabd22f..54c7b7e49d 100644
--- a/Bootloaders/CDC/BootloaderCDC.c
+++ b/Bootloaders/CDC/BootloaderCDC.c
@@ -207,7 +207,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
*
* \param Command Single character AVR910 protocol command indicating what memory operation to perform
*/
-static void ProgramReadWriteMemoryBlock(const uint8_t Command)
+static void ReadWriteMemoryBlock(const uint8_t Command)
{
uint16_t BlockSize;
char MemoryType;
@@ -503,7 +503,7 @@ TASK(CDC_Task)
else if ((Command == 'B') || (Command == 'g'))
{
/* Delegate the block write/read to a seperate function for clarity */
- ProgramReadWriteMemoryBlock(Command);
+ ReadWriteMemoryBlock(Command);
}
else if (Command == 'R')
{
diff --git a/Bootloaders/CDC/BootloaderCDC.h b/Bootloaders/CDC/BootloaderCDC.h
index 0d8f1e3d8d..a6e77550c9 100644
--- a/Bootloaders/CDC/BootloaderCDC.h
+++ b/Bootloaders/CDC/BootloaderCDC.h
@@ -127,9 +127,9 @@
/* Function Prototypes: */
#if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__)
- static void ProgramReadWriteMemoryBlock(const uint8_t Command);
+ static void ReadWriteMemoryBlock(const uint8_t Command);
static uint8_t FetchNextCommandByte(void);
- static void WriteNextResponseByte(const uint8_t Response);
+ static void WriteNextResponseByte(const uint8_t Response);
#endif
#endif
diff --git a/Bootloaders/CDC/makefile b/Bootloaders/CDC/makefile
index 3fa8ad4ff6..5045cc6864 100644
--- a/Bootloaders/CDC/makefile
+++ b/Bootloaders/CDC/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -162,9 +176,11 @@ BOOT_START = 0x1E000
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DSTATIC_ENDPOINT_CONFIGURATION
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES
+CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION
# Place -D or -U options here for ASM sources
diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile
index 5a8e4eeed0..5a26b7e3ef 100644
--- a/Bootloaders/DFU/makefile
+++ b/Bootloaders/DFU/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -162,10 +176,12 @@ BOOT_START = 0x1E000
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DSTATIC_ENDPOINT_CONFIGURATION
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DFIXED_CONTROL_ENDPOINT_SIZE=32 -DUSE_SINGLE_DEVICE_CONFIGURATION
-CDEFS += -DNO_CLEARSET_FEATURE_REQUEST
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_CLEARSET_FEATURE_REQUEST
+CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=32
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION
+
# Place -D or -U options here for ASM sources
ADEFS = -DF_CPU=$(F_CPU)
diff --git a/Bootloaders/TeensyHID/makefile b/Bootloaders/TeensyHID/makefile
index 92dd8b9b35..a815e01b45 100644
--- a/Bootloaders/TeensyHID/makefile
+++ b/Bootloaders/TeensyHID/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -162,10 +176,12 @@ BOOT_START = 0xC000
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DSTATIC_ENDPOINT_CONFIGURATION
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
-CDEFS += -DNO_CLEARSET_FEATURE_REQUEST
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_CLEARSET_FEATURE_REQUES
+CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION
+
# Place -D or -U options here for ASM sources
ADEFS = -DF_CPU=$(F_CPU)
diff --git a/Demos/AudioInput/makefile b/Demos/AudioInput/makefile
index 5906650f5f..51f6cc5b85 100644
--- a/Demos/AudioInput/makefile
+++ b/Demos/AudioInput/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/AudioOutput/makefile b/Demos/AudioOutput/makefile
index 46d7100ef3..6c2ee32308 100644
--- a/Demos/AudioOutput/makefile
+++ b/Demos/AudioOutput/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/BluetoothHost/makefile b/Demos/BluetoothHost/makefile
index b82a8ace49..189c84e1c8 100644
--- a/Demos/BluetoothHost/makefile
+++ b/Demos/BluetoothHost/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -166,9 +180,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-CDEFS += -DNO_STREAM_CALLBACKS
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DUSB_HOST_ONLY -DNO_STREAM_CALLBACKS
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
ADEFS = -DF_CPU=$(F_CPU)
diff --git a/Demos/CDC/makefile b/Demos/CDC/makefile
index b2bc1e269f..9b0e5bdd66 100644
--- a/Demos/CDC/makefile
+++ b/Demos/CDC/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/CDCHost/makefile b/Demos/CDCHost/makefile
index 1152a891af..d1e4cb990b 100644
--- a/Demos/CDCHost/makefile
+++ b/Demos/CDCHost/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DUSB_HOST_ONLY -DNO_STREAM_CALLBACKS
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/DualCDC/makefile b/Demos/DualCDC/makefile
index 50d8efea16..01ab609972 100644
--- a/Demos/DualCDC/makefile
+++ b/Demos/DualCDC/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/Joystick/makefile b/Demos/Joystick/makefile
index 0802e2d53a..a29a2d3802 100644
--- a/Demos/Joystick/makefile
+++ b/Demos/Joystick/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/Keyboard/makefile b/Demos/Keyboard/makefile
index b2a3bee0f6..681f729e20 100644
--- a/Demos/Keyboard/makefile
+++ b/Demos/Keyboard/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/KeyboardFullInt/makefile b/Demos/KeyboardFullInt/makefile
index 20fcc13153..b1f7f890f3 100644
--- a/Demos/KeyboardFullInt/makefile
+++ b/Demos/KeyboardFullInt/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -158,8 +172,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/KeyboardHost/makefile b/Demos/KeyboardHost/makefile
index 5140e7d98f..7ff737e519 100644
--- a/Demos/KeyboardHost/makefile
+++ b/Demos/KeyboardHost/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DUSB_HOST_ONLY -DNO_STREAM_CALLBACKS
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/KeyboardHostViaInt/makefile b/Demos/KeyboardHostViaInt/makefile
index 9cd332e5af..a8b3f23e60 100644
--- a/Demos/KeyboardHostViaInt/makefile
+++ b/Demos/KeyboardHostViaInt/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DUSB_HOST_ONLY -DNO_STREAM_CALLBACKS
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/KeyboardHostWithParser/makefile b/Demos/KeyboardHostWithParser/makefile
index 3082b8e9bc..ea768b4e4c 100644
--- a/Demos/KeyboardHostWithParser/makefile
+++ b/Demos/KeyboardHostWithParser/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -164,8 +178,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DUSB_HOST_ONLY -DNO_STREAM_CALLBACKS
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/KeyboardMouse/makefile b/Demos/KeyboardMouse/makefile
index ceae7dc589..7c26d2cf29 100644
--- a/Demos/KeyboardMouse/makefile
+++ b/Demos/KeyboardMouse/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/KeyboardViaInt/makefile b/Demos/KeyboardViaInt/makefile
index f1cb7a5693..ff225b35c4 100644
--- a/Demos/KeyboardViaInt/makefile
+++ b/Demos/KeyboardViaInt/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/MIDI/makefile b/Demos/MIDI/makefile
index 63f0513069..c5cc048d84 100644
--- a/Demos/MIDI/makefile
+++ b/Demos/MIDI/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
@@ -464,7 +479,7 @@ end:
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-EELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf
+ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf
MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
diff --git a/Demos/MassStorage/makefile b/Demos/MassStorage/makefile
index 82e10908cd..2f17228afc 100644
--- a/Demos/MassStorage/makefile
+++ b/Demos/MassStorage/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -161,8 +175,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/MassStorageHost/makefile b/Demos/MassStorageHost/makefile
index 2379c38561..fb04798e8e 100644
--- a/Demos/MassStorageHost/makefile
+++ b/Demos/MassStorageHost/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -163,8 +177,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_HOST_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/Mouse/makefile b/Demos/Mouse/makefile
index 329423f5dd..0f20dca636 100644
--- a/Demos/Mouse/makefile
+++ b/Demos/Mouse/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/MouseFullInt/makefile b/Demos/MouseFullInt/makefile
index 317fc315d0..fe85516989 100644
--- a/Demos/MouseFullInt/makefile
+++ b/Demos/MouseFullInt/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/MouseHost/makefile b/Demos/MouseHost/makefile
index b387efe348..6e8688f101 100644
--- a/Demos/MouseHost/makefile
+++ b/Demos/MouseHost/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_HOST_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/MouseHostViaInt/makefile b/Demos/MouseHostViaInt/makefile
index 0f8cae3005..f2b86e12f5 100644
--- a/Demos/MouseHostViaInt/makefile
+++ b/Demos/MouseHostViaInt/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_HOST_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/MouseHostWithParser/makefile b/Demos/MouseHostWithParser/makefile
index d9fcb1bc72..3eec44b369 100644
--- a/Demos/MouseHostWithParser/makefile
+++ b/Demos/MouseHostWithParser/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -164,8 +178,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_HOST_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/MouseViaInt/makefile b/Demos/MouseViaInt/makefile
index 0316b912d5..571d1f6067 100644
--- a/Demos/MouseViaInt/makefile
+++ b/Demos/MouseViaInt/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/RNDISEthernet/makefile b/Demos/RNDISEthernet/makefile
index 840b9d8d5d..ba1588af61 100644
--- a/Demos/RNDISEthernet/makefile
+++ b/Demos/RNDISEthernet/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -171,8 +185,10 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+
CDEFS += -DNO_DECODE_ETHERNET -DNO_DECODE_ARP -DNO_DECODE_ICMP -DNO_DECODE_IP -DNO_DECODE_TCP -DNO_DECODE_UDP -DNO_DECODE_DHCP
diff --git a/Demos/StillImageHost/makefile b/Demos/StillImageHost/makefile
index f2aee82e22..63e328ac40 100644
--- a/Demos/StillImageHost/makefile
+++ b/Demos/StillImageHost/makefile
@@ -89,6 +89,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_HOST_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Demos/TestApp/makefile b/Demos/TestApp/makefile
index 9d9b5fd6ae..befc0e6fce 100644
--- a/Demos/TestApp/makefile
+++ b/Demos/TestApp/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -167,7 +181,8 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES
CDEFS += -DNUM_BLOCKS=100 -DBLOCK_SIZE=8 -DNUM_HANDLES=20
diff --git a/Demos/USBtoSerial/makefile b/Demos/USBtoSerial/makefile
index 58c12b9ef0..6703102bb0 100644
--- a/Demos/USBtoSerial/makefile
+++ b/Demos/USBtoSerial/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -161,8 +175,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt
index fd21b3f102..af15a964db 100644
--- a/LUFA/ChangeLog.txt
+++ b/LUFA/ChangeLog.txt
@@ -21,6 +21,8 @@
* - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request
* - USBtoSerial demo now discards all Rx data when not connected to a USB host, rather than buffering characters for transmission
* next time the device is attached to a host.
+ * - Added new F_CLOCK compile time constant to the library and makefiles, to give the raw input clock (used to feed the PLL before any
+ * clock prescaling is performed) frequency, so that the PLL prescale mask can be determined
*
* \section Sec_ChangeLog090209 Version 090209
*
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.h b/LUFA/Drivers/USB/LowLevel/LowLevel.h
index faafbd7bff..9721baca01 100644
--- a/LUFA/Drivers/USB/LowLevel/LowLevel.h
+++ b/LUFA/Drivers/USB/LowLevel/LowLevel.h
@@ -66,7 +66,12 @@
#endif
/* Preprocessor Checks and Defines: */
- #if (F_CPU == 8000000)
+ #if !defined(F_CLOCK)
+ #error F_CLOCK is not defined. You must device F_CLOCK to the frequency of the unprescaled input clock in your project makefile.
+ #define F_CLOCK 0
+ #endif
+
+ #if (F_CLOCK == 8000000)
#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))
#define USB_PLL_PSC 0
#elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \
@@ -76,7 +81,7 @@
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
#define USB_PLL_PSC 0
#endif
- #elif (F_CPU == 16000000)
+ #elif (F_CLOCK == 16000000)
#if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))
#define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))
#elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))
diff --git a/LUFA/GettingStarted.txt b/LUFA/GettingStarted.txt
index 0fe3f50b92..a88a82533e 100644
--- a/LUFA/GettingStarted.txt
+++ b/LUFA/GettingStarted.txt
@@ -57,14 +57,22 @@
* directory into a /Board/ folder inside the application directory, and the stub driver completed with the appropriate code to drive the
* custom board's hardware.
*
- * \subsection SSec_F_CPU The F_CPU Parameter
- * This parameter indicates the target AVR's master clock frequency, in Hz. Consult your AVR model's datasheet for allowable clock frequencies
- * if the USB interface is to be operational.
+ * \subsection SSec_F_CLOCK The F_CLOCK Parameter
+ * This parameter indicates the target AVR's input clock frequency, in Hz. This is the actual clock input, before any prescaling is performed. In the
+ * USB AVR architecture, the input clock before any prescaling is fed directly to the PLL subsystem, and thus the PLL is derived directly from the
+ * clock input. The PLL then feeds the USB and other sections of the AVR with the correct upscaled frequencies required for those sections to function.
*
- * Note that this value does not actually *alter* the AVR's clock frequency, it is just a way to indicate to the library the clock frequency
+ * Note that this value does not actually *alter* the AVR's input clock frequency, it is just a way to indicate to the library the clock frequency
* of the AVR as set by the AVR's fuses. If this value does not reflect the actual running frequency of the AVR, incorrect operation of one of more
* library components will ocurr.
*
+ * \subsection SSec_F_CPU The F_CPU Parameter
+ * This parameter indicates the target AVR's master CPU clock frequency, in Hz.
+ *
+ * Note that this value does not actually *alter* the AVR's CPU clock frequency, it is just a way to indicate to the library the clock frequency
+ * of the AVR core as set by the AVR's fuses. If this value does not reflect the actual running frequency of the AVR, incorrect operation of one of more
+ * library components will ocurr.
+ *
* \subsection SSec_CDEFS The CDEFS Parameter
* Most applications will actually have multiple CDEF lines, which are concatenated together with the "+=" operator. This ensures that large
* numbers of configuration options remain readable by splitting up groups of options into seperate lines.
diff --git a/LUFA/MigrationInformation.txt b/LUFA/MigrationInformation.txt
index 1cdb55ae78..cd23da3328 100644
--- a/LUFA/MigrationInformation.txt
+++ b/LUFA/MigrationInformation.txt
@@ -12,6 +12,14 @@
*
* \section Sec_MigrationXXXXXX Migrating from 090209 to XXXXXX
*
+ * All
+ * - LUFA projects must now give the raw input clock frequency (before any prescaling) as a compile time constant "F_CLOCK",
+ * defined in the project makefile and passed to the compiler via the -D switch.
+ * - The makefile EEPROM programming targets for FLIP and dfu-programmer no longer program in the FLASH data in addition to the
+ * EEPROM data into the device. If both are to be programmed, both the EEPROM and FLASH programming targets must be called.
+ *
+ * Library Demos
+ * - The USBtoSerial demo now discards all data when not connected to a host, rather than buffering it for later transmission.
*
* \section Sec_Migration090209 Migrating from 081217 to 090209
*
diff --git a/Projects/AVRISP_Programmer/AVRISP_Programmer.c b/Projects/AVRISP_Programmer/AVRISP_Programmer.c
index 4dc18cd625..9ba3c0e7ec 100644
--- a/Projects/AVRISP_Programmer/AVRISP_Programmer.c
+++ b/Projects/AVRISP_Programmer/AVRISP_Programmer.c
@@ -116,7 +116,7 @@ BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
#define AVRDEVCODE02 0x56 /* ATtiny15 */
#define AVRDEVCODE03 0x5E /* ATtiny261 */
#define AVRDEVCODE04 0x76 /* ATmega8 */
-#define AVRDEVCODE05 0x74 /*ATmega16 */
+#define AVRDEVCODE05 0x74 /* ATmega16 */
#define AVRDEVCODE06 0x72 /* ATmega32 */
#define AVRDEVCODE07 0x45 /* ATmega64 */
#define AVRDEVCODE08 0x74 /* ATmega644 */
@@ -155,20 +155,8 @@ RingBuff_t Tx_Buffer;
/** Flag to indicate if the USART is currently transmitting data from the Rx_Buffer circular buffer. */
volatile bool Transmitting = false;
-
/* some global variables used throughout */
-uint8_t tempIOreg = 0;
-uint8_t tempIOreg2 = 0;
-uint8_t tempIOreg3 = 0;
-uint8_t tempIOreg4 = 0;
-uint8_t dataWidth = 0;
-uint8_t firstRun = 1;
-uint8_t deviceCode = 0;
-uint8_t tempByte = 0;
uint16_t currAddress = 0;
-uint16_t timerval = 0;
-
-
/** Main program entry point. This routine configures the hardware required by the application, then
starts the scheduler to run the application tasks.
@@ -185,9 +173,7 @@ int main(void)
/* Hardware Initialization */
LEDs_Init();
ReconfigureSPI();
- // prepare PortB
- DDRB = 0;
- PORTB = 0;
+
DDRC |= ((1 << PC2) | (1 << PC4) | (1 << PC5) | (1 << PC6) | (1 << PC7)); //AT90USBxx2
// PC2 is also used for RESET, so set it HIGH initially - note 'P' command sets it to LOW (Active)
PORTC |= ((1 << PC2) | (1 << PC4) | (1 << PC5) | (1 << PC6) | (1 << PC7)); //AT90USBxx2
@@ -198,15 +184,7 @@ int main(void)
PORTB |= (1 << PB0);
// make sure DataFlash devices to not interfere - deselect them by setting PE0 and PE1 HIGH:
PORTE = 0xFF;
- DDRE = 0xFF;
-
- // initialize Timer1 for use in delay function
- TCCR1A = 0;
- //TCCR1B = (1 << CS10); // no prescaling, use CLK
- TCCR1B = ((1 << CS12) | (1 << CS10)); // prescale by CLK/1024
- // 8MHz/1024 = 7813 ticks per second --> ~8 ticks per millisecond (ms)
- timerval = TCNT1; // start timer1
-
+ DDRE = 0xFF;
/* Ringbuffer Initialization */
Buffer_Initialize(&Rx_Buffer);
@@ -320,17 +298,6 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_SetControlLineState:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{
-#if 0
- /* NOTE: Here you can read in the line state mask from the host, to get the current state of the output handshake
- lines. The mask is read in from the wValue parameter, and can be masked against the CONTROL_LINE_OUT_* masks
- to determine the RTS and DTR line states using the following code:
- */
-
- uint16_t wIndex = Endpoint_Read_Word_LE();
-
- // Do something with the given line states in wIndex
-#endif
-
/* Acknowedge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived();
@@ -347,30 +314,6 @@ TASK(CDC_Task)
{
if (USB_IsConnected)
{
-#if 0
- /* NOTE: Here you can use the notification endpoint to send back line state changes to the host, for the special RS-232
- handshake signal lines (and some error states), via the CONTROL_LINE_IN_* masks and the following code:
- */
-
- USB_Notification_Header_t Notification = (USB_Notification_Header_t)
- {
- NotificationType: (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
- Notification: NOTIF_SerialState,
- wValue: 0,
- wIndex: 0,
- wLength: sizeof(uint16_t),
- };
-
- uint16_t LineStateMask;
-
- // Set LineStateMask here to a mask of CONTROL_LINE_IN_* masks to set the input handshake line states to send to the host
-
- Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);
- Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));
- Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask));
- Endpoint_ClearCurrentBank();
-#endif
-
/* Select the Serial Rx Endpoint */
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
@@ -385,72 +328,41 @@ TASK(CDC_Task)
/* Store each character from the endpoint */
Buffer_StoreElement(&Rx_Buffer, Endpoint_Read_Byte());
-
-
-
- /* Each time there is an element, check which comand should be
- run and if enough data is available to run that command.
- There are 1-byte, 2-byte, 3-byte, 4-byte commands, and 5-byte commands
- Remember that the "which command" byte counts as 1 */
- if (Rx_Buffer.Elements == 0) {
- // do nothing, wait for data
- } else {
- tempByte = Buffer_PeekElement(&Rx_Buffer); // peek at first element
-
- /* make sure the issued command and associated data are all ready */
- if (Rx_Buffer.Elements == 1) { // zero data byte command
- if ((tempByte == 'P') | (tempByte == 'a') | (tempByte == 'm') |
- (tempByte == 'R') | (tempByte == 'd') | (tempByte == 'e') |
- (tempByte == 'L') | (tempByte == 's') | (tempByte == 't') |
- (tempByte == 'S') | (tempByte == 'V') | (tempByte == 'v') |
- (tempByte == 'p') | (tempByte == 'F')) {
- processHostSPIRequest(); // command has enough data, process it
- }
- } else if (Rx_Buffer.Elements == 2) { // one data byte command
- if ((tempByte == 'T') | (tempByte == 'c') | (tempByte == 'C') |
- (tempByte == 'D') | (tempByte == 'l') | (tempByte == 'f') |
- (tempByte == 'x') | (tempByte == 'y')) {
- processHostSPIRequest(); // command has enough data, process it
- }
- } else if (Rx_Buffer.Elements == 3) { // two data byte command
- if ((tempByte == 'A') | (tempByte == 'Z')) {
- processHostSPIRequest(); // command has enough data, process it
- }
- } else if (Rx_Buffer.Elements == 4) { // three data byte command
- if ((tempByte == ':')) {
- processHostSPIRequest(); // command has enough data, process it
- }
- } else if (Rx_Buffer.Elements == 5) { // four data byte command
- if ((tempByte == '.')) {
- processHostSPIRequest(); // command has enough data, process it
- }
- } else {
- // do nothing
- }
+ /* Run the given command once enough data is available. */
+ if (Rx_Buffer.Elements)
+ {
+ const uint8_t ZeroDataByteCommands[] = {'P', 'a', 'm', 'R', 'd', 'e', 'L', 's', 't', 'S', 'V', 'v', 'p', 'F'};
+ const uint8_t OneDataByteCommands[] = {'T', 'c', 'C', 'D', 'l', 'f', 'x', 'y'};
+ const uint8_t TwoDataByteCommands[] = {'A', 'Z'};
+ const uint8_t ThreeDataByteCommands[] = {':'};
+ const uint8_t FourDataByteCommands[] = {'.'};
+
+ const struct
+ {
+ const uint8_t TotalCommands;
+ const uint8_t* CommandBytes;
+ } AVR910Commands[] = {{sizeof(ZeroDataByteCommands), ZeroDataByteCommands},
+ {sizeof(OneDataByteCommands), OneDataByteCommands},
+ {sizeof(TwoDataByteCommands), TwoDataByteCommands},
+ {sizeof(ThreeDataByteCommands), ThreeDataByteCommands},
+ {sizeof(FourDataByteCommands), FourDataByteCommands}};
+
+ /* Determine the data length of the issued command */
+ uint8_t CommandDataLength = (Rx_Buffer.Elements - 1);
+
+ /* Loop through each of the possible command bytes allowable from the given command data length */
+ for (uint8_t CurrentCommand = 0; CurrentCommand < AVR910Commands[CommandDataLength].TotalCommands; CurrentCommand++)
+ {
+ /* If issues command matches an allowable command, process it */
+ if (Buffer_PeekElement(&Rx_Buffer) == AVR910Commands[CommandDataLength].CommandBytes[CurrentCommand])
+ processHostSPIRequest();
+ }
}
-
-
-
}
/* Clear the endpoint buffer */
Endpoint_ClearCurrentBank();
}
-
- /* Check if Rx buffer contains data */
- if (Rx_Buffer.Elements)
- {
- /* Initiate the transmission of the buffer contents if USART idle */
- if (!(Transmitting))
- {
- Transmitting = true;
- /* The following flushes the receive buffer to prepare for new data and commands */
- /* Need to flush the buffer as the command byte which is peeked above needs to be */
- /* dealt with, otherwise the command bytes will overflow the buffer eventually */
- //Buffer_GetElement(&Rx_Buffer); // works also
- Buffer_Initialize(&Rx_Buffer);
- }
- }
/* Select the Serial Tx Endpoint */
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
@@ -484,12 +396,10 @@ TASK(CDC_Task)
}
}
-
-
/** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to
- log to a serial port, or anything else that is suitable for status updates.
+ * log to a serial port, or anything else that is suitable for status updates.
*
- \param CurrentStatus Current status of the system, from the USBtoSerial_StatusCodes_t enum
+ * \param CurrentStatus Current status of the system, from the USBtoSerial_StatusCodes_t enum
*/
void UpdateStatus(uint8_t CurrentStatus)
{
@@ -513,22 +423,12 @@ void UpdateStatus(uint8_t CurrentStatus)
LEDs_SetAllLEDs(LEDMask);
}
-
/** Reconfigures SPI to match the current serial port settings issued by the host. */
void ReconfigureSPI(void)
{
uint8_t SPCRmask = (1 << SPE) | (1 << MSTR); // always enable SPI as Master
uint8_t SPSRmask = 0;
- /* Determine data width */
- if (LineCoding.ParityType == Parity_Odd) {
- dataWidth = 16;
- } else if (LineCoding.ParityType == Parity_Even) {
- dataWidth = 32;
- } else if (LineCoding.ParityType == Parity_None) {
- dataWidth = 8;
- }
-
/* Determine stop bits - 1.5 stop bits is set as 1 stop bit due to hardware limitations */
/* For SPI, determine whether format is LSB or MSB */
if (LineCoding.CharFormat == TwoStopBits) {
@@ -579,14 +479,6 @@ void ReconfigureSPI(void)
SPCR = SPCRmask;
SPSR = SPSRmask;
-
- // only read if first run
- if (firstRun) {
- tempIOreg = SPSR; //need to read to initiliaze
- tempIOreg = SPDR; //need to read to initiliaze
- firstRun = 0;
- }
-
}
@@ -642,20 +534,20 @@ void processHostSPIRequest(void) {
//PORTB = 0; // set clock to zero
RESETPORT = (1 << RESETPIN); // set RESET pin on target to 1
RESETPORT2 = (1 << RESETPIN2);
- delay_ms(DELAY_SHORT);
+ _delay_ms(DELAY_SHORT);
//RESETPORT = (RESETPORT & ~(1 << RESETPIN)); // set RESET pin on target to 0 - Active
RESETPORT = 0x00;
RESETPORT2 = 0;
- delay_ms(DELAY_SHORT);
+ _delay_ms(DELAY_SHORT);
SPI_SendByte(0xAC);
SPI_SendByte(0x53);
SPI_SendByte(0x00);
SPI_SendByte(0x00);
- delay_ms(DELAY_VERYSHORT);
+ _delay_ms(DELAY_VERYSHORT);
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'T') { // Select device type
- deviceCode = Buffer_GetElement(&Rx_Buffer); // set device type
+ Buffer_GetElement(&Rx_Buffer); // set device type
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'a') { // Report autoincrement address
@@ -675,7 +567,7 @@ void processHostSPIRequest(void) {
SPI_SendByte((currAddress >> 8)); // high byte
SPI_SendByte((currAddress)); // low byte
SPI_SendByte(readByte1); // data
- delay_ms(DELAY_MEDIUM); // certain MCUs require a delay of about 24585 cycles
+ _delay_ms(DELAY_MEDIUM); // certain MCUs require a delay of about 24585 cycles
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'C') { // Write program memory, high byte
@@ -694,7 +586,7 @@ void processHostSPIRequest(void) {
SPI_SendByte((currAddress >> 8)); // high byte
SPI_SendByte((currAddress)); // low byte
SPI_SendByte(0x00);
- delay_ms(DELAY_LONG);
+ _delay_ms(DELAY_LONG);
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'R') { // Read Program Memory
@@ -719,7 +611,7 @@ void processHostSPIRequest(void) {
SPI_SendByte((currAddress >> 8)); // high byte
SPI_SendByte((currAddress)); // low byte
SPI_SendByte(readByte1); // data
- delay_ms(DELAY_MEDIUM);
+ _delay_ms(DELAY_MEDIUM);
currAddress++; // increment currAddress
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
@@ -738,7 +630,7 @@ void processHostSPIRequest(void) {
SPI_SendByte(0x80);
SPI_SendByte(0x04);
SPI_SendByte(0x00);
- delay_ms(DELAY_LONG);
+ _delay_ms(DELAY_LONG);
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'l') { // write lock bits
@@ -748,7 +640,7 @@ void processHostSPIRequest(void) {
SPI_SendByte(((0x06 & readByte1) | 0xE0)); // TODO - is this correct???
SPI_SendByte(0x00);
SPI_SendByte(0x00);
- delay_ms(DELAY_MEDIUM);
+ _delay_ms(DELAY_MEDIUM);
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'f') { // write fuse bits
@@ -840,7 +732,7 @@ void processHostSPIRequest(void) {
SPI_SendByte(readByte3);
readByte1 = SPI_TransferByte(0x00);
Buffer_StoreElement(&Tx_Buffer, readByte1);
- delay_ms(DELAY_MEDIUM);
+ _delay_ms(DELAY_MEDIUM);
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == '.') { // New Universal Command
@@ -854,7 +746,7 @@ void processHostSPIRequest(void) {
SPI_SendByte(readByte3);
readByte1 = SPI_TransferByte(readByte4);
Buffer_StoreElement(&Tx_Buffer, readByte1);
- delay_ms(DELAY_MEDIUM);
+ _delay_ms(DELAY_MEDIUM);
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'Z') { // Special test command
@@ -868,19 +760,3 @@ void processHostSPIRequest(void) {
}
}
-
-void delay_ms(uint8_t dly) {
- uint16_t endtime = 0;
-
- endtime = TCNT1;
- if (endtime > 63486) {
- endtime = (dly * DELAY_MULTIPLE);
- } else {
- endtime += (dly * DELAY_MULTIPLE);
- }
-
- timerval = TCNT1;
- while (timerval < endtime) {
- timerval = TCNT1;
- }
-}
diff --git a/Projects/AVRISP_Programmer/AVRISP_Programmer.h b/Projects/AVRISP_Programmer/AVRISP_Programmer.h
index e78ba29356..4c98d6bf3a 100644
--- a/Projects/AVRISP_Programmer/AVRISP_Programmer.h
+++ b/Projects/AVRISP_Programmer/AVRISP_Programmer.h
@@ -37,6 +37,7 @@
#define _AVRISP_PROGRAMMER_H_
/* Includes: */
+ #include
#include
#include
#include
@@ -189,6 +190,5 @@
void ReconfigureSPI(void);
void UpdateStatus(uint8_t CurrentStatus);
void processHostSPIRequest(void);
- void delay_ms(uint8_t dly);
#endif
diff --git a/Projects/AVRISP_Programmer/makefile b/Projects/AVRISP_Programmer/makefile
index d6617dc7ef..f8d75b6588 100644
--- a/Projects/AVRISP_Programmer/makefile
+++ b/Projects/AVRISP_Programmer/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -161,8 +175,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
diff --git a/Projects/Magstripe/makefile b/Projects/Magstripe/makefile
index 2ea5536fb1..1099760909 100644
--- a/Projects/Magstripe/makefile
+++ b/Projects/Magstripe/makefile
@@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 16000000
+# Input clock frequency.
+# This will define a symbol, F_CLOCK, in all source code files equal to the
+# input clock frequency (before any prescaling is performed). This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_CLOCK = 8000000
+
+
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
@@ -160,8 +174,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
-CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS
-CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
+CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
+CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
CDEFS += -DMAG_T1_CLOCK="(1 << 0)"
CDEFS += -DMAG_T1_DATA="(1 << 1)"