Makefiles and library modified to add a new F_CLOCK constant to give the unprescaled master input clock frequency, so that the correct PLL mask can be determined even when the CPU (F_CPU) clock rate is prescaled outside the normal input range of the PLL.

Started to clean up the AVRISP Programmer project code, donated by Opendous Inc.
pull/1469/head
Dean Camera 16 years ago
parent fa456ce531
commit 99145a8d7c

@ -207,7 +207,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
* *
* \param Command Single character AVR910 protocol command indicating what memory operation to perform * \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; uint16_t BlockSize;
char MemoryType; char MemoryType;
@ -503,7 +503,7 @@ TASK(CDC_Task)
else if ((Command == 'B') || (Command == 'g')) else if ((Command == 'B') || (Command == 'g'))
{ {
/* Delegate the block write/read to a seperate function for clarity */ /* Delegate the block write/read to a seperate function for clarity */
ProgramReadWriteMemoryBlock(Command); ReadWriteMemoryBlock(Command);
} }
else if (Command == 'R') else if (Command == 'R')
{ {

@ -127,9 +127,9 @@
/* Function Prototypes: */ /* Function Prototypes: */
#if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__) #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 uint8_t FetchNextCommandByte(void);
static void WriteNextResponseByte(const uint8_t Response); static void WriteNextResponseByte(const uint8_t Response);
#endif #endif
#endif #endif

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -162,9 +176,11 @@ BOOT_START = 0x1E000
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES
CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -162,10 +176,12 @@ BOOT_START = 0x1E000
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_CLEARSET_FEATURE_REQUEST
CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DFIXED_CONTROL_ENDPOINT_SIZE=32 -DUSE_SINGLE_DEVICE_CONFIGURATION CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=32
CDEFS += -DNO_CLEARSET_FEATURE_REQUEST 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 # Place -D or -U options here for ASM sources
ADEFS = -DF_CPU=$(F_CPU) ADEFS = -DF_CPU=$(F_CPU)

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -162,10 +176,12 @@ BOOT_START = 0xC000
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_CLEARSET_FEATURE_REQUES
CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
CDEFS += -DNO_CLEARSET_FEATURE_REQUEST 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 # Place -D or -U options here for ASM sources
ADEFS = -DF_CPU=$(F_CPU) ADEFS = -DF_CPU=$(F_CPU)

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -166,9 +180,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DUSB_HOST_ONLY -DNO_STREAM_CALLBACKS
CDEFS += -DNO_STREAM_CALLBACKS CDEFS += -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources # Place -D or -U options here for ASM sources
ADEFS = -DF_CPU=$(F_CPU) ADEFS = -DF_CPU=$(F_CPU)

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -158,8 +172,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -164,8 +178,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources
@ -464,7 +479,7 @@ end:
# Display size of file. # Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex 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) ) 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 ) FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -161,8 +175,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -163,8 +177,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -164,8 +178,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -159,8 +173,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -171,8 +185,10 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 CDEFS += -DNO_DECODE_ETHERNET -DNO_DECODE_ARP -DNO_DECODE_ICMP -DNO_DECODE_IP -DNO_DECODE_TCP -DNO_DECODE_UDP -DNO_DECODE_DHCP

@ -89,6 +89,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -162,8 +176,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_HOST_ONLY -DUSE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -167,7 +181,8 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 CDEFS += -DNUM_BLOCKS=100 -DBLOCK_SIZE=8 -DNUM_HANDLES=20

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -161,8 +175,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -21,6 +21,8 @@
* - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request * - 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 * - 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. * 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 * \section Sec_ChangeLog090209 Version 090209
* *

@ -66,7 +66,12 @@
#endif #endif
/* Preprocessor Checks and Defines: */ /* 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__)) #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))
#define USB_PLL_PSC 0 #define USB_PLL_PSC 0
#elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \ #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \
@ -76,7 +81,7 @@
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
#define USB_PLL_PSC 0 #define USB_PLL_PSC 0
#endif #endif
#elif (F_CPU == 16000000) #elif (F_CLOCK == 16000000)
#if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__)) #if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))
#define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1)) #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))
#elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)) #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))

@ -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 * 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. * custom board's hardware.
* *
* \subsection SSec_F_CPU The F_CPU Parameter * \subsection SSec_F_CLOCK The F_CLOCK Parameter
* This parameter indicates the target AVR's master clock frequency, in Hz. Consult your AVR model's datasheet for allowable clock frequencies * 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
* if the USB interface is to be operational. * 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.
* *
* <b>Note that this value does not actually *alter* the AVR's clock frequency</b>, it is just a way to indicate to the library the clock frequency * <b>Note that this value does not actually *alter* the AVR's input clock frequency</b>, 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 * 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. * 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.
*
* <b>Note that this value does not actually *alter* the AVR's CPU clock frequency</b>, 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 * \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 * 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. * numbers of configuration options remain readable by splitting up groups of options into seperate lines.

@ -12,6 +12,14 @@
* *
* \section Sec_MigrationXXXXXX Migrating from 090209 to XXXXXX * \section Sec_MigrationXXXXXX Migrating from 090209 to XXXXXX
* *
* <b>All</b>
* - 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.
*
* <b>Library Demos</b>
* - 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 * \section Sec_Migration090209 Migrating from 081217 to 090209
* *

@ -116,7 +116,7 @@ BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
#define AVRDEVCODE02 0x56 /* ATtiny15 */ #define AVRDEVCODE02 0x56 /* ATtiny15 */
#define AVRDEVCODE03 0x5E /* ATtiny261 */ #define AVRDEVCODE03 0x5E /* ATtiny261 */
#define AVRDEVCODE04 0x76 /* ATmega8 */ #define AVRDEVCODE04 0x76 /* ATmega8 */
#define AVRDEVCODE05 0x74 /*ATmega16 */ #define AVRDEVCODE05 0x74 /* ATmega16 */
#define AVRDEVCODE06 0x72 /* ATmega32 */ #define AVRDEVCODE06 0x72 /* ATmega32 */
#define AVRDEVCODE07 0x45 /* ATmega64 */ #define AVRDEVCODE07 0x45 /* ATmega64 */
#define AVRDEVCODE08 0x74 /* ATmega644 */ #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. */ /** Flag to indicate if the USART is currently transmitting data from the Rx_Buffer circular buffer. */
volatile bool Transmitting = false; volatile bool Transmitting = false;
/* some global variables used throughout */ /* 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 currAddress = 0;
uint16_t timerval = 0;
/** Main program entry point. This routine configures the hardware required by the application, then /** Main program entry point. This routine configures the hardware required by the application, then
starts the scheduler to run the application tasks. starts the scheduler to run the application tasks.
@ -185,9 +173,7 @@ int main(void)
/* Hardware Initialization */ /* Hardware Initialization */
LEDs_Init(); LEDs_Init();
ReconfigureSPI(); ReconfigureSPI();
// prepare PortB
DDRB = 0;
PORTB = 0;
DDRC |= ((1 << PC2) | (1 << PC4) | (1 << PC5) | (1 << PC6) | (1 << PC7)); //AT90USBxx2 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) // 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 PORTC |= ((1 << PC2) | (1 << PC4) | (1 << PC5) | (1 << PC6) | (1 << PC7)); //AT90USBxx2
@ -198,15 +184,7 @@ int main(void)
PORTB |= (1 << PB0); PORTB |= (1 << PB0);
// make sure DataFlash devices to not interfere - deselect them by setting PE0 and PE1 HIGH: // make sure DataFlash devices to not interfere - deselect them by setting PE0 and PE1 HIGH:
PORTE = 0xFF; PORTE = 0xFF;
DDRE = 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
/* Ringbuffer Initialization */ /* Ringbuffer Initialization */
Buffer_Initialize(&Rx_Buffer); Buffer_Initialize(&Rx_Buffer);
@ -320,17 +298,6 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
case REQ_SetControlLineState: case REQ_SetControlLineState:
if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) 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 */ /* Acknowedge the SETUP packet, ready for data transfer */
Endpoint_ClearSetupReceived(); Endpoint_ClearSetupReceived();
@ -347,30 +314,6 @@ TASK(CDC_Task)
{ {
if (USB_IsConnected) 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 */ /* Select the Serial Rx Endpoint */
Endpoint_SelectEndpoint(CDC_RX_EPNUM); Endpoint_SelectEndpoint(CDC_RX_EPNUM);
@ -385,73 +328,42 @@ TASK(CDC_Task)
/* Store each character from the endpoint */ /* Store each character from the endpoint */
Buffer_StoreElement(&Rx_Buffer, Endpoint_Read_Byte()); Buffer_StoreElement(&Rx_Buffer, Endpoint_Read_Byte());
/* Run the given command once enough data is available. */
if (Rx_Buffer.Elements)
{
/* Each time there is an element, check which comand should be const uint8_t ZeroDataByteCommands[] = {'P', 'a', 'm', 'R', 'd', 'e', 'L', 's', 't', 'S', 'V', 'v', 'p', 'F'};
run and if enough data is available to run that command. const uint8_t OneDataByteCommands[] = {'T', 'c', 'C', 'D', 'l', 'f', 'x', 'y'};
There are 1-byte, 2-byte, 3-byte, 4-byte commands, and 5-byte commands const uint8_t TwoDataByteCommands[] = {'A', 'Z'};
Remember that the "which command" byte counts as 1 */ const uint8_t ThreeDataByteCommands[] = {':'};
if (Rx_Buffer.Elements == 0) { const uint8_t FourDataByteCommands[] = {'.'};
// do nothing, wait for data
} else { const struct
tempByte = Buffer_PeekElement(&Rx_Buffer); // peek at first element {
const uint8_t TotalCommands;
/* make sure the issued command and associated data are all ready */ const uint8_t* CommandBytes;
if (Rx_Buffer.Elements == 1) { // zero data byte command } AVR910Commands[] = {{sizeof(ZeroDataByteCommands), ZeroDataByteCommands},
if ((tempByte == 'P') | (tempByte == 'a') | (tempByte == 'm') | {sizeof(OneDataByteCommands), OneDataByteCommands},
(tempByte == 'R') | (tempByte == 'd') | (tempByte == 'e') | {sizeof(TwoDataByteCommands), TwoDataByteCommands},
(tempByte == 'L') | (tempByte == 's') | (tempByte == 't') | {sizeof(ThreeDataByteCommands), ThreeDataByteCommands},
(tempByte == 'S') | (tempByte == 'V') | (tempByte == 'v') | {sizeof(FourDataByteCommands), FourDataByteCommands}};
(tempByte == 'p') | (tempByte == 'F')) {
processHostSPIRequest(); // command has enough data, process it /* Determine the data length of the issued command */
} uint8_t CommandDataLength = (Rx_Buffer.Elements - 1);
} else if (Rx_Buffer.Elements == 2) { // one data byte command
if ((tempByte == 'T') | (tempByte == 'c') | (tempByte == 'C') | /* Loop through each of the possible command bytes allowable from the given command data length */
(tempByte == 'D') | (tempByte == 'l') | (tempByte == 'f') | for (uint8_t CurrentCommand = 0; CurrentCommand < AVR910Commands[CommandDataLength].TotalCommands; CurrentCommand++)
(tempByte == 'x') | (tempByte == 'y')) { {
processHostSPIRequest(); // command has enough data, process it /* If issues command matches an allowable command, process it */
} if (Buffer_PeekElement(&Rx_Buffer) == AVR910Commands[CommandDataLength].CommandBytes[CurrentCommand])
} else if (Rx_Buffer.Elements == 3) { // two data byte command processHostSPIRequest();
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
}
} }
} }
/* Clear the endpoint buffer */ /* Clear the endpoint buffer */
Endpoint_ClearCurrentBank(); 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 */ /* Select the Serial Tx Endpoint */
Endpoint_SelectEndpoint(CDC_TX_EPNUM); 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 /** 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) void UpdateStatus(uint8_t CurrentStatus)
{ {
@ -513,22 +423,12 @@ void UpdateStatus(uint8_t CurrentStatus)
LEDs_SetAllLEDs(LEDMask); LEDs_SetAllLEDs(LEDMask);
} }
/** Reconfigures SPI to match the current serial port settings issued by the host. */ /** Reconfigures SPI to match the current serial port settings issued by the host. */
void ReconfigureSPI(void) void ReconfigureSPI(void)
{ {
uint8_t SPCRmask = (1 << SPE) | (1 << MSTR); // always enable SPI as Master uint8_t SPCRmask = (1 << SPE) | (1 << MSTR); // always enable SPI as Master
uint8_t SPSRmask = 0; 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 */ /* 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 */ /* For SPI, determine whether format is LSB or MSB */
if (LineCoding.CharFormat == TwoStopBits) { if (LineCoding.CharFormat == TwoStopBits) {
@ -579,14 +479,6 @@ void ReconfigureSPI(void)
SPCR = SPCRmask; SPCR = SPCRmask;
SPSR = SPSRmask; 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 //PORTB = 0; // set clock to zero
RESETPORT = (1 << RESETPIN); // set RESET pin on target to 1 RESETPORT = (1 << RESETPIN); // set RESET pin on target to 1
RESETPORT2 = (1 << RESETPIN2); RESETPORT2 = (1 << RESETPIN2);
delay_ms(DELAY_SHORT); _delay_ms(DELAY_SHORT);
//RESETPORT = (RESETPORT & ~(1 << RESETPIN)); // set RESET pin on target to 0 - Active //RESETPORT = (RESETPORT & ~(1 << RESETPIN)); // set RESET pin on target to 0 - Active
RESETPORT = 0x00; RESETPORT = 0x00;
RESETPORT2 = 0; RESETPORT2 = 0;
delay_ms(DELAY_SHORT); _delay_ms(DELAY_SHORT);
SPI_SendByte(0xAC); SPI_SendByte(0xAC);
SPI_SendByte(0x53); SPI_SendByte(0x53);
SPI_SendByte(0x00); SPI_SendByte(0x00);
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 Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'T') { // Select device type } 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 Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'a') { // Report autoincrement address } else if (firstByte == 'a') { // Report autoincrement address
@ -675,7 +567,7 @@ void processHostSPIRequest(void) {
SPI_SendByte((currAddress >> 8)); // high byte SPI_SendByte((currAddress >> 8)); // high byte
SPI_SendByte((currAddress)); // low byte SPI_SendByte((currAddress)); // low byte
SPI_SendByte(readByte1); // data 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 Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'C') { // Write program memory, high byte } 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 >> 8)); // high byte
SPI_SendByte((currAddress)); // low byte SPI_SendByte((currAddress)); // low byte
SPI_SendByte(0x00); SPI_SendByte(0x00);
delay_ms(DELAY_LONG); _delay_ms(DELAY_LONG);
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'R') { // Read Program Memory } else if (firstByte == 'R') { // Read Program Memory
@ -719,7 +611,7 @@ void processHostSPIRequest(void) {
SPI_SendByte((currAddress >> 8)); // high byte SPI_SendByte((currAddress >> 8)); // high byte
SPI_SendByte((currAddress)); // low byte SPI_SendByte((currAddress)); // low byte
SPI_SendByte(readByte1); // data SPI_SendByte(readByte1); // data
delay_ms(DELAY_MEDIUM); _delay_ms(DELAY_MEDIUM);
currAddress++; // increment currAddress currAddress++; // increment currAddress
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful 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(0x80);
SPI_SendByte(0x04); SPI_SendByte(0x04);
SPI_SendByte(0x00); SPI_SendByte(0x00);
delay_ms(DELAY_LONG); _delay_ms(DELAY_LONG);
Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'l') { // write lock bits } 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(((0x06 & readByte1) | 0xE0)); // TODO - is this correct???
SPI_SendByte(0x00); SPI_SendByte(0x00);
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 Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'f') { // write fuse bits } else if (firstByte == 'f') { // write fuse bits
@ -840,7 +732,7 @@ void processHostSPIRequest(void) {
SPI_SendByte(readByte3); SPI_SendByte(readByte3);
readByte1 = SPI_TransferByte(0x00); readByte1 = SPI_TransferByte(0x00);
Buffer_StoreElement(&Tx_Buffer, readByte1); 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 Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == '.') { // New Universal Command } else if (firstByte == '.') { // New Universal Command
@ -854,7 +746,7 @@ void processHostSPIRequest(void) {
SPI_SendByte(readByte3); SPI_SendByte(readByte3);
readByte1 = SPI_TransferByte(readByte4); readByte1 = SPI_TransferByte(readByte4);
Buffer_StoreElement(&Tx_Buffer, readByte1); 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 Buffer_StoreElement(&Tx_Buffer, CR_HEX); // return carriage return (CR_HEX) if successful
} else if (firstByte == 'Z') { // Special test command } 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;
}
}

@ -37,6 +37,7 @@
#define _AVRISP_PROGRAMMER_H_ #define _AVRISP_PROGRAMMER_H_
/* Includes: */ /* Includes: */
#include <util/delay.h>
#include <avr/io.h> #include <avr/io.h>
#include <avr/wdt.h> #include <avr/wdt.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
@ -189,6 +190,5 @@
void ReconfigureSPI(void); void ReconfigureSPI(void);
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);
void processHostSPIRequest(void); void processHostSPIRequest(void);
void delay_ms(uint8_t dly);
#endif #endif

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 8000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -161,8 +175,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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 # Place -D or -U options here for ASM sources

@ -90,6 +90,20 @@ BOARD = USBKEY
F_CPU = 16000000 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) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
@ -160,8 +174,9 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # 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 = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" 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_CLOCK="(1 << 0)"
CDEFS += -DMAG_T1_DATA="(1 << 1)" CDEFS += -DMAG_T1_DATA="(1 << 1)"

Loading…
Cancel
Save