Updated LUFA to SVN r2651
This commit is contained in:
@@ -117,6 +117,12 @@
|
||||
* #define BOOTLOADER_ADDRESS_LENGTH 4
|
||||
* \endcode
|
||||
*
|
||||
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
|
||||
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
|
||||
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
|
||||
* to the value \c BOOTLOADER_CDC_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
|
||||
* memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \subsection SSec_API_MemLayout Device Memory Map
|
||||
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
|
||||
*
|
||||
@@ -155,12 +161,6 @@
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
* Bootloaders reporting a device release revision number of 1.00 or greater are bootloader API enabled. From the application
|
||||
* the API support of the bootloader can be detected by reading the FLASH memory bytes located at address \c BOOTLOADER_MAGIC_SIGNATURE_START
|
||||
* and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader can be determined by reading the
|
||||
* FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them to the value \c BOOTLOADER_CDC_SIGNATURE.
|
||||
* The start address of the bootloader can be retrieved by reading the bytes of FLASH memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
|
||||
@@ -33,14 +33,14 @@ BOOT_SECTION_SIZE_KB = 8
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - $(strip $(1)) )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Bootloader linker section flags for relocating the API table sections to
|
||||
# known FLASH addresses - these should not normally be user-edited.
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=.apitable_$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=BootloaderAPI_$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, trampolines, Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, jumptable, JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, signatures, Signatures, 8)
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
*
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4) - <i>See \ref SSec_Aux_Space</i>
|
||||
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) - <i>See \ref SSec_Aux_Space</i>
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
@@ -150,6 +150,16 @@
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_AUX_SECTION_SIZE
|
||||
* | Booloader Start Trampoline |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - (BOOT_AUX_SECTION_SIZE - 4)
|
||||
* | |
|
||||
* | Auxillery Bootloader |
|
||||
* | Space for Smaller Devices |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
|
||||
* | |
|
||||
* | Bootloader Application |
|
||||
@@ -167,6 +177,10 @@
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
* \subsection SSec_Aux_Space Auxiliary Bootloader Section
|
||||
* To make the bootloader function on smaller devices (those with a physical
|
||||
* bootloader section of smaller than 6KB)
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
|
||||
@@ -33,14 +33,14 @@ BOOT_SECTION_SIZE_KB = 8
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - $(strip $(1)) )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Bootloader linker section flags for relocating the API table sections to
|
||||
# known FLASH addresses - these should not normally be user-edited.
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=.apitable_$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=BootloaderAPI_$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, trampolines, Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, jumptable, JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, signatures, Signatures, 8)
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
@@ -33,7 +33,7 @@ BOOT_SECTION_SIZE_KB := 8
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - $(strip $(1)) )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Bootloader user application API functions.
|
||||
*/
|
||||
|
||||
#include "BootloaderAPI.h"
|
||||
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_erase_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_WritePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_write_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
|
||||
{
|
||||
boot_page_fill_safe(Address, Word);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
|
||||
{
|
||||
return boot_signature_byte_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadLock(void)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
|
||||
}
|
||||
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits)
|
||||
{
|
||||
boot_lock_bits_set_safe(LockBits);
|
||||
}
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Bootloader user application API functions.
|
||||
*/
|
||||
|
||||
#include "BootloaderAPI.h"
|
||||
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_erase_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_WritePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_write_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
|
||||
{
|
||||
boot_page_fill_safe(Address, Word);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
|
||||
{
|
||||
return boot_signature_byte_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadLock(void)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
|
||||
}
|
||||
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits)
|
||||
{
|
||||
boot_lock_bits_set_safe(LockBits);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderAPI.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_API_H_
|
||||
#define _BOOTLOADER_API_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/boot.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Function Prototypes: */
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address);
|
||||
void BootloaderAPI_WritePage(const uint32_t Address);
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadLock(void);
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderAPI.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_API_H_
|
||||
#define _BOOTLOADER_API_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/boot.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Function Prototypes: */
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address);
|
||||
void BootloaderAPI_WritePage(const uint32_t Address);
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadLock(void);
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -28,6 +28,19 @@
|
||||
this software.
|
||||
*/
|
||||
|
||||
#if AUX_BOOT_SECTION_SIZE > 0
|
||||
|
||||
#warning Using a AUX bootloader section in addition to the defined bootloader space (see documentation).
|
||||
|
||||
; Trampoline to jump over the AUX bootloader section to the start of the bootloader,
|
||||
; on devices where an AUX bootloader section is used.
|
||||
.section .boot_aux_trampoline, "ax"
|
||||
.global Boot_AUX_Trampoline
|
||||
Boot_AUX_Trampoline:
|
||||
jmp BOOT_START_ADDR
|
||||
|
||||
#endif
|
||||
|
||||
; Trampolines to actual API implementations if the target address is outside the
|
||||
; range of a rjmp instruction (can happen with large bootloader sections)
|
||||
.section .apitable_trampolines, "ax"
|
||||
|
||||
@@ -1,158 +1,176 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the Mass Storage class bootloader. This file contains the complete bootloader logic.
|
||||
*/
|
||||
|
||||
#include "BootloaderMassStorage.h"
|
||||
|
||||
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
|
||||
* passed to all Mass Storage Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
*/
|
||||
USB_ClassInfo_MS_Device_t Disk_MS_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.InterfaceNumber = 0,
|
||||
.DataINEndpoint =
|
||||
{
|
||||
.Address = MASS_STORAGE_IN_EPADDR,
|
||||
.Size = MASS_STORAGE_IO_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.DataOUTEndpoint =
|
||||
{
|
||||
.Address = MASS_STORAGE_OUT_EPADDR,
|
||||
.Size = MASS_STORAGE_IO_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.TotalLUNs = 1,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
GlobalInterruptEnable();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
MS_Device_USBTask(&Disk_MS_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Relocate the interrupt vector table to the bootloader section */
|
||||
MCUCR = (1 << IVCE);
|
||||
MCUCR = (1 << IVSEL);
|
||||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
|
||||
/* Bootloader active LED toggle timer initialization */
|
||||
TIMSK1 = (1 << TOIE1);
|
||||
TCCR1B = ((1 << CS11) | (1 << CS10));
|
||||
}
|
||||
|
||||
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
|
||||
ISR(TIMER1_OVF_vect, ISR_BLOCK)
|
||||
{
|
||||
LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
/* Indicate USB enumerating */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||
* the status LEDs and stops the Mass Storage management task.
|
||||
*/
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
/* Indicate USB not ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Configuration Changed event. */
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
bool ConfigSuccess = true;
|
||||
|
||||
/* Setup Mass Storage Data Endpoints */
|
||||
ConfigSuccess &= MS_Device_ConfigureEndpoints(&Disk_MS_Interface);
|
||||
|
||||
/* Indicate endpoint configuration success or failure */
|
||||
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Control Request reception event. */
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
MS_Device_ProcessControlRequest(&Disk_MS_Interface);
|
||||
}
|
||||
|
||||
/** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed.
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface configuration structure being referenced
|
||||
*/
|
||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
bool CommandSuccess;
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
|
||||
return CommandSuccess;
|
||||
}
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the Mass Storage class bootloader. This file contains the complete bootloader logic.
|
||||
*/
|
||||
|
||||
#include "BootloaderMassStorage.h"
|
||||
|
||||
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
|
||||
* passed to all Mass Storage Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
*/
|
||||
USB_ClassInfo_MS_Device_t Disk_MS_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.InterfaceNumber = 0,
|
||||
.DataINEndpoint =
|
||||
{
|
||||
.Address = MASS_STORAGE_IN_EPADDR,
|
||||
.Size = MASS_STORAGE_IO_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.DataOUTEndpoint =
|
||||
{
|
||||
.Address = MASS_STORAGE_OUT_EPADDR,
|
||||
.Size = MASS_STORAGE_IO_EPSIZE,
|
||||
.Banks = 1,
|
||||
},
|
||||
.TotalLUNs = 1,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
void Application_Jump_Check(void)
|
||||
{
|
||||
bool JumpToApplication = false;
|
||||
|
||||
#if (BOARD == BOARD_LEONARDO)
|
||||
/* Enable pull-up on the IO13 pin so we can use it to select the mode */
|
||||
PORTC |= (1 << 7);
|
||||
Delay_MS(10);
|
||||
JumpToApplication |= ((PINC & (1 << 7)) != 0);
|
||||
PORTC &= ~(1 << 7);
|
||||
#endif
|
||||
|
||||
if (JumpToApplication)
|
||||
{
|
||||
// cppcheck-suppress constStatement
|
||||
((void (*)(void))0x0000)();
|
||||
}
|
||||
}
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
GlobalInterruptEnable();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
MS_Device_USBTask(&Disk_MS_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
static void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Relocate the interrupt vector table to the bootloader section */
|
||||
MCUCR = (1 << IVCE);
|
||||
MCUCR = (1 << IVSEL);
|
||||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
|
||||
/* Bootloader active LED toggle timer initialization */
|
||||
TIMSK1 = (1 << TOIE1);
|
||||
TCCR1B = ((1 << CS11) | (1 << CS10));
|
||||
}
|
||||
|
||||
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
|
||||
ISR(TIMER1_OVF_vect, ISR_BLOCK)
|
||||
{
|
||||
LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
/* Indicate USB enumerating */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||
* the status LEDs and stops the Mass Storage management task.
|
||||
*/
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
/* Indicate USB not ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Configuration Changed event. */
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
bool ConfigSuccess = true;
|
||||
|
||||
/* Setup Mass Storage Data Endpoints */
|
||||
ConfigSuccess &= MS_Device_ConfigureEndpoints(&Disk_MS_Interface);
|
||||
|
||||
/* Indicate endpoint configuration success or failure */
|
||||
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Control Request reception event. */
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
MS_Device_ProcessControlRequest(&Disk_MS_Interface);
|
||||
}
|
||||
|
||||
/** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed.
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface configuration structure being referenced
|
||||
*/
|
||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
bool CommandSuccess;
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
|
||||
return CommandSuccess;
|
||||
}
|
||||
|
||||
@@ -1,80 +1,84 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderMassStorage.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_MASS_STORAGE_H_
|
||||
#define _BOOTLOADER_MASS_STORAGE_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
//#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include "Lib/SCSI.h"
|
||||
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
void EVENT_USB_Device_Connect(void);
|
||||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_ControlRequest(void);
|
||||
|
||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderMassStorage.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_MASS_STORAGE_H_
|
||||
#define _BOOTLOADER_MASS_STORAGE_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include "Lib/SCSI.h"
|
||||
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/* Function Prototypes: */
|
||||
int main(void) AUX_BOOT_SECTION;
|
||||
|
||||
static void SetupHardware(void) AUX_BOOT_SECTION;
|
||||
|
||||
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
|
||||
|
||||
void EVENT_USB_Device_Connect(void) AUX_BOOT_SECTION;
|
||||
void EVENT_USB_Device_Disconnect(void) AUX_BOOT_SECTION;
|
||||
void EVENT_USB_Device_ConfigurationChanged(void) AUX_BOOT_SECTION;
|
||||
void EVENT_USB_Device_ControlRequest(void) AUX_BOOT_SECTION;
|
||||
|
||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,159 +1,181 @@
|
||||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Mass Storage Class USB AVR Bootloader
|
||||
*
|
||||
* \section Sec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Mass Storage Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Bulk-Only Transport</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF Mass Storage Standard \n
|
||||
* USB Bulk-Only Transport Standard \n
|
||||
* SCSI Primary Commands Specification \n
|
||||
* SCSI Block Commands Specification</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section Sec_Description Project Description:
|
||||
*
|
||||
* This bootloader enumerates to the host as a Mass Storage device, capable of reading and writing a new binary
|
||||
* firmware image file, to load firmware onto the AVR.
|
||||
*
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 8KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
|
||||
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
|
||||
*
|
||||
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
|
||||
* bootloader from the normal user application.
|
||||
*
|
||||
* \section Sec_Installation Driver Installation
|
||||
*
|
||||
* This bootloader uses the Mass Storage drivers inbuilt into all modern operating systems, thus no additional
|
||||
* drivers need to be supplied for correct operation.
|
||||
*
|
||||
* \section Sec_HostApp Host Controller Application
|
||||
*
|
||||
* This bootloader is compatible with all operating systems that support the FAT12 file system format. To reprogram the
|
||||
* device, overwrite a file stored on the virtual FAT filesystem with a new binary (BIN format) image. Remember to safely
|
||||
* remove your device from the host using the host OS's ejection APIs, to ensure all data is correctly flushed to the
|
||||
* bootloader's virtual filesystem and not cached in the OS's file system driver.
|
||||
*
|
||||
* The current device firmware can be read from the device by reading a file from the virtual FAT filesystem.
|
||||
*
|
||||
* \section Sec_API User Application API
|
||||
*
|
||||
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
|
||||
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
|
||||
*
|
||||
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
|
||||
* following layout:
|
||||
*
|
||||
* \code
|
||||
* #define BOOTLOADER_API_TABLE_SIZE 32
|
||||
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
|
||||
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
|
||||
*
|
||||
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
|
||||
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
|
||||
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
|
||||
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
|
||||
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
|
||||
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
|
||||
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
|
||||
*
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
|
||||
*
|
||||
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
|
||||
* #define BOOTLOADER_MASS_STORAGE_SIGNATURE 0xDF30
|
||||
*
|
||||
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
|
||||
* #define BOOTLOADER_ADDRESS_LENGTH 4
|
||||
* \endcode
|
||||
*
|
||||
* \subsection SSec_API_MemLayout Device Memory Map
|
||||
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
|
||||
*
|
||||
* \verbatim
|
||||
* +----------------------------+ 0x0000
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | User Application |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
|
||||
* | |
|
||||
* | Bootloader Application |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - 96
|
||||
* | API Table Trampolines |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 32
|
||||
* | Bootloader API Table |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 8
|
||||
* | Bootloader ID Constants |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
* Bootloaders reporting a device release revision number of 1.00 or greater are bootloader API enabled. From the application
|
||||
* the API support of the bootloader can be detected by reading the FLASH memory bytes located at address \c BOOTLOADER_MAGIC_SIGNATURE_START
|
||||
* and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader can be determined by reading the
|
||||
* FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MASS_STORAGE_SIGNATURE.
|
||||
* The start address of the bootloader can be retrieved by reading the bytes of FLASH memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Mass Storage Class USB AVR Bootloader
|
||||
*
|
||||
* \section Sec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4) - <i>See \ref SSec_Aux_Space</i>
|
||||
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) - <i>See \ref SSec_Aux_Space</i>
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Mass Storage Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Bulk-Only Transport</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF Mass Storage Standard \n
|
||||
* USB Bulk-Only Transport Standard \n
|
||||
* SCSI Primary Commands Specification \n
|
||||
* SCSI Block Commands Specification</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section Sec_Description Project Description:
|
||||
*
|
||||
* This bootloader enumerates to the host as a Mass Storage device, capable of reading and writing a new binary
|
||||
* firmware image file, to load firmware onto the AVR.
|
||||
*
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 6KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
|
||||
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
|
||||
*
|
||||
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
|
||||
* bootloader from the normal user application.
|
||||
*
|
||||
* \section Sec_Installation Driver Installation
|
||||
*
|
||||
* This bootloader uses the Mass Storage drivers inbuilt into all modern operating systems, thus no additional
|
||||
* drivers need to be supplied for correct operation.
|
||||
*
|
||||
* \section Sec_HostApp Host Controller Application
|
||||
*
|
||||
* This bootloader is compatible with all operating systems that support the FAT12 file system format. To reprogram the
|
||||
* device, overwrite a file stored on the virtual FAT filesystem with a new binary (BIN format) image. Remember to safely
|
||||
* remove your device from the host using the host OS's ejection APIs, to ensure all data is correctly flushed to the
|
||||
* bootloader's virtual filesystem and not cached in the OS's file system driver.
|
||||
*
|
||||
* The current device firmware can be read from the device by reading a file from the virtual FAT filesystem.
|
||||
*
|
||||
* \section Sec_API User Application API
|
||||
*
|
||||
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
|
||||
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
|
||||
*
|
||||
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
|
||||
* following layout:
|
||||
*
|
||||
* \code
|
||||
* #define BOOTLOADER_API_TABLE_SIZE 32
|
||||
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
|
||||
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
|
||||
*
|
||||
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
|
||||
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
|
||||
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
|
||||
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
|
||||
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
|
||||
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
|
||||
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
|
||||
*
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
|
||||
*
|
||||
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
|
||||
* #define BOOTLOADER_MASS_STORAGE_SIGNATURE 0xDF30
|
||||
*
|
||||
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
|
||||
* #define BOOTLOADER_ADDRESS_LENGTH 4
|
||||
* \endcode
|
||||
*
|
||||
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
|
||||
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
|
||||
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
|
||||
* to the value \c BOOTLOADER_MASS_STORAGE_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes
|
||||
* of FLASH memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \subsection SSec_Aux_Space Auxiliary Bootloader Section
|
||||
* To make the bootloader function on smaller devices (those with a physical bootloader section of smaller than 6KB) a second
|
||||
* section of memory (called the <i>Auxiliary Bootloader Section</i>) is added before the start of the real bootloader section,
|
||||
* and is filled with a portion of the bootloader code. This allows smaller devices to run the bootloader, at the cost of an
|
||||
* additional portion of the device's FLASH (the bootloader section size in KB subtracted from the 6KB total size). A small
|
||||
* trampoline is inserted at the start of the auxiliary section so that the bootloader will run normally in the case of a blank
|
||||
* application section.
|
||||
*
|
||||
* On devices supporting a 8KB bootloader section size, the AUX section is not created in the final binary.
|
||||
*
|
||||
* \subsection SSec_API_MemLayout Device Memory Map
|
||||
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
|
||||
*
|
||||
* \verbatim
|
||||
* +----------------------------+ 0x0000
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | User Application |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE - BOOT_AUX_SECTION_SIZE
|
||||
* | Booloader Start Trampoline |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE - BOOT_AUX_SECTION_SIZE + 4
|
||||
* | |
|
||||
* | Auxiliary Bootloader |
|
||||
* | Space for Smaller Devices |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
|
||||
* | |
|
||||
* | Bootloader Application |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - 96
|
||||
* | API Table Trampolines |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 32
|
||||
* | Bootloader API Table |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 8
|
||||
* | Bootloader ID Constants |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
#define USE_RAM_DESCRIPTORS
|
||||
// #define USE_FLASH_DESCRIPTORS
|
||||
// #define USE_EEPROM_DESCRIPTORS
|
||||
// #define NO_INTERNAL_SERIAL
|
||||
#define NO_INTERNAL_SERIAL
|
||||
#define FIXED_CONTROL_ENDPOINT_SIZE 8
|
||||
#define DEVICE_STATE_AS_GPIOR 0
|
||||
#define FIXED_NUM_CONFIGURATIONS 1
|
||||
|
||||
@@ -1,177 +1,157 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
const USB_Descriptor_Device_t DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = USB_CSCP_NoDeviceClass,
|
||||
.SubClass = USB_CSCP_NoDeviceSubclass,
|
||||
.Protocol = USB_CSCP_NoDeviceProtocol,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2045,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
.ManufacturerStrIndex = NO_DESCRIPTOR,
|
||||
.ProductStrIndex = NO_DESCRIPTOR,
|
||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.MS_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
.Class = MS_CSCP_MassStorageClass,
|
||||
.SubClass = MS_CSCP_SCSITransparentSubclass,
|
||||
.Protocol = MS_CSCP_BulkOnlyTransportProtocol,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MS_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = MASS_STORAGE_IN_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MASS_STORAGE_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
},
|
||||
|
||||
.MS_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = MASS_STORAGE_OUT_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MASS_STORAGE_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
}
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
||||
*/
|
||||
const USB_Descriptor_String_t LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
if (!(DescriptorNumber))
|
||||
{
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
const USB_Descriptor_Device_t DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = USB_CSCP_NoDeviceClass,
|
||||
.SubClass = USB_CSCP_NoDeviceSubclass,
|
||||
.Protocol = USB_CSCP_NoDeviceProtocol,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2045,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
.ManufacturerStrIndex = NO_DESCRIPTOR,
|
||||
.ProductStrIndex = NO_DESCRIPTOR,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.MS_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
.Class = MS_CSCP_MassStorageClass,
|
||||
.SubClass = MS_CSCP_SCSITransparentSubclass,
|
||||
.Protocol = MS_CSCP_BulkOnlyTransportProtocol,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MS_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = MASS_STORAGE_IN_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MASS_STORAGE_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
},
|
||||
|
||||
.MS_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = MASS_STORAGE_OUT_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MASS_STORAGE_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
}
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
/* If/Else If chain compiles slightly smaller than a switch case */
|
||||
if (DescriptorType == DTYPE_Device)
|
||||
{
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
}
|
||||
else if (DescriptorType == DTYPE_Configuration)
|
||||
{
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint address of the Mass Storage device-to-host data IN endpoint. */
|
||||
#define MASS_STORAGE_IN_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||
|
||||
/** Endpoint address of the Mass Storage host-to-device data OUT endpoint. */
|
||||
#define MASS_STORAGE_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
|
||||
|
||||
/** Size in bytes of the Mass Storage data endpoints. */
|
||||
#define MASS_STORAGE_IO_EPSIZE 64
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// Mass Storage Interface
|
||||
USB_Descriptor_Interface_t MS_Interface;
|
||||
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint address of the Mass Storage device-to-host data IN endpoint. */
|
||||
#define MASS_STORAGE_IN_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||
|
||||
/** Endpoint address of the Mass Storage host-to-device data OUT endpoint. */
|
||||
#define MASS_STORAGE_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
|
||||
|
||||
/** Size in bytes of the Mass Storage data endpoints. */
|
||||
#define MASS_STORAGE_IO_EPSIZE 64
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// Mass Storage Interface
|
||||
USB_Descriptor_Interface_t MS_Interface;
|
||||
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3) AUX_BOOT_SECTION;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ static SCSI_Request_Sense_Response_t SenseData =
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise
|
||||
*/
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -104,9 +104,6 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
case SCSI_CMD_READ_CAPACITY_10:
|
||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_SEND_DIAGNOSTIC:
|
||||
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_WRITE_10:
|
||||
CommandSuccess = SCSI_Command_ReadWrite_10(MSInterfaceInfo, DATA_WRITE);
|
||||
break;
|
||||
@@ -116,6 +113,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
case SCSI_CMD_MODE_SENSE_6:
|
||||
CommandSuccess = SCSI_Command_ModeSense_6(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_SEND_DIAGNOSTIC:
|
||||
case SCSI_CMD_START_STOP_UNIT:
|
||||
case SCSI_CMD_TEST_UNIT_READY:
|
||||
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
|
||||
@@ -150,7 +148,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -188,7 +186,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -210,7 +208,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -227,33 +225,6 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Command processing for an issued SCSI SEND DIAGNOSTIC command. This command performs a quick check of the Dataflash ICs on the
|
||||
* board, and indicates if they are present and functioning correctly. Only the Self-Test portion of the diagnostic command is
|
||||
* supported.
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
/* Check to see if the SELF TEST bit is not set */
|
||||
if (!(MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & (1 << 2)))
|
||||
{
|
||||
/* Only self-test supported - update SENSE key and fail the command */
|
||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,
|
||||
SCSI_ASENSE_INVALID_FIELD_IN_CDB,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Command processing for an issued SCSI READ (10) or WRITE (10) command. This command reads in the block start address
|
||||
* and total number of blocks to process, then calls the appropriate low-level Dataflash routine to handle the actual
|
||||
* reading and writing of the data.
|
||||
@@ -261,7 +232,7 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
* \param[in] IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead)
|
||||
@@ -303,7 +274,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include "../BootloaderMassStorage.h"
|
||||
#include "../Descriptors.h"
|
||||
#include "VirtualFAT.h"
|
||||
|
||||
@@ -69,16 +68,15 @@
|
||||
#define DEVICE_TYPE_BLOCK 0x00
|
||||
|
||||
/* Function Prototypes: */
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
|
||||
#if defined(INCLUDE_FROM_SCSI_C)
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead);
|
||||
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
const bool IsDataRead) AUX_BOOT_SECTION;
|
||||
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -75,7 +75,7 @@ static const FATBootBlock_t BootBlock =
|
||||
static FATDirectoryEntry_t FirmwareFileEntries[2] =
|
||||
{
|
||||
/* Root volume label entry; disk label is contained in the Filename and
|
||||
* Extension fields (concantenated) with a special attribute flag - other
|
||||
* Extension fields (concatenated) with a special attribute flag - other
|
||||
* fields are ignored. Should be the same as the label in the boot block.
|
||||
*/
|
||||
{
|
||||
@@ -151,26 +151,28 @@ static void WriteVirtualBlock(const uint16_t BlockNumber)
|
||||
|
||||
if ((BlockNumber >= 4) && (BlockNumber < (4 + FILE_SECTORS(FIRMWARE_FILE_SIZE_BYTES))))
|
||||
{
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
uint32_t WriteFlashAddress = (uint32_t)(BlockNumber - 4) * SECTOR_SIZE_BYTES;
|
||||
#else
|
||||
uint16_t WriteFlashAddress = (uint16_t)(BlockNumber - 4) * SECTOR_SIZE_BYTES;
|
||||
#endif
|
||||
|
||||
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i += 2)
|
||||
{
|
||||
if ((WriteFlashAddress % SPM_PAGESIZE) == 0)
|
||||
{
|
||||
/* Erase the given FLASH page, ready to be programmed */
|
||||
boot_page_erase(WriteFlashAddress);
|
||||
boot_spm_busy_wait();
|
||||
BootloaderAPI_ErasePage(WriteFlashAddress);
|
||||
}
|
||||
|
||||
/* Write the next data word to the FLASH page */
|
||||
boot_page_fill(WriteFlashAddress, (BlockBuffer[i + 1] << 8) | BlockBuffer[i]);
|
||||
BootloaderAPI_FillWord(WriteFlashAddress, (BlockBuffer[i + 1] << 8) | BlockBuffer[i]);
|
||||
WriteFlashAddress += 2;
|
||||
|
||||
if ((WriteFlashAddress % SPM_PAGESIZE) == 0)
|
||||
{
|
||||
/* Write the filled FLASH page to memory */
|
||||
boot_page_write(WriteFlashAddress - SPM_PAGESIZE);
|
||||
boot_spm_busy_wait();
|
||||
BootloaderAPI_WritePage(WriteFlashAddress - SPM_PAGESIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,10 +221,17 @@ static void ReadVirtualBlock(const uint16_t BlockNumber)
|
||||
default: /* Blocks 4 onwards: Data allocation section */
|
||||
if ((BlockNumber >= 4) && (BlockNumber < (4 + FILE_SECTORS(FIRMWARE_FILE_SIZE_BYTES))))
|
||||
{
|
||||
#if (FLASHEND > 0xFFFF)
|
||||
uint32_t ReadFlashAddress = (uint32_t)(BlockNumber - 4) * SECTOR_SIZE_BYTES;
|
||||
|
||||
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i++)
|
||||
BlockBuffer[i] = pgm_read_byte_far(ReadFlashAddress++);
|
||||
#else
|
||||
uint16_t ReadFlashAddress = (uint16_t)(BlockNumber - 4) * SECTOR_SIZE_BYTES;
|
||||
|
||||
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i++)
|
||||
BlockBuffer[i] = pgm_read_byte(ReadFlashAddress++);
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -237,8 +246,8 @@ static void ReadVirtualBlock(const uint16_t BlockNumber)
|
||||
* PC via the USB Mass Storage interface.
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state
|
||||
* \param[in] BlockAddress Data block starting address for the write sequence
|
||||
* \param[in] TotalBlocks Number of blocks of data to write
|
||||
* \param[in] BlockAddress Data block starting address for the write sequence
|
||||
* \param[in] TotalBlocks Number of blocks of data to write
|
||||
*/
|
||||
void VirtualFAT_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const uint32_t BlockAddress,
|
||||
@@ -256,8 +265,8 @@ void VirtualFAT_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
* to the host PC via the USB Mass Storage interface.
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state
|
||||
* \param[in] BlockAddress Data block starting address for the read sequence
|
||||
* \param[in] TotalBlocks Number of blocks of data to read
|
||||
* \param[in] BlockAddress Data block starting address for the read sequence
|
||||
* \param[in] TotalBlocks Number of blocks of data to read
|
||||
*/
|
||||
void VirtualFAT_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const uint32_t BlockAddress,
|
||||
|
||||
@@ -37,9 +37,11 @@
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include "../BootloaderAPI.h"
|
||||
|
||||
/* Macros: */
|
||||
/** Size of the virtual FIRMWARE.BIN file in bytes. */
|
||||
#define FIRMWARE_FILE_SIZE_BYTES (FLASHEND - (FLASHEND - BOOT_START_ADDR))
|
||||
#define FIRMWARE_FILE_SIZE_BYTES (FLASHEND - (FLASHEND - BOOT_START_ADDR) - AUX_BOOT_SECTION_SIZE)
|
||||
|
||||
/** Number of sectors that comprise a single logical disk cluster. */
|
||||
#define SECTOR_PER_CLUSTER 4
|
||||
@@ -144,16 +146,16 @@
|
||||
#if defined(INCLUDE_FROM_VIRTUAL_FAT_C)
|
||||
static void UpdateFAT12ClusterEntry(uint8_t* const FATTable,
|
||||
const uint16_t Index,
|
||||
const uint16_t ChainEntry);
|
||||
static void WriteVirtualBlock(const uint16_t BlockNumber);
|
||||
static void ReadVirtualBlock(const uint16_t BlockNumber);
|
||||
const uint16_t ChainEntry) AUX_BOOT_SECTION;
|
||||
static void WriteVirtualBlock(const uint16_t BlockNumber) AUX_BOOT_SECTION;
|
||||
static void ReadVirtualBlock(const uint16_t BlockNumber) AUX_BOOT_SECTION;
|
||||
#endif
|
||||
|
||||
void VirtualFAT_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const uint32_t BlockAddress,
|
||||
uint16_t TotalBlocks);
|
||||
uint16_t TotalBlocks) AUX_BOOT_SECTION;
|
||||
|
||||
void VirtualFAT_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const uint32_t BlockAddress,
|
||||
uint16_t TotalBlocks);
|
||||
uint16_t TotalBlocks) AUX_BOOT_SECTION;
|
||||
#endif
|
||||
|
||||
@@ -33,14 +33,27 @@ BOOT_SECTION_SIZE_KB = 8
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - $(strip $(1)) )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Bootloader linker section flags for relocating the API table sections to
|
||||
# known FLASH addresses - these should not normally be user-edited.
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=.apitable_$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=BootloaderAPI_$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, trampolines, Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, jumptable, JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, signatures, Signatures, 8)
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
|
||||
|
||||
# Check if the bootloader needs an AUX section, located before the real bootloader section to store some of the
|
||||
# bootloader code. This is required for 32KB and smaller devices, where the actual bootloader is 6KB but the maximum
|
||||
# bootloader section size is 4KB. The actual usable application space will be reduced by 6KB for these devices.
|
||||
ifeq ($(BOOT_SECTION_SIZE_KB),8)
|
||||
CC_FLAGS += -DAUX_BOOT_SECTION='' -DAUX_BOOT_SECTION_SIZE=0
|
||||
else
|
||||
AUX_BOOT_SECTION_SIZE_KB = (6 - $(BOOT_SECTION_SIZE_KB))
|
||||
|
||||
CC_FLAGS += -DAUX_BOOT_SECTION='__attribute__((section(".boot_aux")))' -DAUX_BOOT_SECTION_SIZE='($(AUX_BOOT_SECTION_SIZE_KB) * 1024)'
|
||||
LD_FLAGS += -Wl,--section-start=.boot_aux=$(call BOOT_SEC_OFFSET, (($(BOOT_SECTION_SIZE_KB) + $(AUX_BOOT_SECTION_SIZE_KB)) * 1024 - 16))
|
||||
LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .boot_aux_trampoline, Boot_AUX_Trampoline, ($(BOOT_SECTION_SIZE_KB) + $(AUX_BOOT_SECTION_SIZE_KB)) * 1024)
|
||||
endif
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Bootloader user application API functions.
|
||||
*/
|
||||
|
||||
#include "BootloaderAPI.h"
|
||||
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_erase_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_WritePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_write_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
|
||||
{
|
||||
boot_page_fill_safe(Address, Word);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
|
||||
{
|
||||
return boot_signature_byte_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadLock(void)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
|
||||
}
|
||||
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits)
|
||||
{
|
||||
boot_lock_bits_set_safe(LockBits);
|
||||
}
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Bootloader user application API functions.
|
||||
*/
|
||||
|
||||
#include "BootloaderAPI.h"
|
||||
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_erase_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_WritePage(const uint32_t Address)
|
||||
{
|
||||
boot_page_write_safe(Address);
|
||||
boot_spm_busy_wait();
|
||||
boot_rww_enable();
|
||||
}
|
||||
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
|
||||
{
|
||||
boot_page_fill_safe(Address, Word);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
|
||||
{
|
||||
return boot_signature_byte_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(Address);
|
||||
}
|
||||
|
||||
uint8_t BootloaderAPI_ReadLock(void)
|
||||
{
|
||||
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
|
||||
}
|
||||
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits)
|
||||
{
|
||||
boot_lock_bits_set_safe(LockBits);
|
||||
}
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderAPI.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_API_H_
|
||||
#define _BOOTLOADER_API_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/boot.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Function Prototypes: */
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address);
|
||||
void BootloaderAPI_WritePage(const uint32_t Address);
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadLock(void);
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderAPI.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_API_H_
|
||||
#define _BOOTLOADER_API_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/boot.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Function Prototypes: */
|
||||
void BootloaderAPI_ErasePage(const uint32_t Address);
|
||||
void BootloaderAPI_WritePage(const uint32_t Address);
|
||||
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
|
||||
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
|
||||
uint8_t BootloaderAPI_ReadLock(void);
|
||||
void BootloaderAPI_WriteLock(const uint8_t LockBits);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,407 +1,407 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the Printer class bootloader. This file contains the complete bootloader logic.
|
||||
*/
|
||||
|
||||
#include "BootloaderPrinter.h"
|
||||
|
||||
/** Intel HEX parser state machine state information, to track the contents of
|
||||
* a HEX file streamed in as a sequence of arbitrary bytes.
|
||||
*/
|
||||
struct
|
||||
{
|
||||
/** Current HEX parser state machine state. */
|
||||
uint8_t ParserState;
|
||||
/** Previously decoded numerical byte of data. */
|
||||
uint8_t PrevData;
|
||||
/** Currently decoded numerical byte of data. */
|
||||
uint8_t Data;
|
||||
/** Indicates if both bytes that correspond to a single decoded numerical
|
||||
* byte of data (HEX encodes values in ASCII HEX, two characters per byte)
|
||||
* have been read.
|
||||
*/
|
||||
bool ReadMSB;
|
||||
/** Intel HEX record type of the current Intel HEX record. */
|
||||
uint8_t RecordType;
|
||||
/** Numerical bytes of data remaining to be read in the current record. */
|
||||
uint8_t DataRem;
|
||||
/** Checksum of the current record received so far. */
|
||||
uint8_t Checksum;
|
||||
/** Starting address of the last addressed FLASH page. */
|
||||
uint32_t PageStartAddress;
|
||||
/** Current 32-bit byte extended base address in FLASH being targeted. */
|
||||
uint32_t CurrBaseAddress;
|
||||
/** Current 32-bit byte address in FLASH being targeted. */
|
||||
uint32_t CurrAddress;
|
||||
} HEXParser =
|
||||
{
|
||||
.ParserState = HEX_PARSE_STATE_WAIT_LINE
|
||||
};
|
||||
|
||||
/** Indicates if there is data waiting to be written to a physical page of
|
||||
* memory in FLASH.
|
||||
*/
|
||||
static bool PageDirty = false;
|
||||
|
||||
/**
|
||||
* Determines if a given input byte of data is an ASCII encoded HEX value.
|
||||
*
|
||||
* \note Input HEX bytes are expected to be in uppercase only.
|
||||
*
|
||||
* \param[in] Byte ASCII byte of data to check
|
||||
*
|
||||
* \return Boolean \c true if the input data is ASCII encoded HEX, false otherwise.
|
||||
*/
|
||||
static bool IsHex(const char Byte)
|
||||
{
|
||||
return ((Byte >= 'A') && (Byte <= 'F')) ||
|
||||
((Byte >= '0') && (Byte <= '9'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given input byte of data from an ASCII encoded HEX value to an integer value.
|
||||
*
|
||||
* \note Input HEX bytes are expected to be in uppercase only.
|
||||
*
|
||||
* \param[in] Byte ASCII byte of data to convert
|
||||
*
|
||||
* \return Integer converted value of the input ASCII encoded HEX byte of data.
|
||||
*/
|
||||
static uint8_t HexToDecimal(const char Byte)
|
||||
{
|
||||
if ((Byte >= 'A') && (Byte <= 'F'))
|
||||
return (10 + (Byte - 'A'));
|
||||
else if ((Byte >= '0') && (Byte <= '9'))
|
||||
return (Byte - '0');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an input Intel HEX formatted stream one character at a time, loading
|
||||
* the data contents into the device's internal FLASH memory.
|
||||
*
|
||||
* \param[in] ReadCharacter Next input ASCII byte of data to parse
|
||||
*/
|
||||
static void ParseIntelHEXByte(const char ReadCharacter)
|
||||
{
|
||||
/* Reset the line parser while waiting for a new line to start */
|
||||
if ((HEXParser.ParserState == HEX_PARSE_STATE_WAIT_LINE) || (ReadCharacter == ':'))
|
||||
{
|
||||
HEXParser.Checksum = 0;
|
||||
HEXParser.CurrAddress = HEXParser.CurrBaseAddress;
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
|
||||
HEXParser.ReadMSB = false;
|
||||
|
||||
/* ASCII ':' indicates the start of a new HEX record */
|
||||
if (ReadCharacter == ':')
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_BYTE_COUNT;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Only allow ASCII HEX encoded digits, ignore all other characters */
|
||||
if (!IsHex(ReadCharacter))
|
||||
return;
|
||||
|
||||
/* Read and convert the next nibble of data from the current character */
|
||||
HEXParser.Data = (HEXParser.Data << 4) | HexToDecimal(ReadCharacter);
|
||||
HEXParser.ReadMSB = !HEXParser.ReadMSB;
|
||||
|
||||
/* Only process further when a full byte (two nibbles) have been read */
|
||||
if (HEXParser.ReadMSB)
|
||||
return;
|
||||
|
||||
/* Intel HEX checksum is for all fields except starting character and the
|
||||
* checksum itself
|
||||
*/
|
||||
if (HEXParser.ParserState != HEX_PARSE_STATE_CHECKSUM)
|
||||
HEXParser.Checksum += HEXParser.Data;
|
||||
|
||||
switch (HEXParser.ParserState)
|
||||
{
|
||||
case HEX_PARSE_STATE_BYTE_COUNT:
|
||||
HEXParser.DataRem = HEXParser.Data;
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_ADDRESS_HIGH;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_ADDRESS_HIGH:
|
||||
HEXParser.CurrAddress += ((uint16_t)HEXParser.Data << 8);
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_ADDRESS_LOW;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_ADDRESS_LOW:
|
||||
HEXParser.CurrAddress += HEXParser.Data;
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_RECORD_TYPE;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_RECORD_TYPE:
|
||||
HEXParser.RecordType = HEXParser.Data;
|
||||
HEXParser.ParserState = (HEXParser.DataRem ? HEX_PARSE_STATE_READ_DATA : HEX_PARSE_STATE_CHECKSUM);
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_READ_DATA:
|
||||
/* Track the number of read data bytes in the record */
|
||||
HEXParser.DataRem--;
|
||||
|
||||
/* Protect the bootloader against being written to */
|
||||
if (HEXParser.CurrAddress >= BOOT_START_ADDR)
|
||||
{
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
|
||||
PageDirty = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Wait for a machine word (two bytes) of data to be read */
|
||||
if (HEXParser.DataRem & 0x01)
|
||||
{
|
||||
HEXParser.PrevData = HEXParser.Data;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Convert the last two received data bytes into a 16-bit word */
|
||||
uint16_t NewDataWord = ((uint16_t)HEXParser.Data << 8) | HEXParser.PrevData;
|
||||
|
||||
switch (HEXParser.RecordType)
|
||||
{
|
||||
case HEX_RECORD_TYPE_Data:
|
||||
/* If we are writing to a new page, we need to erase it
|
||||
* first
|
||||
*/
|
||||
if (!(PageDirty))
|
||||
{
|
||||
boot_page_erase(HEXParser.PageStartAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
PageDirty = true;
|
||||
}
|
||||
|
||||
/* Fill the FLASH memory buffer with the new word of data */
|
||||
boot_page_fill(HEXParser.CurrAddress, NewDataWord);
|
||||
HEXParser.CurrAddress += 2;
|
||||
|
||||
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
|
||||
uint32_t NewPageStartAddress = (HEXParser.CurrAddress & ~(SPM_PAGESIZE - 1));
|
||||
if (PageDirty && (HEXParser.PageStartAddress != NewPageStartAddress))
|
||||
{
|
||||
boot_page_write(HEXParser.PageStartAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
HEXParser.PageStartAddress = NewPageStartAddress;
|
||||
|
||||
PageDirty = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case HEX_RECORD_TYPE_ExtendedSegmentAddress:
|
||||
/* Extended address data - store the upper 12-bits of the new address */
|
||||
HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 4);
|
||||
break;
|
||||
|
||||
case HEX_RECORD_TYPE_ExtendedLinearAddress:
|
||||
/* Extended address data - store the upper 16-bits of the new address */
|
||||
HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 16);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!HEXParser.DataRem)
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_CHECKSUM;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_CHECKSUM:
|
||||
/* Verify checksum of the completed record */
|
||||
if (HEXParser.Data != ((~HEXParser.Checksum + 1) & 0xFF))
|
||||
break;
|
||||
|
||||
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
|
||||
uint32_t NewPageStartAddress = (HEXParser.CurrAddress & ~(SPM_PAGESIZE - 1));
|
||||
if (PageDirty && (HEXParser.PageStartAddress != NewPageStartAddress))
|
||||
{
|
||||
boot_page_write(HEXParser.PageStartAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
HEXParser.PageStartAddress = NewPageStartAddress;
|
||||
|
||||
PageDirty = false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
GlobalInterruptEnable();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
USB_USBTask();
|
||||
|
||||
Endpoint_SelectEndpoint(PRINTER_OUT_EPADDR);
|
||||
|
||||
/* Check if we have received new printer data from the host */
|
||||
if (Endpoint_IsOUTReceived()) {
|
||||
LEDs_ToggleLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
/* Read all bytes of data from the host and parse them */
|
||||
while (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Feed the next byte of data to the HEX parser */
|
||||
ParseIntelHEXByte(Endpoint_Read_8());
|
||||
}
|
||||
|
||||
/* Send an ACK to the host, ready for the next data packet */
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Relocate the interrupt vector table to the bootloader section */
|
||||
MCUCR = (1 << IVCE);
|
||||
MCUCR = (1 << IVSEL);
|
||||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
|
||||
/* Bootloader active LED toggle timer initialization */
|
||||
TIMSK1 = (1 << TOIE1);
|
||||
TCCR1B = ((1 << CS11) | (1 << CS10));
|
||||
}
|
||||
|
||||
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
|
||||
ISR(TIMER1_OVF_vect, ISR_BLOCK)
|
||||
{
|
||||
LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
/* Indicate USB enumerating */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||
* the status LEDs and stops the Printer management task.
|
||||
*/
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
/* Indicate USB not ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
|
||||
* of the USB device after enumeration - the device endpoints are configured and the Mass Storage management task started.
|
||||
*/
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
bool ConfigSuccess = true;
|
||||
|
||||
/* Setup Printer Data Endpoints */
|
||||
ConfigSuccess &= Endpoint_ConfigureEndpoint(PRINTER_IN_EPADDR, EP_TYPE_BULK, PRINTER_IO_EPSIZE, 1);
|
||||
ConfigSuccess &= Endpoint_ConfigureEndpoint(PRINTER_OUT_EPADDR, EP_TYPE_BULK, PRINTER_IO_EPSIZE, 1);
|
||||
|
||||
/* Indicate endpoint configuration success or failure */
|
||||
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
|
||||
* the device from the USB host before passing along unhandled control requests to the library for processing
|
||||
* internally.
|
||||
*/
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
/* Process Printer specific control requests */
|
||||
switch (USB_ControlRequest.bRequest)
|
||||
{
|
||||
case PRNT_REQ_GetDeviceID:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* Generic printer IEEE 1284 identification string, will bind to an in-built driver on
|
||||
* Windows systems, and will fall-back to a text-only printer driver on *nix.
|
||||
*/
|
||||
const char PrinterIDString[] =
|
||||
"MFG:Generic;"
|
||||
"MDL:Generic_/_Text_Only;"
|
||||
"CMD:1284.4;"
|
||||
"CLS:PRINTER";
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_Write_16_BE(sizeof(PrinterIDString));
|
||||
Endpoint_Write_Control_Stream_LE(PrinterIDString, strlen(PrinterIDString));
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
break;
|
||||
case PRNT_REQ_GetPortStatus:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_Write_8(PRNT_PORTSTATUS_NOTERROR | PRNT_PORTSTATUS_SELECT);
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
break;
|
||||
case PRNT_REQ_SoftReset:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the Printer class bootloader. This file contains the complete bootloader logic.
|
||||
*/
|
||||
|
||||
#include "BootloaderPrinter.h"
|
||||
|
||||
/** Intel HEX parser state machine state information, to track the contents of
|
||||
* a HEX file streamed in as a sequence of arbitrary bytes.
|
||||
*/
|
||||
struct
|
||||
{
|
||||
/** Current HEX parser state machine state. */
|
||||
uint8_t ParserState;
|
||||
/** Previously decoded numerical byte of data. */
|
||||
uint8_t PrevData;
|
||||
/** Currently decoded numerical byte of data. */
|
||||
uint8_t Data;
|
||||
/** Indicates if both bytes that correspond to a single decoded numerical
|
||||
* byte of data (HEX encodes values in ASCII HEX, two characters per byte)
|
||||
* have been read.
|
||||
*/
|
||||
bool ReadMSB;
|
||||
/** Intel HEX record type of the current Intel HEX record. */
|
||||
uint8_t RecordType;
|
||||
/** Numerical bytes of data remaining to be read in the current record. */
|
||||
uint8_t DataRem;
|
||||
/** Checksum of the current record received so far. */
|
||||
uint8_t Checksum;
|
||||
/** Starting address of the last addressed FLASH page. */
|
||||
uint32_t PageStartAddress;
|
||||
/** Current 32-bit byte extended base address in FLASH being targeted. */
|
||||
uint32_t CurrBaseAddress;
|
||||
/** Current 32-bit byte address in FLASH being targeted. */
|
||||
uint32_t CurrAddress;
|
||||
} HEXParser =
|
||||
{
|
||||
.ParserState = HEX_PARSE_STATE_WAIT_LINE
|
||||
};
|
||||
|
||||
/** Indicates if there is data waiting to be written to a physical page of
|
||||
* memory in FLASH.
|
||||
*/
|
||||
static bool PageDirty = false;
|
||||
|
||||
/**
|
||||
* Determines if a given input byte of data is an ASCII encoded HEX value.
|
||||
*
|
||||
* \note Input HEX bytes are expected to be in uppercase only.
|
||||
*
|
||||
* \param[in] Byte ASCII byte of data to check
|
||||
*
|
||||
* \return Boolean \c true if the input data is ASCII encoded HEX, \c false otherwise.
|
||||
*/
|
||||
static bool IsHex(const char Byte)
|
||||
{
|
||||
return ((Byte >= 'A') && (Byte <= 'F')) ||
|
||||
((Byte >= '0') && (Byte <= '9'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given input byte of data from an ASCII encoded HEX value to an integer value.
|
||||
*
|
||||
* \note Input HEX bytes are expected to be in uppercase only.
|
||||
*
|
||||
* \param[in] Byte ASCII byte of data to convert
|
||||
*
|
||||
* \return Integer converted value of the input ASCII encoded HEX byte of data.
|
||||
*/
|
||||
static uint8_t HexToDecimal(const char Byte)
|
||||
{
|
||||
if ((Byte >= 'A') && (Byte <= 'F'))
|
||||
return (10 + (Byte - 'A'));
|
||||
else if ((Byte >= '0') && (Byte <= '9'))
|
||||
return (Byte - '0');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an input Intel HEX formatted stream one character at a time, loading
|
||||
* the data contents into the device's internal FLASH memory.
|
||||
*
|
||||
* \param[in] ReadCharacter Next input ASCII byte of data to parse
|
||||
*/
|
||||
static void ParseIntelHEXByte(const char ReadCharacter)
|
||||
{
|
||||
/* Reset the line parser while waiting for a new line to start */
|
||||
if ((HEXParser.ParserState == HEX_PARSE_STATE_WAIT_LINE) || (ReadCharacter == ':'))
|
||||
{
|
||||
HEXParser.Checksum = 0;
|
||||
HEXParser.CurrAddress = HEXParser.CurrBaseAddress;
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
|
||||
HEXParser.ReadMSB = false;
|
||||
|
||||
/* ASCII ':' indicates the start of a new HEX record */
|
||||
if (ReadCharacter == ':')
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_BYTE_COUNT;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Only allow ASCII HEX encoded digits, ignore all other characters */
|
||||
if (!IsHex(ReadCharacter))
|
||||
return;
|
||||
|
||||
/* Read and convert the next nibble of data from the current character */
|
||||
HEXParser.Data = (HEXParser.Data << 4) | HexToDecimal(ReadCharacter);
|
||||
HEXParser.ReadMSB = !HEXParser.ReadMSB;
|
||||
|
||||
/* Only process further when a full byte (two nibbles) have been read */
|
||||
if (HEXParser.ReadMSB)
|
||||
return;
|
||||
|
||||
/* Intel HEX checksum is for all fields except starting character and the
|
||||
* checksum itself
|
||||
*/
|
||||
if (HEXParser.ParserState != HEX_PARSE_STATE_CHECKSUM)
|
||||
HEXParser.Checksum += HEXParser.Data;
|
||||
|
||||
switch (HEXParser.ParserState)
|
||||
{
|
||||
case HEX_PARSE_STATE_BYTE_COUNT:
|
||||
HEXParser.DataRem = HEXParser.Data;
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_ADDRESS_HIGH;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_ADDRESS_HIGH:
|
||||
HEXParser.CurrAddress += ((uint16_t)HEXParser.Data << 8);
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_ADDRESS_LOW;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_ADDRESS_LOW:
|
||||
HEXParser.CurrAddress += HEXParser.Data;
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_RECORD_TYPE;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_RECORD_TYPE:
|
||||
HEXParser.RecordType = HEXParser.Data;
|
||||
HEXParser.ParserState = (HEXParser.DataRem ? HEX_PARSE_STATE_READ_DATA : HEX_PARSE_STATE_CHECKSUM);
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_READ_DATA:
|
||||
/* Track the number of read data bytes in the record */
|
||||
HEXParser.DataRem--;
|
||||
|
||||
/* Protect the bootloader against being written to */
|
||||
if (HEXParser.CurrAddress >= BOOT_START_ADDR)
|
||||
{
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
|
||||
PageDirty = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Wait for a machine word (two bytes) of data to be read */
|
||||
if (HEXParser.DataRem & 0x01)
|
||||
{
|
||||
HEXParser.PrevData = HEXParser.Data;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Convert the last two received data bytes into a 16-bit word */
|
||||
uint16_t NewDataWord = ((uint16_t)HEXParser.Data << 8) | HEXParser.PrevData;
|
||||
|
||||
switch (HEXParser.RecordType)
|
||||
{
|
||||
case HEX_RECORD_TYPE_Data:
|
||||
/* If we are writing to a new page, we need to erase it
|
||||
* first
|
||||
*/
|
||||
if (!(PageDirty))
|
||||
{
|
||||
boot_page_erase(HEXParser.PageStartAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
PageDirty = true;
|
||||
}
|
||||
|
||||
/* Fill the FLASH memory buffer with the new word of data */
|
||||
boot_page_fill(HEXParser.CurrAddress, NewDataWord);
|
||||
HEXParser.CurrAddress += 2;
|
||||
|
||||
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
|
||||
uint32_t NewPageStartAddress = (HEXParser.CurrAddress & ~(SPM_PAGESIZE - 1));
|
||||
if (PageDirty && (HEXParser.PageStartAddress != NewPageStartAddress))
|
||||
{
|
||||
boot_page_write(HEXParser.PageStartAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
HEXParser.PageStartAddress = NewPageStartAddress;
|
||||
|
||||
PageDirty = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case HEX_RECORD_TYPE_ExtendedSegmentAddress:
|
||||
/* Extended address data - store the upper 12-bits of the new address */
|
||||
HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 4);
|
||||
break;
|
||||
|
||||
case HEX_RECORD_TYPE_ExtendedLinearAddress:
|
||||
/* Extended address data - store the upper 16-bits of the new address */
|
||||
HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 16);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!HEXParser.DataRem)
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_CHECKSUM;
|
||||
break;
|
||||
|
||||
case HEX_PARSE_STATE_CHECKSUM:
|
||||
/* Verify checksum of the completed record */
|
||||
if (HEXParser.Data != ((~HEXParser.Checksum + 1) & 0xFF))
|
||||
break;
|
||||
|
||||
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
|
||||
uint32_t NewPageStartAddress = (HEXParser.CurrAddress & ~(SPM_PAGESIZE - 1));
|
||||
if (PageDirty && (HEXParser.PageStartAddress != NewPageStartAddress))
|
||||
{
|
||||
boot_page_write(HEXParser.PageStartAddress);
|
||||
boot_spm_busy_wait();
|
||||
|
||||
HEXParser.PageStartAddress = NewPageStartAddress;
|
||||
|
||||
PageDirty = false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
GlobalInterruptEnable();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
USB_USBTask();
|
||||
|
||||
Endpoint_SelectEndpoint(PRINTER_OUT_EPADDR);
|
||||
|
||||
/* Check if we have received new printer data from the host */
|
||||
if (Endpoint_IsOUTReceived()) {
|
||||
LEDs_ToggleLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
/* Read all bytes of data from the host and parse them */
|
||||
while (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Feed the next byte of data to the HEX parser */
|
||||
ParseIntelHEXByte(Endpoint_Read_8());
|
||||
}
|
||||
|
||||
/* Send an ACK to the host, ready for the next data packet */
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
static void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Relocate the interrupt vector table to the bootloader section */
|
||||
MCUCR = (1 << IVCE);
|
||||
MCUCR = (1 << IVSEL);
|
||||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
|
||||
/* Bootloader active LED toggle timer initialization */
|
||||
TIMSK1 = (1 << TOIE1);
|
||||
TCCR1B = ((1 << CS11) | (1 << CS10));
|
||||
}
|
||||
|
||||
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
|
||||
ISR(TIMER1_OVF_vect, ISR_BLOCK)
|
||||
{
|
||||
LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
/* Indicate USB enumerating */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||
* the status LEDs and stops the Printer management task.
|
||||
*/
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
/* Indicate USB not ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
|
||||
* of the USB device after enumeration - the device endpoints are configured and the Mass Storage management task started.
|
||||
*/
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
bool ConfigSuccess = true;
|
||||
|
||||
/* Setup Printer Data Endpoints */
|
||||
ConfigSuccess &= Endpoint_ConfigureEndpoint(PRINTER_IN_EPADDR, EP_TYPE_BULK, PRINTER_IO_EPSIZE, 1);
|
||||
ConfigSuccess &= Endpoint_ConfigureEndpoint(PRINTER_OUT_EPADDR, EP_TYPE_BULK, PRINTER_IO_EPSIZE, 1);
|
||||
|
||||
/* Indicate endpoint configuration success or failure */
|
||||
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
|
||||
* the device from the USB host before passing along unhandled control requests to the library for processing
|
||||
* internally.
|
||||
*/
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
/* Process Printer specific control requests */
|
||||
switch (USB_ControlRequest.bRequest)
|
||||
{
|
||||
case PRNT_REQ_GetDeviceID:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* Generic printer IEEE 1284 identification string, will bind to an in-built driver on
|
||||
* Windows systems, and will fall-back to a text-only printer driver on *nix.
|
||||
*/
|
||||
const char PrinterIDString[] =
|
||||
"MFG:Generic;"
|
||||
"MDL:Generic_/_Text_Only;"
|
||||
"CMD:1284.4;"
|
||||
"CLS:PRINTER";
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_Write_16_BE(sizeof(PrinterIDString));
|
||||
Endpoint_Write_Control_Stream_LE(PrinterIDString, strlen(PrinterIDString));
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
break;
|
||||
case PRNT_REQ_GetPortStatus:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_Write_8(PRNT_PORTSTATUS_NOTERROR | PRNT_PORTSTATUS_SELECT);
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
break;
|
||||
case PRNT_REQ_SoftReset:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,99 +1,99 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderPrinter.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_PRINTER_H_
|
||||
#define _BOOTLOADER_PRINTER_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/* Enums: */
|
||||
/** Intel HEX parser state machine states. */
|
||||
enum HEX_Parser_States_t
|
||||
{
|
||||
HEX_PARSE_STATE_WAIT_LINE, /**< Parser is waiting for a HEX Start of Line character. */
|
||||
HEX_PARSE_STATE_BYTE_COUNT, /**< Parser is waiting for a record byte count. */
|
||||
HEX_PARSE_STATE_ADDRESS_HIGH, /**< Parser is waiting for the MSB of a record address. */
|
||||
HEX_PARSE_STATE_ADDRESS_LOW, /**< Parser is waiting for the LSB of a record address. */
|
||||
HEX_PARSE_STATE_RECORD_TYPE, /**< Parser is waiting for the record type. */
|
||||
HEX_PARSE_STATE_READ_DATA, /**< Parser is waiting for more data in the current record. */
|
||||
HEX_PARSE_STATE_CHECKSUM, /**< Parser is waiting for the checksum of the current record. */
|
||||
};
|
||||
|
||||
/** Intel HEX record types, used to indicate the type of record contained in a line of a HEX file. */
|
||||
enum HEX_Record_Types_t
|
||||
{
|
||||
HEX_RECORD_TYPE_Data = 0, /**< Record contains loadable data. */
|
||||
HEX_RECORD_TYPE_EndOfFile = 1, /**< End of file record. */
|
||||
HEX_RECORD_TYPE_ExtendedSegmentAddress = 2, /**< Extended segment start record. */
|
||||
HEX_RECORD_TYPE_StartSegmentAddress = 3, /**< Normal segment start record. */
|
||||
HEX_RECORD_TYPE_ExtendedLinearAddress = 4, /**< Extended linear address start record. */
|
||||
HEX_RECORD_TYPE_StartLinearAddress = 5, /**< Linear address start record. */
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
void EVENT_USB_Device_Connect(void);
|
||||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_ControlRequest(void);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for BootloaderPrinter.c.
|
||||
*/
|
||||
|
||||
#ifndef _BOOTLOADER_PRINTER_H_
|
||||
#define _BOOTLOADER_PRINTER_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/* Enums: */
|
||||
/** Intel HEX parser state machine states. */
|
||||
enum HEX_Parser_States_t
|
||||
{
|
||||
HEX_PARSE_STATE_WAIT_LINE, /**< Parser is waiting for a HEX Start of Line character. */
|
||||
HEX_PARSE_STATE_BYTE_COUNT, /**< Parser is waiting for a record byte count. */
|
||||
HEX_PARSE_STATE_ADDRESS_HIGH, /**< Parser is waiting for the MSB of a record address. */
|
||||
HEX_PARSE_STATE_ADDRESS_LOW, /**< Parser is waiting for the LSB of a record address. */
|
||||
HEX_PARSE_STATE_RECORD_TYPE, /**< Parser is waiting for the record type. */
|
||||
HEX_PARSE_STATE_READ_DATA, /**< Parser is waiting for more data in the current record. */
|
||||
HEX_PARSE_STATE_CHECKSUM, /**< Parser is waiting for the checksum of the current record. */
|
||||
};
|
||||
|
||||
/** Intel HEX record types, used to indicate the type of record contained in a line of a HEX file. */
|
||||
enum HEX_Record_Types_t
|
||||
{
|
||||
HEX_RECORD_TYPE_Data = 0, /**< Record contains loadable data. */
|
||||
HEX_RECORD_TYPE_EndOfFile = 1, /**< End of file record. */
|
||||
HEX_RECORD_TYPE_ExtendedSegmentAddress = 2, /**< Extended segment start record. */
|
||||
HEX_RECORD_TYPE_StartSegmentAddress = 3, /**< Normal segment start record. */
|
||||
HEX_RECORD_TYPE_ExtendedLinearAddress = 4, /**< Extended linear address start record. */
|
||||
HEX_RECORD_TYPE_StartLinearAddress = 5, /**< Linear address start record. */
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
static void SetupHardware(void);
|
||||
|
||||
void EVENT_USB_Device_Connect(void);
|
||||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_ControlRequest(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,169 +1,169 @@
|
||||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Printer Class USB AVR Bootloader
|
||||
*
|
||||
* \section Sec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Printer Class</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Printer Subclass</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF Printer Class Standard</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section Sec_Description Project Description:
|
||||
*
|
||||
* This bootloader enumerates to the host as a Generic Text Only Printer device, capable of reading and parsing
|
||||
* "printed" plain-text Intel HEX files to load firmware onto the AVR.
|
||||
*
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
|
||||
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
|
||||
*
|
||||
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
|
||||
* bootloader from the normal user application.
|
||||
*
|
||||
* \section Sec_Installation Driver Installation
|
||||
*
|
||||
* This bootloader uses the Generic Text-Only printer drivers inbuilt into all modern operating systems, thus no
|
||||
* additional drivers need to be supplied for correct operation.
|
||||
*
|
||||
* \section Sec_HostApp Host Controller Application
|
||||
*
|
||||
* This bootloader is compatible with Notepad under Windows, and the command line \c lpr utility under Linux.
|
||||
*
|
||||
* \subsection SSec_Notepad Notepad (Windows)
|
||||
*
|
||||
* While most text applications under Windows will be compatible with the bootloader, the inbuilt Notepad utility
|
||||
* is recommended as it will introduce minimal formatting changes to the output stream. To program with Notepad,
|
||||
* open the target HEX file and print it to the Generic Text Only printer device the bootloader creates.
|
||||
*
|
||||
* \subsection SSec_LPR LPR (Linux)
|
||||
*
|
||||
* While the CUPS framework under Linux will enumerate the bootloader as a Generic Text-Only printer, many
|
||||
* applications will refuse to print to the device due to the lack of rich formatting options available. As a result,
|
||||
* under Linux HEX files must be printed via the low level \c lpr utility instead.
|
||||
*
|
||||
* \code
|
||||
* cat Mouse.hex | lpr
|
||||
* \endcode
|
||||
*
|
||||
* \section Sec_API User Application API
|
||||
*
|
||||
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
|
||||
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
|
||||
*
|
||||
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
|
||||
* following layout:
|
||||
*
|
||||
* \code
|
||||
* #define BOOTLOADER_API_TABLE_SIZE 32
|
||||
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
|
||||
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
|
||||
*
|
||||
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
|
||||
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
|
||||
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
|
||||
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
|
||||
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
|
||||
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
|
||||
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
|
||||
*
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
|
||||
*
|
||||
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
|
||||
* #define BOOTLOADER_PRINTER_SIGNATURE 0xDF20
|
||||
*
|
||||
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
|
||||
* #define BOOTLOADER_ADDRESS_LENGTH 4
|
||||
* \endcode
|
||||
*
|
||||
* \subsection SSec_API_MemLayout Device Memory Map
|
||||
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
|
||||
*
|
||||
* \verbatim
|
||||
* +----------------------------+ 0x0000
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | User Application |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
|
||||
* | |
|
||||
* | Bootloader Application |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - 96
|
||||
* | API Table Trampolines |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 32
|
||||
* | Bootloader API Table |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 8
|
||||
* | Bootloader ID Constants |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
* Bootloaders reporting a device release revision number of 1.00 or greater are bootloader API enabled. From the application
|
||||
* the API support of the bootloader can be detected by reading the FLASH memory bytes located at address \c BOOTLOADER_MAGIC_SIGNATURE_START
|
||||
* and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader can be determined by reading the
|
||||
* FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them to the value \c BOOTLOADER_PRINTER_SIGNATURE.
|
||||
* The start address of the bootloader can be retrieved by reading the bytes of FLASH memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Printer Class USB AVR Bootloader
|
||||
*
|
||||
* \section Sec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* \li Series 7 USB AVRs (AT90USBxxx7)
|
||||
* \li Series 6 USB AVRs (AT90USBxxx6)
|
||||
* \li Series 4 USB AVRs (ATMEGAxxU4)
|
||||
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
|
||||
*
|
||||
* \section Sec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Printer Class</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Printer Subclass</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF Printer Class Standard</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Supported USB Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section Sec_Description Project Description:
|
||||
*
|
||||
* This bootloader enumerates to the host as a Generic Text Only Printer device, capable of reading and parsing
|
||||
* "printed" plain-text Intel HEX files to load firmware onto the AVR.
|
||||
*
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
|
||||
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
|
||||
*
|
||||
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
|
||||
* bootloader from the normal user application.
|
||||
*
|
||||
* \section Sec_Installation Driver Installation
|
||||
*
|
||||
* This bootloader uses the Generic Text-Only printer drivers inbuilt into all modern operating systems, thus no
|
||||
* additional drivers need to be supplied for correct operation.
|
||||
*
|
||||
* \section Sec_HostApp Host Controller Application
|
||||
*
|
||||
* This bootloader is compatible with Notepad under Windows, and the command line \c lpr utility under Linux.
|
||||
*
|
||||
* \subsection SSec_Notepad Notepad (Windows)
|
||||
*
|
||||
* While most text applications under Windows will be compatible with the bootloader, the inbuilt Notepad utility
|
||||
* is recommended as it will introduce minimal formatting changes to the output stream. To program with Notepad,
|
||||
* open the target HEX file and print it to the Generic Text Only printer device the bootloader creates.
|
||||
*
|
||||
* \subsection SSec_LPR LPR (Linux)
|
||||
*
|
||||
* While the CUPS framework under Linux will enumerate the bootloader as a Generic Text-Only printer, many
|
||||
* applications will refuse to print to the device due to the lack of rich formatting options available. As a result,
|
||||
* under Linux HEX files must be printed via the low level \c lpr utility instead.
|
||||
*
|
||||
* \code
|
||||
* cat Mouse.hex | lpr
|
||||
* \endcode
|
||||
*
|
||||
* \section Sec_API User Application API
|
||||
*
|
||||
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
|
||||
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
|
||||
*
|
||||
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
|
||||
* following layout:
|
||||
*
|
||||
* \code
|
||||
* #define BOOTLOADER_API_TABLE_SIZE 32
|
||||
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
|
||||
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
|
||||
*
|
||||
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
|
||||
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
|
||||
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
|
||||
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
|
||||
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
|
||||
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
|
||||
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
|
||||
*
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
|
||||
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
|
||||
*
|
||||
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
|
||||
* #define BOOTLOADER_PRINTER_SIGNATURE 0xDF20
|
||||
*
|
||||
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
|
||||
* #define BOOTLOADER_ADDRESS_LENGTH 4
|
||||
* \endcode
|
||||
*
|
||||
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
|
||||
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
|
||||
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
|
||||
* to the value \c BOOTLOADER_PRINTER_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
|
||||
* memory starting from address \c BOOTLOADER_ADDRESS_START.
|
||||
*
|
||||
* \subsection SSec_API_MemLayout Device Memory Map
|
||||
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
|
||||
*
|
||||
* \verbatim
|
||||
* +----------------------------+ 0x0000
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | User Application |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
|
||||
* | |
|
||||
* | Bootloader Application |
|
||||
* | (Not User App. Accessible) |
|
||||
* | |
|
||||
* +----------------------------+ FLASHEND - 96
|
||||
* | API Table Trampolines |
|
||||
* | (Not User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 32
|
||||
* | Bootloader API Table |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND - 8
|
||||
* | Bootloader ID Constants |
|
||||
* | (User App. Accessible) |
|
||||
* +----------------------------+ FLASHEND
|
||||
* \endverbatim
|
||||
*
|
||||
* \section Sec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,209 +1,209 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
const USB_Descriptor_Device_t DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = USB_CSCP_NoDeviceClass,
|
||||
.SubClass = USB_CSCP_NoDeviceSubclass,
|
||||
.Protocol = USB_CSCP_NoDeviceProtocol,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x206B,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.Printer_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
.Class = PRNT_CSCP_PrinterClass,
|
||||
.SubClass = PRNT_CSCP_PrinterSubclass,
|
||||
.Protocol = PRNT_CSCP_BidirectionalProtocol,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.Printer_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = PRINTER_IN_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = PRINTER_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
},
|
||||
|
||||
.Printer_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = PRINTER_OUT_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = PRINTER_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
}
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
||||
*/
|
||||
const USB_Descriptor_String_t LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(23), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"LUFA Printer Bootloader"
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
const USB_Descriptor_Device_t DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = USB_CSCP_NoDeviceClass,
|
||||
.SubClass = USB_CSCP_NoDeviceSubclass,
|
||||
.Protocol = USB_CSCP_NoDeviceProtocol,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x206B,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.Printer_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
.Class = PRNT_CSCP_PrinterClass,
|
||||
.SubClass = PRNT_CSCP_PrinterSubclass,
|
||||
.Protocol = PRNT_CSCP_BidirectionalProtocol,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.Printer_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = PRINTER_IN_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = PRINTER_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
},
|
||||
|
||||
.Printer_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = PRINTER_OUT_EPADDR,
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = PRINTER_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x05
|
||||
}
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
||||
*/
|
||||
const USB_Descriptor_String_t LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(23), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"LUFA Printer Bootloader"
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,77 +1,77 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h>
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint address of the Printer device-to-host data IN endpoint. */
|
||||
#define PRINTER_IN_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||
|
||||
/** Endpoint address of the Printer host-to-device data OUT endpoint. */
|
||||
#define PRINTER_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
|
||||
|
||||
/** Size in bytes of the Printer data endpoints. */
|
||||
#define PRINTER_IO_EPSIZE 64
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// Printer Interface
|
||||
USB_Descriptor_Interface_t Printer_Interface;
|
||||
USB_Descriptor_Endpoint_t Printer_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t Printer_DataOutEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2013.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h>
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint address of the Printer device-to-host data IN endpoint. */
|
||||
#define PRINTER_IN_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||
|
||||
/** Endpoint address of the Printer host-to-device data OUT endpoint. */
|
||||
#define PRINTER_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
|
||||
|
||||
/** Size in bytes of the Printer data endpoints. */
|
||||
#define PRINTER_IO_EPSIZE 64
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// Printer Interface
|
||||
USB_Descriptor_Interface_t Printer_Interface;
|
||||
USB_Descriptor_Endpoint_t Printer_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t Printer_DataOutEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -33,14 +33,14 @@ BOOT_SECTION_SIZE_KB = 8
|
||||
# Do not modify these macros, but rather modify the dependent values above.
|
||||
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
|
||||
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - $(strip $(1)) )
|
||||
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
|
||||
|
||||
# Bootloader linker section flags for relocating the API table sections to
|
||||
# known FLASH addresses - these should not normally be user-edited.
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=.apitable_$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=BootloaderAPI_$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, trampolines, Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, jumptable, JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, signatures, Signatures, 8)
|
||||
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
|
||||
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
|
||||
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU =
|
||||
ARCH =
|
||||
MCU =
|
||||
ARCH =
|
||||
BOARD = NONE
|
||||
F_CPU = $(F_USB)
|
||||
OPTIMIZATION = 1
|
||||
TARGET = Test
|
||||
SRC = $(TARGET)_C.c $(TARGET)_CPP.cpp Dummy.S $(LUFA_SRC_USB)
|
||||
LUFA_PATH = ../../LUFA
|
||||
DEBUG_LEVEL = 0
|
||||
DEBUG_LEVEL = 0
|
||||
|
||||
ifeq ($(ARCH), AVR8)
|
||||
F_USB = 8000000
|
||||
|
||||
@@ -227,7 +227,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
* \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where
|
||||
* the retrieved data is to be stored for GET operations.
|
||||
*
|
||||
* \return Boolean true if the property get/set was successful, false otherwise
|
||||
* \return Boolean \c true if the property get/set was successful, \c false otherwise
|
||||
*/
|
||||
bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
|
||||
const uint8_t EndpointProperty,
|
||||
|
||||
@@ -136,7 +136,7 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
|
||||
@@ -138,7 +138,7 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
|
||||
@@ -138,7 +138,7 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
|
||||
@@ -166,7 +166,7 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
|
||||
@@ -137,7 +137,7 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
|
||||
@@ -501,7 +501,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||
|
||||
/** Performs a simple test on the attached Dataflash IC(s) to ensure that they are working.
|
||||
*
|
||||
* \return Boolean true if all media chips are working, false otherwise
|
||||
* \return Boolean \c true if all media chips are working, \c false otherwise
|
||||
*/
|
||||
bool DataflashManager_CheckDataflashOperation(void)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ static SCSI_Request_Sense_Response_t SenseData =
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise
|
||||
*/
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -150,7 +150,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -210,7 +210,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -233,7 +233,7 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -272,7 +272,7 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
* \param[in] IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead)
|
||||
@@ -330,7 +330,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
|
||||
@@ -501,7 +501,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||
|
||||
/** Performs a simple test on the attached Dataflash IC(s) to ensure that they are working.
|
||||
*
|
||||
* \return Boolean true if all media chips are working, false otherwise
|
||||
* \return Boolean \c true if all media chips are working, \c false otherwise
|
||||
*/
|
||||
bool DataflashManager_CheckDataflashOperation(void)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ static SCSI_Request_Sense_Response_t SenseData =
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise
|
||||
*/
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -150,7 +150,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -210,7 +210,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -233,7 +233,7 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -272,7 +272,7 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
* \param[in] IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead)
|
||||
@@ -330,7 +330,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
|
||||
@@ -193,7 +193,7 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
|
||||
@@ -138,7 +138,7 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
* \param[in] MAC1 First MAC address
|
||||
* \param[in] MAC2 Second MAC address
|
||||
*
|
||||
* \return True if the addresses match, false otherwise
|
||||
* \return True if the addresses match, \c false otherwise
|
||||
*/
|
||||
#define MAC_COMPARE(MAC1, MAC2) (memcmp(MAC1, MAC2, sizeof(MAC_Address_t)) == 0)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
* \param[in] IP1 First IP address
|
||||
* \param[in] IP2 Second IP address
|
||||
*
|
||||
* \return True if the addresses match, false otherwise
|
||||
* \return True if the addresses match, \c false otherwise
|
||||
*/
|
||||
#define IP_COMPARE(IP1, IP2) (memcmp(IP1, IP2, sizeof(IP_Address_t)) == 0)
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ void TCP_Init(void)
|
||||
* \param[in] State New state of the port, a value from the \ref TCP_PortStates_t enum
|
||||
* \param[in] Handler Application callback handler for the port
|
||||
*
|
||||
* \return Boolean true if the port state was set, false otherwise (no more space in the port state table)
|
||||
* \return Boolean \c true if the port state was set, \c false otherwise (no more space in the port state table)
|
||||
*/
|
||||
bool TCP_SetPortState(const uint16_t Port,
|
||||
const uint8_t State,
|
||||
@@ -247,7 +247,7 @@ uint8_t TCP_GetPortState(const uint16_t Port)
|
||||
* \param[in] RemotePort TCP port of the remote device in the connection, specified in big endian
|
||||
* \param[in] State TCP connection state, a value from the \ref TCP_ConnectionStates_t enum
|
||||
*
|
||||
* \return Boolean true if the connection was updated or created, false otherwise (no more space in the connection state table)
|
||||
* \return Boolean \c true if the connection was updated or created, \c false otherwise (no more space in the connection state table)
|
||||
*/
|
||||
bool TCP_SetConnectionState(const uint16_t Port,
|
||||
const IP_Address_t* RemoteAddress,
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
*
|
||||
* \param[in] Buffer Application buffer to check
|
||||
*
|
||||
* \return Boolean true if the buffer contains a packet from the host, false otherwise
|
||||
* \return Boolean \c true if the buffer contains a packet from the host, \c false otherwise
|
||||
*/
|
||||
#define TCP_APP_HAS_RECEIVED_PACKET(Buffer) (Buffer->Ready && (Buffer->Direction == TCP_PACKETDIR_IN))
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
*
|
||||
* \param[in] Buffer Application buffer to check
|
||||
*
|
||||
* \return Boolean true if the buffer has been captured by the application for device-to-host transmissions, false otherwise
|
||||
* \return Boolean \c true if the buffer has been captured by the application for device-to-host transmissions, \c false otherwise
|
||||
*/
|
||||
#define TCP_APP_HAVE_CAPTURED_BUFFER(Buffer) (!(Buffer->Ready) && Buffer->InUse && (Buffer->Direction == TCP_PACKETDIR_OUT))
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
*
|
||||
* \param[in] Buffer Application buffer to check
|
||||
*
|
||||
* \return Boolean true if the buffer may be captured by the application for device-to-host transmissions, false otherwise
|
||||
* \return Boolean \c true if the buffer may be captured by the application for device-to-host transmissions, \c false otherwise
|
||||
*/
|
||||
#define TCP_APP_CAN_CAPTURE_BUFFER(Buffer) Buffer->InUse
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ void Webserver_Init(void)
|
||||
* \param[in] RequestHeader HTTP request made by the host
|
||||
* \param[in] Command HTTP command to compare the request to
|
||||
*
|
||||
* \return Boolean true if the command matches the request, false otherwise
|
||||
* \return Boolean \c true if the command matches the request, \c false otherwise
|
||||
*/
|
||||
static bool IsHTTPCommand(uint8_t* RequestHeader,
|
||||
char* Command)
|
||||
|
||||
@@ -501,7 +501,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||
|
||||
/** Performs a simple test on the attached Dataflash IC(s) to ensure that they are working.
|
||||
*
|
||||
* \return Boolean true if all media chips are working, false otherwise
|
||||
* \return Boolean \c true if all media chips are working, \c false otherwise
|
||||
*/
|
||||
bool DataflashManager_CheckDataflashOperation(void)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ static SCSI_Request_Sense_Response_t SenseData =
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise
|
||||
*/
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -150,7 +150,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -210,7 +210,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -233,7 +233,7 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
@@ -272,7 +272,7 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
* \param[in] IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead)
|
||||
@@ -330,7 +330,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||
*
|
||||
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
|
||||
@@ -203,7 +203,7 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
|
||||
@@ -407,7 +407,7 @@ void TMC_Task(void)
|
||||
*
|
||||
* \param[out] MessageHeader Pointer to a location where the read header (if any) should be stored
|
||||
*
|
||||
* \return Boolean true if a header was read, false otherwise
|
||||
* \return Boolean \c true if a header was read, \c false otherwise
|
||||
*/
|
||||
bool ReadTMCHeader(TMC_MessageHeader_t* const MessageHeader)
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
||||
*
|
||||
* \param[out] ReportData Pointer to a HID report data structure to be filled
|
||||
*
|
||||
* \return Boolean true if the new report differs from the last report, false otherwise
|
||||
* \return Boolean \c true if the new report differs from the last report, \c false otherwise
|
||||
*/
|
||||
bool GetNextReport(USB_JoystickReport_Data_t* const ReportData)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
#include "Keyboard.h"
|
||||
|
||||
/** Indicates what report mode the host has requested, true for normal HID reporting mode, false for special boot
|
||||
/** Indicates what report mode the host has requested, true for normal HID reporting mode, \c false for special boot
|
||||
* protocol reporting mode.
|
||||
*/
|
||||
static bool UsingReportProtocol = true;
|
||||
|
||||
@@ -497,7 +497,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||
|
||||
/** Performs a simple test on the attached Dataflash IC(s) to ensure that they are working.
|
||||
*
|
||||
* \return Boolean true if all media chips are working, false otherwise
|
||||
* \return Boolean \c true if all media chips are working, \c false otherwise
|
||||
*/
|
||||
bool DataflashManager_CheckDataflashOperation(void)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ static SCSI_Request_Sense_Response_t SenseData =
|
||||
* to the appropriate SCSI command handling routine if the issued command is supported by the device, else it returns
|
||||
* a command failure due to a ILLEGAL REQUEST.
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise
|
||||
*/
|
||||
bool SCSI_DecodeSCSICommand(void)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ bool SCSI_DecodeSCSICommand(void)
|
||||
/** Command processing for an issued SCSI INQUIRY command. This command returns information about the device's features
|
||||
* and capabilities to the host.
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Inquiry(void)
|
||||
{
|
||||
@@ -183,7 +183,7 @@ static bool SCSI_Command_Inquiry(void)
|
||||
/** Command processing for an issued SCSI REQUEST SENSE command. This command returns information about the last issued command,
|
||||
* including the error code and additional error information so that the host can determine why a command failed to complete.
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Request_Sense(void)
|
||||
{
|
||||
@@ -208,7 +208,7 @@ static bool SCSI_Command_Request_Sense(void)
|
||||
/** Command processing for an issued SCSI READ CAPACITY (10) command. This command returns information about the device's capacity
|
||||
* on the selected Logical Unit (drive), as a number of OS-sized blocks.
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Read_Capacity_10(void)
|
||||
{
|
||||
@@ -235,7 +235,7 @@ static bool SCSI_Command_Read_Capacity_10(void)
|
||||
* board, and indicates if they are present and functioning correctly. Only the Self-Test portion of the diagnostic command is
|
||||
* supported.
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_Send_Diagnostic(void)
|
||||
{
|
||||
@@ -273,7 +273,7 @@ static bool SCSI_Command_Send_Diagnostic(void)
|
||||
*
|
||||
* \param[in] IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ReadWrite_10(const bool IsDataRead)
|
||||
{
|
||||
@@ -325,7 +325,7 @@ static bool SCSI_Command_ReadWrite_10(const bool IsDataRead)
|
||||
/** Command processing for an issued SCSI MODE SENSE (6) command. This command returns various informational pages about
|
||||
* the SCSI device, as well as the device's Write Protect status.
|
||||
*
|
||||
* \return Boolean true if the command completed successfully, false otherwise.
|
||||
* \return Boolean \c true if the command completed successfully, \c false otherwise.
|
||||
*/
|
||||
static bool SCSI_Command_ModeSense_6(void)
|
||||
{
|
||||
|
||||
@@ -222,7 +222,7 @@ void MassStorage_Task(void)
|
||||
/** Function to read in a command block from the host, via the bulk data OUT endpoint. This function reads in the next command block
|
||||
* if one has been issued, and performs validation to ensure that the block command is valid.
|
||||
*
|
||||
* \return Boolean true if a valid command block has been read in from the endpoint, false otherwise
|
||||
* \return Boolean \c true if a valid command block has been read in from the endpoint, \c false otherwise
|
||||
*/
|
||||
static bool ReadInCommandBlock(void)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "Mouse.h"
|
||||
|
||||
/** Indicates what report mode the host has requested, true for normal HID reporting mode, false for special boot
|
||||
/** Indicates what report mode the host has requested, true for normal HID reporting mode, \c false for special boot
|
||||
* protocol reporting mode.
|
||||
*/
|
||||
static bool UsingReportProtocol = true;
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
* \param[in] MAC1 First MAC address
|
||||
* \param[in] MAC2 Second MAC address
|
||||
*
|
||||
* \return True if the addresses match, false otherwise
|
||||
* \return True if the addresses match, \c false otherwise
|
||||
*/
|
||||
#define MAC_COMPARE(MAC1, MAC2) (memcmp(MAC1, MAC2, sizeof(MAC_Address_t)) == 0)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
* \param[in] IP1 First IP address
|
||||
* \param[in] IP2 Second IP address
|
||||
*
|
||||
* \return True if the addresses match, false otherwise
|
||||
* \return True if the addresses match, \c false otherwise
|
||||
*/
|
||||
#define IP_COMPARE(IP1, IP2) (memcmp(IP1, IP2, sizeof(IP_Address_t)) == 0)
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ void ProcessRNDISControlMessage(void)
|
||||
* \param[out] ResponseData Pointer to the start of the query response inside the RNDIS message buffer
|
||||
* \param[out] ResponseSize Pointer to the size in bytes of the response data being sent to the host
|
||||
*
|
||||
* \return Boolean true if the query was handled, false otherwise
|
||||
* \return Boolean \c true if the query was handled, \c false otherwise
|
||||
*/
|
||||
static bool ProcessNDISQuery(const uint32_t OId, void* QueryData, uint16_t QuerySize,
|
||||
void* ResponseData, uint16_t* ResponseSize)
|
||||
@@ -367,7 +367,7 @@ static bool ProcessNDISQuery(const uint32_t OId, void* QueryData, uint16_t Query
|
||||
* \param[in] SetData Pointer to the parameter value in the RNDIS message buffer
|
||||
* \param[in] SetSize Size in bytes of the parameter value being sent by the host
|
||||
*
|
||||
* \return Boolean true if the set was handled, false otherwise
|
||||
* \return Boolean \c true if the set was handled, \c false otherwise
|
||||
*/
|
||||
static bool ProcessNDISSet(uint32_t OId, void* SetData, uint16_t SetSize)
|
||||
{
|
||||
|
||||
@@ -172,7 +172,7 @@ void TCP_Init(void)
|
||||
* \param[in] State New state of the port, a value from the \ref TCP_PortStates_t enum
|
||||
* \param[in] Handler Application callback handler for the port
|
||||
*
|
||||
* \return Boolean true if the port state was set, false otherwise (no more space in the port state table)
|
||||
* \return Boolean \c true if the port state was set, \c false otherwise (no more space in the port state table)
|
||||
*/
|
||||
bool TCP_SetPortState(const uint16_t Port,
|
||||
const uint8_t State,
|
||||
@@ -246,7 +246,7 @@ uint8_t TCP_GetPortState(const uint16_t Port)
|
||||
* \param[in] RemotePort TCP port of the remote device in the connection, specified in big endian
|
||||
* \param[in] State TCP connection state, a value from the \ref TCP_ConnectionStates_t enum
|
||||
*
|
||||
* \return Boolean true if the connection was updated or created, false otherwise (no more space in the connection state table)
|
||||
* \return Boolean \c true if the connection was updated or created, \c false otherwise (no more space in the connection state table)
|
||||
*/
|
||||
bool TCP_SetConnectionState(const uint16_t Port,
|
||||
const IP_Address_t* RemoteAddress,
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
*
|
||||
* \param[in] Buffer Application buffer to check
|
||||
*
|
||||
* \return Boolean true if the buffer contains a packet from the host, false otherwise
|
||||
* \return Boolean \c true if the buffer contains a packet from the host, \c false otherwise
|
||||
*/
|
||||
#define TCP_APP_HAS_RECEIVED_PACKET(Buffer) (Buffer->Ready && (Buffer->Direction == TCP_PACKETDIR_IN))
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
*
|
||||
* \param[in] Buffer Application buffer to check
|
||||
*
|
||||
* \return Boolean true if the buffer has been captured by the application for device-to-host transmissions, false otherwise
|
||||
* \return Boolean \c true if the buffer has been captured by the application for device-to-host transmissions, \c false otherwise
|
||||
*/
|
||||
#define TCP_APP_HAVE_CAPTURED_BUFFER(Buffer) (!(Buffer->Ready) && Buffer->InUse && \
|
||||
(Buffer->Direction == TCP_PACKETDIR_OUT))
|
||||
@@ -108,7 +108,7 @@
|
||||
*
|
||||
* \param[in] Buffer Application buffer to check
|
||||
*
|
||||
* \return Boolean true if the buffer may be captured by the application for device-to-host transmissions, false otherwise
|
||||
* \return Boolean \c true if the buffer may be captured by the application for device-to-host transmissions, \c false otherwise
|
||||
*/
|
||||
#define TCP_APP_CAN_CAPTURE_BUFFER(Buffer) Buffer->InUse
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ void Webserver_Init(void)
|
||||
* \param[in] RequestHeader HTTP request made by the host
|
||||
* \param[in] Command HTTP command to compare the request to
|
||||
*
|
||||
* \return Boolean true if the command matches the request, false otherwise
|
||||
* \return Boolean \c true if the command matches the request, \c false otherwise
|
||||
*/
|
||||
static bool IsHTTPCommand(uint8_t* RequestHeader,
|
||||
char* Command)
|
||||
|
||||
@@ -103,7 +103,7 @@ void EVENT_USB_Device_StartOfFrame(void)
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent)
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
* \return Boolean \c true to force the sending of the report, \c false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
uint8_t* const ReportID,
|
||||
|
||||
@@ -250,7 +250,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
*
|
||||
* \param[in] CurrentItem Pointer to the item the HID report parser is currently working with
|
||||
*
|
||||
* \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded
|
||||
* \return Boolean \c true if the item should be stored into the HID report structure, \c false if it should be discarded
|
||||
*/
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
||||
{
|
||||
|
||||
@@ -272,7 +272,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
*
|
||||
* \param[in] CurrentItem Pointer to the item the HID report parser is currently working with
|
||||
*
|
||||
* \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded
|
||||
* \return Boolean \c true if the item should be stored into the HID report structure, \c false if it should be discarded
|
||||
*/
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
||||
{
|
||||
|
||||
@@ -259,7 +259,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
*
|
||||
* \param[in] CurrentItem Pointer to the item the HID report parser is currently working with
|
||||
*
|
||||
* \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded
|
||||
* \return Boolean \c true if the item should be stored into the HID report structure, \c false if it should be discarded
|
||||
*/
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ uint8_t GetHIDReportData(void)
|
||||
*
|
||||
* \param[in] CurrentItem Pointer to the item the HID report parser is currently working with
|
||||
*
|
||||
* \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded
|
||||
* \return Boolean \c true if the item should be stored into the HID report structure, \c false if it should be discarded
|
||||
*/
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ uint8_t GetHIDReportData(void)
|
||||
*
|
||||
* \param[in] CurrentItem Pointer to the item the HID report parser is currently working with
|
||||
*
|
||||
* \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded
|
||||
* \return Boolean \c true if the item should be stored into the HID report structure, \c false if it should be discarded
|
||||
*/
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ uint8_t GetHIDReportData(void)
|
||||
*
|
||||
* \param[in] CurrentItem Pointer to the item the HID report parser is currently working with
|
||||
*
|
||||
* \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded
|
||||
* \return Boolean \c true if the item should be stored into the HID report structure, \c false if it should be discarded
|
||||
*/
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
||||
{
|
||||
|
||||
@@ -246,7 +246,7 @@ uint8_t SImage_ReadData(void* const Buffer,
|
||||
|
||||
/** Function to test if a PIMA event block is waiting to be read in from the attached device.
|
||||
*
|
||||
* \return True if an event is waiting to be read in from the device, false otherwise
|
||||
* \return True if an event is waiting to be read in from the device, \c false otherwise
|
||||
*/
|
||||
bool SImage_IsEventReceived(void)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
svn checkout http://lufa-lib.googlecode.com/svn/trunk/ lufa-lib-read-only
|
||||
|
||||
This directory contains LUFA SVN Revision 2644 with the following modifications:
|
||||
This directory contains LUFA SVN Revision 2651 with the following modifications:
|
||||
|
||||
Files Added:
|
||||
|
||||
@@ -1,103 +1,103 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += ATPROGRAM
|
||||
LUFA_BUILD_TARGETS += atprogram atprogram-ee
|
||||
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
||||
LUFA_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM_PORT
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA ATPROGRAM Programmer Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to re-program a device using the Atmel atprogram
|
||||
# utility in AVR Studio 5.x and Atmel Studio 6.0 onwards.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# atprogram - Program target FLASH with application using
|
||||
# atprogram
|
||||
# atprogram-ee - Program target EEPROM with application data
|
||||
# using atprogram
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# MCU - Microcontroller device model name
|
||||
# TARGET - Application name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# ATPROGRAM_PROGRAMMER - Name of programming hardware to use
|
||||
# ATPROGRAM_INTERFACE - Name of programming interface to use
|
||||
# ATPROGRAM_PORT - Name of communication port to use
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
ATPROGRAM_PROGRAMMER ?= jtagice3
|
||||
ATPROGRAM_INTERFACE ?= jtag
|
||||
ATPROGRAM_PORT ?=
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
$(call ERROR_IF_EMPTY, ATPROGRAM_PROGRAMMER)
|
||||
$(call ERROR_IF_EMPTY, ATPROGRAM_INTERFACE)
|
||||
|
||||
# Output Messages
|
||||
MSG_ATPROGRAM_CMD := ' [ATPRGRM] :'
|
||||
|
||||
# Construct base atprogram command flags
|
||||
BASE_ATPROGRAM_FLAGS := --tool $(ATPROGRAM_PROGRAMMER) --interface $(ATPROGRAM_INTERFACE) --device $(MCU)
|
||||
ifneq ($(ATPROGRAM_PORT),)
|
||||
BASE_ATPROGRAM_FLAGS += --port $(ATPROGRAM_PORT)
|
||||
endif
|
||||
|
||||
# Construct the flags to use for the various memory spaces
|
||||
ifeq ($(ARCH), AVR8)
|
||||
ATPROGRAM_FLASH_FLAGS := --chiperase --flash
|
||||
ATPROGRAM_EEPROM_FLAGS := --eeprom
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
ATPROGRAM_FLASH_FLAGS := --erase --flash
|
||||
ATPROGRAM_EEPROM_FLAGS := --eeprom
|
||||
else ifeq ($(ARCH), UC3)
|
||||
ATPROGRAM_FLASH_FLAGS := --erase
|
||||
ATPROGRAM_EEPROM_FLAGS := --eeprom
|
||||
else
|
||||
$(error Unsupported architecture "$(ARCH)")
|
||||
endif
|
||||
|
||||
# Programs in the target FLASH memory using ATPROGRAM
|
||||
atprogram: $(TARGET).elf $(MAKEFILE_LIST)
|
||||
@echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" FLASH using \"$(ATPROGRAM_PROGRAMMER)\"
|
||||
atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_FLASH_FLAGS) --file $<
|
||||
|
||||
# Programs in the target EEPROM memory using ATPROGRAM
|
||||
atprogram-ee: $(TARGET).elf $(MAKEFILE_LIST)
|
||||
@echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" EEPROM using \"$(ATPROGRAM_PROGRAMMER)\"
|
||||
atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_EEPROM_FLAGS) --file $<
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: atprogram atprogram-ee
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += ATPROGRAM
|
||||
LUFA_BUILD_TARGETS += atprogram atprogram-ee
|
||||
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
||||
LUFA_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM_PORT
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA ATPROGRAM Programmer Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to re-program a device using the Atmel atprogram
|
||||
# utility in AVR Studio 5.x and Atmel Studio 6.0 onwards.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# atprogram - Program target FLASH with application using
|
||||
# atprogram
|
||||
# atprogram-ee - Program target EEPROM with application data
|
||||
# using atprogram
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# MCU - Microcontroller device model name
|
||||
# TARGET - Application name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# ATPROGRAM_PROGRAMMER - Name of programming hardware to use
|
||||
# ATPROGRAM_INTERFACE - Name of programming interface to use
|
||||
# ATPROGRAM_PORT - Name of communication port to use
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
ATPROGRAM_PROGRAMMER ?= jtagice3
|
||||
ATPROGRAM_INTERFACE ?= jtag
|
||||
ATPROGRAM_PORT ?=
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
$(call ERROR_IF_EMPTY, ATPROGRAM_PROGRAMMER)
|
||||
$(call ERROR_IF_EMPTY, ATPROGRAM_INTERFACE)
|
||||
|
||||
# Output Messages
|
||||
MSG_ATPROGRAM_CMD := ' [ATPRGRM] :'
|
||||
|
||||
# Construct base atprogram command flags
|
||||
BASE_ATPROGRAM_FLAGS := --tool $(ATPROGRAM_PROGRAMMER) --interface $(ATPROGRAM_INTERFACE) --device $(MCU)
|
||||
ifneq ($(ATPROGRAM_PORT),)
|
||||
BASE_ATPROGRAM_FLAGS += --port $(ATPROGRAM_PORT)
|
||||
endif
|
||||
|
||||
# Construct the flags to use for the various memory spaces
|
||||
ifeq ($(ARCH), AVR8)
|
||||
ATPROGRAM_FLASH_FLAGS := --chiperase --flash
|
||||
ATPROGRAM_EEPROM_FLAGS := --eeprom
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
ATPROGRAM_FLASH_FLAGS := --erase --flash
|
||||
ATPROGRAM_EEPROM_FLAGS := --eeprom
|
||||
else ifeq ($(ARCH), UC3)
|
||||
ATPROGRAM_FLASH_FLAGS := --erase
|
||||
ATPROGRAM_EEPROM_FLAGS := --eeprom
|
||||
else
|
||||
$(error Unsupported architecture "$(ARCH)")
|
||||
endif
|
||||
|
||||
# Programs in the target FLASH memory using ATPROGRAM
|
||||
atprogram: $(TARGET).elf $(MAKEFILE_LIST)
|
||||
@echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" FLASH using \"$(ATPROGRAM_PROGRAMMER)\"
|
||||
atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_FLASH_FLAGS) --file $<
|
||||
|
||||
# Programs in the target EEPROM memory using ATPROGRAM
|
||||
atprogram-ee: $(TARGET).elf $(MAKEFILE_LIST)
|
||||
@echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" EEPROM using \"$(ATPROGRAM_PROGRAMMER)\"
|
||||
atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_EEPROM_FLAGS) --file $<
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: atprogram atprogram-ee
|
||||
|
||||
@@ -1,96 +1,86 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += AVRDUDE
|
||||
LUFA_BUILD_TARGETS += avrdude avrdude-ee
|
||||
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
||||
LUFA_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA AVRDUDE Programmer Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to re-program a device using the open source
|
||||
# avr-dude utility.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# avrdude - Program target FLASH with application using
|
||||
# avrdude
|
||||
# avrdude-ee - Program target EEPROM with application data
|
||||
# using avrdude
|
||||
# cdc - Program target (with CDC Bootloader) FLASH
|
||||
# with application using avrdude
|
||||
# cdc-ee - Program target (with CDC Bootloader) EEPROM
|
||||
# with application using avrdude
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# MCU - Microcontroller device model name
|
||||
# TARGET - Application name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# AVRDUDE_PROGRAMMER - Name of programming hardware to use
|
||||
# AVRDUDE_PORT - Name of communication port to use
|
||||
# AVRDUDE_FLAGS - Flags to pass to avr-dude
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
AVRDUDE_PROGRAMMER ?= jtagicemkii
|
||||
AVRDUDE_PORT ?= usb
|
||||
AVRDUDE_FLAGS ?=
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
$(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
|
||||
$(call ERROR_IF_EMPTY, AVRDUDE_PORT)
|
||||
|
||||
# Output Messages
|
||||
MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
|
||||
|
||||
# Construct base avrdude command flags
|
||||
BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||
|
||||
# Programs in the target FLASH memory using AVRDUDE
|
||||
avrdude: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
|
||||
avrdude $(BASE_AVRDUDE_FLAGS) -U flash:w:$< $(AVRDUDE_FLAGS)
|
||||
|
||||
# Programs in the target EEPROM memory using AVRDUDE
|
||||
avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
|
||||
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
|
||||
avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
|
||||
|
||||
cdc: $(TARGET).hex
|
||||
avrdude -v -v -c avr109 -P $(CDC_BOOTLOADER_PORT) -p $(MCU) -U flash:w:$(TARGET).hex
|
||||
|
||||
cdc-ee: $(TARGET).hex
|
||||
avrdude -v -v -c avr109 -P $(CDC_BOOTLOADER_PORT) -p $(MCU) -U eeprom:w:$(TARGET).eep
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: avrdude avrdude-ee cdc cdc-ee
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += AVRDUDE
|
||||
LUFA_BUILD_TARGETS += avrdude avrdude-ee
|
||||
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
||||
LUFA_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA AVRDUDE Programmer Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to re-program a device using the open source
|
||||
# avr-dude utility.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# avrdude - Program target FLASH with application using
|
||||
# avrdude
|
||||
# avrdude-ee - Program target EEPROM with application data
|
||||
# using avrdude
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# MCU - Microcontroller device model name
|
||||
# TARGET - Application name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# AVRDUDE_PROGRAMMER - Name of programming hardware to use
|
||||
# AVRDUDE_PORT - Name of communication port to use
|
||||
# AVRDUDE_FLAGS - Flags to pass to avr-dude
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
AVRDUDE_PROGRAMMER ?= jtagicemkii
|
||||
AVRDUDE_PORT ?= usb
|
||||
AVRDUDE_FLAGS ?=
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
$(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
|
||||
$(call ERROR_IF_EMPTY, AVRDUDE_PORT)
|
||||
|
||||
# Output Messages
|
||||
MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
|
||||
|
||||
# Construct base avrdude command flags
|
||||
BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||
|
||||
# Programs in the target FLASH memory using AVRDUDE
|
||||
avrdude: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
|
||||
avrdude $(BASE_AVRDUDE_FLAGS) -U flash:w:$< $(AVRDUDE_FLAGS)
|
||||
|
||||
# Programs in the target EEPROM memory using AVRDUDE
|
||||
avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
|
||||
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
|
||||
avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: avrdude avrdude-ee
|
||||
|
||||
@@ -1,339 +1,339 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += BUILD
|
||||
LUFA_BUILD_TARGETS += size symbol-sizes all lib elf hex lss clean mostlyclean
|
||||
LUFA_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC F_USB LUFA_PATH
|
||||
LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES DEBUG_TYPE DEBUG_LEVEL LINKER_RELAXATIONS
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA GCC Compiler Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to build a C, C++ and/or Assembly application
|
||||
# via the AVR-GCC compiler.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# size - List built application size
|
||||
# symbol-sizes - Print application symbols from the binary ELF
|
||||
# file as a list sorted by size in bytes
|
||||
# all - Build application and list size
|
||||
# lib - Build and archive source files into a library
|
||||
# elf - Build application ELF debug object file
|
||||
# hex - Build application HEX object files
|
||||
# lss - Build application LSS assembly listing file
|
||||
# clean - Remove all project intermediatary and binary
|
||||
# output files
|
||||
# mostlyclean - Remove intermediatary output files, but
|
||||
# preserve binaries
|
||||
# <filename>.s - Compile C/C++ source file into an assembly file
|
||||
# for manual code inspection
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# TARGET - Application name
|
||||
# ARCH - Device architecture name
|
||||
# MCU - Microcontroller device model name
|
||||
# SRC - List of input source files (*.c, *.cpp, *.S)
|
||||
# F_USB - Speed of the input clock of the USB controller
|
||||
# in Hz
|
||||
# LUFA_PATH - Path to the LUFA library core
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# BOARD - LUFA board hardware
|
||||
# OPTIMIZATION - Optimization level
|
||||
# C_STANDARD - C Language Standard to use
|
||||
# CPP_STANDARD - C++ Language Standard to use
|
||||
# F_CPU - Speed of the CPU, in Hz
|
||||
# C_FLAGS - Flags to pass to the C compiler only
|
||||
# CPP_FLAGS - Flags to pass to the C++ compiler only
|
||||
# ASM_FLAGS - Flags to pass to the assembler only
|
||||
# CC_FLAGS - Common flags to pass to the C/C++ compiler and
|
||||
# assembler
|
||||
# LD_FLAGS - Flags to pass to the linker
|
||||
# LINKER_RELAXATIONS - Enable or disable linker relaxations to
|
||||
# decrease binary size (note: can cause link
|
||||
# failures on systems with an unpatched binutils)
|
||||
# OBJDIR - Directory for the output object and dependency
|
||||
# files; if equal to ".", the output files will
|
||||
# be generated in the same folder as the sources
|
||||
# OBJECT_FILES - Extra object files to link in to the binaries
|
||||
# DEBUG_FORMAT - Format of the debugging information to
|
||||
# generate in the compiled object files
|
||||
# DEBUG_LEVEL - Level the debugging information to generate in
|
||||
# the compiled object files
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
BOARD ?= NONE
|
||||
OPTIMIZATION ?= s
|
||||
F_CPU ?=
|
||||
C_STANDARD ?= gnu99
|
||||
CPP_STANDARD ?= gnu++98
|
||||
C_FLAGS ?=
|
||||
CPP_FLAGS ?=
|
||||
ASM_FLAGS ?=
|
||||
CC_FLAGS ?=
|
||||
OBJDIR ?= .
|
||||
OBJECT_FILES ?=
|
||||
DEBUG_FORMAT ?= dwarf-2
|
||||
DEBUG_LEVEL ?= 2
|
||||
LINKER_RELAXATIONS ?= Y
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
$(call ERROR_IF_EMPTY, ARCH)
|
||||
$(call ERROR_IF_EMPTY, F_USB)
|
||||
$(call ERROR_IF_EMPTY, LUFA_PATH)
|
||||
$(call ERROR_IF_EMPTY, BOARD)
|
||||
$(call ERROR_IF_EMPTY, OPTIMIZATION)
|
||||
$(call ERROR_IF_EMPTY, C_STANDARD)
|
||||
$(call ERROR_IF_EMPTY, CPP_STANDARD)
|
||||
$(call ERROR_IF_EMPTY, OBJDIR)
|
||||
$(call ERROR_IF_EMPTY, DEBUG_FORMAT)
|
||||
$(call ERROR_IF_EMPTY, DEBUG_LEVEL)
|
||||
$(call ERROR_IF_NONBOOL, LINKER_RELAXATIONS)
|
||||
|
||||
# Determine the utility prefix to use for the selected architecture
|
||||
ifeq ($(ARCH), AVR8)
|
||||
CROSS := avr
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
CROSS := avr
|
||||
$(warning The XMEGA device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)
|
||||
else ifeq ($(ARCH), UC3)
|
||||
CROSS := avr32
|
||||
$(warning The UC3 device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)
|
||||
else
|
||||
$(error Unsupported architecture "$(ARCH)")
|
||||
endif
|
||||
|
||||
# Output Messages
|
||||
MSG_INFO_MESSAGE := ' [INFO] :'
|
||||
MSG_COMPILE_CMD := ' [GCC] :'
|
||||
MSG_ASSEMBLE_CMD := ' [GAS] :'
|
||||
MSG_NM_CMD := ' [NM] :'
|
||||
MSG_REMOVE_CMD := ' [RM] :'
|
||||
MSG_LINK_CMD := ' [LNK] :'
|
||||
MSG_ARCHIVE_CMD := ' [AR] :'
|
||||
MSG_SIZE_CMD := ' [SIZE] :'
|
||||
MSG_OBJCPY_CMD := ' [OBJCPY] :'
|
||||
MSG_OBJDMP_CMD := ' [OBJDMP] :'
|
||||
|
||||
# Convert input source file list to differentiate them by type
|
||||
C_SOURCE := $(filter %.c, $(SRC))
|
||||
CPP_SOURCE := $(filter %.cpp, $(SRC))
|
||||
ASM_SOURCE := $(filter %.S, $(SRC))
|
||||
|
||||
# Create a list of unknown source file types, if any are found throw an error
|
||||
UNKNOWN_SOURCE := $(filter-out $(C_SOURCE) $(CPP_SOURCE) $(ASM_SOURCE), $(SRC))
|
||||
ifneq ($(UNKNOWN_SOURCE),)
|
||||
$(error Unknown input source file formats: $(UNKNOWN_SOURCE))
|
||||
endif
|
||||
|
||||
# Convert input source filenames into a list of required output object files
|
||||
OBJECT_FILES += $(addsuffix .o, $(basename $(SRC)))
|
||||
|
||||
# Check if an output object file directory was specified instead of the input file location
|
||||
ifneq ($(OBJDIR),.)
|
||||
# Prefix all the object filenames with the output object file directory path
|
||||
OBJECT_FILES := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(notdir $(OBJECT_FILES)))
|
||||
|
||||
# Check if any object file (without path) appears more than once in the object file list
|
||||
ifneq ($(words $(sort $(OBJECT_FILES))), $(words $(OBJECT_FILES)))
|
||||
$(error Cannot build with OBJDIR parameter set - one or more object file name is not unique)
|
||||
endif
|
||||
|
||||
# Create the output object file directory if it does not exist and add it to the virtual path list
|
||||
$(shell mkdir $(OBJDIR) 2> /dev/null)
|
||||
VPATH += $(dir $(SRC))
|
||||
endif
|
||||
|
||||
# Create a list of dependency files from the list of object files
|
||||
DEPENDENCY_FILES := $(OBJECT_FILES:%.o=%.d)
|
||||
|
||||
# Create a list of common flags to pass to the compiler/linker/assembler
|
||||
BASE_CC_FLAGS := -pipe -g$(DEBUG_FORMAT) -g$(DEBUG_LEVEL)
|
||||
ifeq ($(ARCH), AVR8)
|
||||
BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct
|
||||
else ifeq ($(ARCH), UC3)
|
||||
BASE_CC_FLAGS += -mpart=$(MCU:at32%=%) -masm-addr-pseudos
|
||||
endif
|
||||
BASE_CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections
|
||||
BASE_CC_FLAGS += -I. -I$(patsubst %/,%,$(LUFA_PATH))/..
|
||||
BASE_CC_FLAGS += -DARCH=ARCH_$(ARCH) -DBOARD=BOARD_$(BOARD) -DF_USB=$(F_USB)UL
|
||||
ifneq ($(F_CPU),)
|
||||
BASE_CC_FLAGS += -DF_CPU=$(F_CPU)UL
|
||||
endif
|
||||
|
||||
# Additional language specific compiler flags
|
||||
BASE_C_FLAGS := -x c -O$(OPTIMIZATION) -std=$(C_STANDARD) -Wstrict-prototypes
|
||||
BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD)
|
||||
BASE_ASM_FLAGS := -x assembler-with-cpp
|
||||
|
||||
# Create a list of flags to pass to the linker
|
||||
BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections
|
||||
ifeq ($(LINKER_RELAXATIONS), Y)
|
||||
BASE_LD_FLAGS += -Wl,--relax
|
||||
endif
|
||||
ifeq ($(ARCH), AVR8)
|
||||
BASE_LD_FLAGS += -mmcu=$(MCU)
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
BASE_LD_FLAGS += -mmcu=$(MCU)
|
||||
else ifeq ($(ARCH), UC3)
|
||||
BASE_LD_FLAGS += -mpart=$(MCU:at32%=%) --rodata-writable --direct-data
|
||||
endif
|
||||
|
||||
# Determine flags to pass to the size utility based on its reported features (only invoke if size target required)
|
||||
# and on an architecture where this non-standard patch is available
|
||||
ifneq ($(ARCH), UC3)
|
||||
size: SIZE_MCU_FLAG := $(shell $(CROSS)-size --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
|
||||
size: SIZE_FORMAT_FLAG := $(shell $(CROSS)-size --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
|
||||
endif
|
||||
|
||||
# Pre-build informational target, to give compiler and project name information when building
|
||||
build_begin:
|
||||
@echo $(MSG_INFO_MESSAGE) Begin compilation of project \"$(TARGET)\"...
|
||||
@echo ""
|
||||
@$(CROSS)-gcc --version
|
||||
|
||||
# Post-build informational target, to project name information when building has completed
|
||||
build_end:
|
||||
@echo $(MSG_INFO_MESSAGE) Finished building project \"$(TARGET)\".
|
||||
|
||||
# Prints size information of a compiled application (FLASH, RAM and EEPROM usages)
|
||||
size: $(TARGET).elf
|
||||
@echo $(MSG_SIZE_CMD) Determining size of \"$<\"
|
||||
@echo ""
|
||||
$(CROSS)-size $(SIZE_MCU_FLAG) $(SIZE_FORMAT_FLAG) $<
|
||||
|
||||
# Prints size information on the symbols within a compiled application in decimal bytes
|
||||
symbol-sizes: $(TARGET).elf
|
||||
@echo $(MSG_NM_CMD) Extracting \"$<\" symbols with decimal byte sizes
|
||||
$(CROSS)-nm --size-sort --demangle --radix=d $<
|
||||
|
||||
# Cleans intermediary build files, leaving only the compiled application files
|
||||
mostlyclean:
|
||||
@echo $(MSG_REMOVE_CMD) Removing object files of \"$(TARGET)\"
|
||||
rm -f $(OBJECT_FILES)
|
||||
@echo $(MSG_REMOVE_CMD) Removing dependency files of \"$(TARGET)\"
|
||||
rm -f $(DEPENDENCY_FILES)
|
||||
|
||||
# Cleans all build files, leaving only the original source code
|
||||
clean: mostlyclean
|
||||
@echo $(MSG_REMOVE_CMD) Removing output files of \"$(TARGET)\"
|
||||
rm -f $(TARGET).elf $(TARGET).hex $(TARGET).bin $(TARGET).eep $(TARGET).map $(TARGET).lss $(TARGET).sym $(TARGET).a
|
||||
|
||||
# Performs a complete build of the user application and prints size information afterwards
|
||||
all: build_begin elf hex bin lss sym size build_end
|
||||
|
||||
# Helper targets, to build a specific type of output file without having to know the project target name
|
||||
lib: lib$(TARGET).a
|
||||
elf: $(TARGET).elf
|
||||
hex: $(TARGET).hex $(TARGET).eep
|
||||
bin: $(TARGET).bin $(TARGET).eep
|
||||
lss: $(TARGET).lss
|
||||
sym: $(TARGET).sym
|
||||
|
||||
# Default target to *create* the user application's specified source files; if this rule is executed by
|
||||
# make, the input source file doesn't exist and an error needs to be presented to the user
|
||||
$(SRC):
|
||||
$(error Source file does not exist: $@)
|
||||
|
||||
# Compiles an input C source file and generates an assembly listing for it
|
||||
%.s: %.c $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COMPILE_CMD) Generating assembly from C file \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -S $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) $< -o $@
|
||||
|
||||
# Compiles an input C++ source file and generates an assembly listing for it
|
||||
%.s: %.cpp $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COMPILE_CMD) Generating assembly from C++ file \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -S $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) $< -o $@
|
||||
|
||||
# Compiles an input C source file and generates a linkable object file for it
|
||||
$(OBJDIR)/%.o: %.c $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COMPILE_CMD) Compiling C file \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
|
||||
|
||||
# Compiles an input C++ source file and generates a linkable object file for it
|
||||
$(OBJDIR)/%.o: %.cpp $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COMPILE_CMD) Compiling C++ file \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
|
||||
|
||||
# Assembles an input ASM source file and generates a linkable object file for it
|
||||
$(OBJDIR)/%.o: %.S $(MAKEFILE_LIST)
|
||||
@echo $(MSG_ASSEMBLE_CMD) Assembling \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_ASM_FLAGS) $(CC_FLAGS) $(ASM_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
|
||||
|
||||
# Generates a library archive file from the user application, which can be linked into other applications
|
||||
.PRECIOUS : $(OBJECT_FILES)
|
||||
.SECONDARY : %.a
|
||||
%.a: $(OBJECT_FILES)
|
||||
@echo $(MSG_ARCHIVE_CMD) Archiving object files into \"$@\"
|
||||
$(CROSS)-ar rcs $@ $(OBJECT_FILES)
|
||||
|
||||
# Generates an ELF debug file from the user application, which can be further processed for FLASH and EEPROM data
|
||||
# files, or used for programming and debugging directly
|
||||
.PRECIOUS : $(OBJECT_FILES)
|
||||
.SECONDARY : %.elf
|
||||
%.elf: $(OBJECT_FILES)
|
||||
@echo $(MSG_LINK_CMD) Linking object files into \"$@\"
|
||||
$(CROSS)-gcc $^ -o $@ $(BASE_LD_FLAGS) $(LD_FLAGS)
|
||||
|
||||
# Extracts out the loadable FLASH memory data from the project ELF file, and creates an Intel HEX format file of it
|
||||
%.hex: %.elf
|
||||
@echo $(MSG_OBJCPY_CMD) Extracting HEX file data from \"$<\"
|
||||
$(CROSS)-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
||||
|
||||
# Extracts out the loadable FLASH memory data from the project ELF file, and creates an Binary format file of it
|
||||
%.bin: %.elf
|
||||
@echo $(MSG_OBJCPY_CMD) Extracting BIN file data from \"$<\"
|
||||
$(CROSS)-objcopy -O binary -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
||||
|
||||
# Extracts out the loadable EEPROM memory data from the project ELF file, and creates an Intel HEX format file of it
|
||||
%.eep: %.elf
|
||||
@echo $(MSG_OBJCPY_CMD) Extracting EEP file data from \"$<\"
|
||||
$(CROSS)-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $< $@ || exit 0
|
||||
|
||||
# Creates an assembly listing file from an input project ELF file, containing interleaved assembly and source data
|
||||
%.lss: %.elf
|
||||
@echo $(MSG_OBJDMP_CMD) Extracting LSS file data from \"$<\"
|
||||
$(CROSS)-objdump -h -d -S -z $< > $@
|
||||
|
||||
# Creates a symbol file listing the loadable and discarded symbols from an input project ELF file
|
||||
%.sym: %.elf
|
||||
@echo $(MSG_NM_CMD) Extracting SYM file data from \"$<\"
|
||||
$(CROSS)-nm -n $< > $@
|
||||
|
||||
# Include build dependency files
|
||||
-include $(DEPENDENCY_FILES)
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: build_begin build_end size symbol-sizes lib elf hex lss clean mostlyclean
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += BUILD
|
||||
LUFA_BUILD_TARGETS += size symbol-sizes all lib elf hex lss clean mostlyclean
|
||||
LUFA_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC F_USB LUFA_PATH
|
||||
LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES DEBUG_TYPE DEBUG_LEVEL LINKER_RELAXATIONS
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA GCC Compiler Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to build a C, C++ and/or Assembly application
|
||||
# via the AVR-GCC compiler.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# size - List built application size
|
||||
# symbol-sizes - Print application symbols from the binary ELF
|
||||
# file as a list sorted by size in bytes
|
||||
# all - Build application and list size
|
||||
# lib - Build and archive source files into a library
|
||||
# elf - Build application ELF debug object file
|
||||
# hex - Build application HEX object files
|
||||
# lss - Build application LSS assembly listing file
|
||||
# clean - Remove all project intermediatary and binary
|
||||
# output files
|
||||
# mostlyclean - Remove intermediatary output files, but
|
||||
# preserve binaries
|
||||
# <filename>.s - Compile C/C++ source file into an assembly file
|
||||
# for manual code inspection
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# TARGET - Application name
|
||||
# ARCH - Device architecture name
|
||||
# MCU - Microcontroller device model name
|
||||
# SRC - List of input source files (*.c, *.cpp, *.S)
|
||||
# F_USB - Speed of the input clock of the USB controller
|
||||
# in Hz
|
||||
# LUFA_PATH - Path to the LUFA library core
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# BOARD - LUFA board hardware
|
||||
# OPTIMIZATION - Optimization level
|
||||
# C_STANDARD - C Language Standard to use
|
||||
# CPP_STANDARD - C++ Language Standard to use
|
||||
# F_CPU - Speed of the CPU, in Hz
|
||||
# C_FLAGS - Flags to pass to the C compiler only
|
||||
# CPP_FLAGS - Flags to pass to the C++ compiler only
|
||||
# ASM_FLAGS - Flags to pass to the assembler only
|
||||
# CC_FLAGS - Common flags to pass to the C/C++ compiler and
|
||||
# assembler
|
||||
# LD_FLAGS - Flags to pass to the linker
|
||||
# LINKER_RELAXATIONS - Enable or disable linker relaxations to
|
||||
# decrease binary size (note: can cause link
|
||||
# failures on systems with an unpatched binutils)
|
||||
# OBJDIR - Directory for the output object and dependency
|
||||
# files; if equal to ".", the output files will
|
||||
# be generated in the same folder as the sources
|
||||
# OBJECT_FILES - Extra object files to link in to the binaries
|
||||
# DEBUG_FORMAT - Format of the debugging information to
|
||||
# generate in the compiled object files
|
||||
# DEBUG_LEVEL - Level the debugging information to generate in
|
||||
# the compiled object files
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
BOARD ?= NONE
|
||||
OPTIMIZATION ?= s
|
||||
F_CPU ?=
|
||||
C_STANDARD ?= gnu99
|
||||
CPP_STANDARD ?= gnu++98
|
||||
C_FLAGS ?=
|
||||
CPP_FLAGS ?=
|
||||
ASM_FLAGS ?=
|
||||
CC_FLAGS ?=
|
||||
OBJDIR ?= .
|
||||
OBJECT_FILES ?=
|
||||
DEBUG_FORMAT ?= dwarf-2
|
||||
DEBUG_LEVEL ?= 2
|
||||
LINKER_RELAXATIONS ?= Y
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
$(call ERROR_IF_EMPTY, ARCH)
|
||||
$(call ERROR_IF_EMPTY, F_USB)
|
||||
$(call ERROR_IF_EMPTY, LUFA_PATH)
|
||||
$(call ERROR_IF_EMPTY, BOARD)
|
||||
$(call ERROR_IF_EMPTY, OPTIMIZATION)
|
||||
$(call ERROR_IF_EMPTY, C_STANDARD)
|
||||
$(call ERROR_IF_EMPTY, CPP_STANDARD)
|
||||
$(call ERROR_IF_EMPTY, OBJDIR)
|
||||
$(call ERROR_IF_EMPTY, DEBUG_FORMAT)
|
||||
$(call ERROR_IF_EMPTY, DEBUG_LEVEL)
|
||||
$(call ERROR_IF_NONBOOL, LINKER_RELAXATIONS)
|
||||
|
||||
# Determine the utility prefix to use for the selected architecture
|
||||
ifeq ($(ARCH), AVR8)
|
||||
CROSS := avr
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
CROSS := avr
|
||||
$(warning The XMEGA device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)
|
||||
else ifeq ($(ARCH), UC3)
|
||||
CROSS := avr32
|
||||
$(warning The UC3 device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)
|
||||
else
|
||||
$(error Unsupported architecture "$(ARCH)")
|
||||
endif
|
||||
|
||||
# Output Messages
|
||||
MSG_INFO_MESSAGE := ' [INFO] :'
|
||||
MSG_COMPILE_CMD := ' [GCC] :'
|
||||
MSG_ASSEMBLE_CMD := ' [GAS] :'
|
||||
MSG_NM_CMD := ' [NM] :'
|
||||
MSG_REMOVE_CMD := ' [RM] :'
|
||||
MSG_LINK_CMD := ' [LNK] :'
|
||||
MSG_ARCHIVE_CMD := ' [AR] :'
|
||||
MSG_SIZE_CMD := ' [SIZE] :'
|
||||
MSG_OBJCPY_CMD := ' [OBJCPY] :'
|
||||
MSG_OBJDMP_CMD := ' [OBJDMP] :'
|
||||
|
||||
# Convert input source file list to differentiate them by type
|
||||
C_SOURCE := $(filter %.c, $(SRC))
|
||||
CPP_SOURCE := $(filter %.cpp, $(SRC))
|
||||
ASM_SOURCE := $(filter %.S, $(SRC))
|
||||
|
||||
# Create a list of unknown source file types, if any are found throw an error
|
||||
UNKNOWN_SOURCE := $(filter-out $(C_SOURCE) $(CPP_SOURCE) $(ASM_SOURCE), $(SRC))
|
||||
ifneq ($(UNKNOWN_SOURCE),)
|
||||
$(error Unknown input source file formats: $(UNKNOWN_SOURCE))
|
||||
endif
|
||||
|
||||
# Convert input source filenames into a list of required output object files
|
||||
OBJECT_FILES += $(addsuffix .o, $(basename $(SRC)))
|
||||
|
||||
# Check if an output object file directory was specified instead of the input file location
|
||||
ifneq ($(OBJDIR),.)
|
||||
# Prefix all the object filenames with the output object file directory path
|
||||
OBJECT_FILES := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(notdir $(OBJECT_FILES)))
|
||||
|
||||
# Check if any object file (without path) appears more than once in the object file list
|
||||
ifneq ($(words $(sort $(OBJECT_FILES))), $(words $(OBJECT_FILES)))
|
||||
$(error Cannot build with OBJDIR parameter set - one or more object file name is not unique)
|
||||
endif
|
||||
|
||||
# Create the output object file directory if it does not exist and add it to the virtual path list
|
||||
$(shell mkdir $(OBJDIR) 2> /dev/null)
|
||||
VPATH += $(dir $(SRC))
|
||||
endif
|
||||
|
||||
# Create a list of dependency files from the list of object files
|
||||
DEPENDENCY_FILES := $(OBJECT_FILES:%.o=%.d)
|
||||
|
||||
# Create a list of common flags to pass to the compiler/linker/assembler
|
||||
BASE_CC_FLAGS := -pipe -g$(DEBUG_FORMAT) -g$(DEBUG_LEVEL)
|
||||
ifeq ($(ARCH), AVR8)
|
||||
BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct
|
||||
else ifeq ($(ARCH), UC3)
|
||||
BASE_CC_FLAGS += -mpart=$(MCU:at32%=%) -masm-addr-pseudos
|
||||
endif
|
||||
BASE_CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections
|
||||
BASE_CC_FLAGS += -I. -I$(patsubst %/,%,$(LUFA_PATH))/..
|
||||
BASE_CC_FLAGS += -DARCH=ARCH_$(ARCH) -DBOARD=BOARD_$(BOARD) -DF_USB=$(F_USB)UL
|
||||
ifneq ($(F_CPU),)
|
||||
BASE_CC_FLAGS += -DF_CPU=$(F_CPU)UL
|
||||
endif
|
||||
|
||||
# Additional language specific compiler flags
|
||||
BASE_C_FLAGS := -x c -O$(OPTIMIZATION) -std=$(C_STANDARD) -Wstrict-prototypes
|
||||
BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD)
|
||||
BASE_ASM_FLAGS := -x assembler-with-cpp
|
||||
|
||||
# Create a list of flags to pass to the linker
|
||||
BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections
|
||||
ifeq ($(LINKER_RELAXATIONS), Y)
|
||||
BASE_LD_FLAGS += -Wl,--relax
|
||||
endif
|
||||
ifeq ($(ARCH), AVR8)
|
||||
BASE_LD_FLAGS += -mmcu=$(MCU)
|
||||
else ifeq ($(ARCH), XMEGA)
|
||||
BASE_LD_FLAGS += -mmcu=$(MCU)
|
||||
else ifeq ($(ARCH), UC3)
|
||||
BASE_LD_FLAGS += -mpart=$(MCU:at32%=%) --rodata-writable --direct-data
|
||||
endif
|
||||
|
||||
# Determine flags to pass to the size utility based on its reported features (only invoke if size target required)
|
||||
# and on an architecture where this non-standard patch is available
|
||||
ifneq ($(ARCH), UC3)
|
||||
size: SIZE_MCU_FLAG := $(shell $(CROSS)-size --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
|
||||
size: SIZE_FORMAT_FLAG := $(shell $(CROSS)-size --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
|
||||
endif
|
||||
|
||||
# Pre-build informational target, to give compiler and project name information when building
|
||||
build_begin:
|
||||
@echo $(MSG_INFO_MESSAGE) Begin compilation of project \"$(TARGET)\"...
|
||||
@echo ""
|
||||
@$(CROSS)-gcc --version
|
||||
|
||||
# Post-build informational target, to project name information when building has completed
|
||||
build_end:
|
||||
@echo $(MSG_INFO_MESSAGE) Finished building project \"$(TARGET)\".
|
||||
|
||||
# Prints size information of a compiled application (FLASH, RAM and EEPROM usages)
|
||||
size: $(TARGET).elf
|
||||
@echo $(MSG_SIZE_CMD) Determining size of \"$<\"
|
||||
@echo ""
|
||||
$(CROSS)-size $(SIZE_MCU_FLAG) $(SIZE_FORMAT_FLAG) $<
|
||||
|
||||
# Prints size information on the symbols within a compiled application in decimal bytes
|
||||
symbol-sizes: $(TARGET).elf
|
||||
@echo $(MSG_NM_CMD) Extracting \"$<\" symbols with decimal byte sizes
|
||||
$(CROSS)-nm --size-sort --demangle --radix=d $<
|
||||
|
||||
# Cleans intermediary build files, leaving only the compiled application files
|
||||
mostlyclean:
|
||||
@echo $(MSG_REMOVE_CMD) Removing object files of \"$(TARGET)\"
|
||||
rm -f $(OBJECT_FILES)
|
||||
@echo $(MSG_REMOVE_CMD) Removing dependency files of \"$(TARGET)\"
|
||||
rm -f $(DEPENDENCY_FILES)
|
||||
|
||||
# Cleans all build files, leaving only the original source code
|
||||
clean: mostlyclean
|
||||
@echo $(MSG_REMOVE_CMD) Removing output files of \"$(TARGET)\"
|
||||
rm -f $(TARGET).elf $(TARGET).hex $(TARGET).bin $(TARGET).eep $(TARGET).map $(TARGET).lss $(TARGET).sym $(TARGET).a
|
||||
|
||||
# Performs a complete build of the user application and prints size information afterwards
|
||||
all: build_begin elf hex bin lss sym size build_end
|
||||
|
||||
# Helper targets, to build a specific type of output file without having to know the project target name
|
||||
lib: lib$(TARGET).a
|
||||
elf: $(TARGET).elf
|
||||
hex: $(TARGET).hex $(TARGET).eep
|
||||
bin: $(TARGET).bin $(TARGET).eep
|
||||
lss: $(TARGET).lss
|
||||
sym: $(TARGET).sym
|
||||
|
||||
# Default target to *create* the user application's specified source files; if this rule is executed by
|
||||
# make, the input source file doesn't exist and an error needs to be presented to the user
|
||||
$(SRC):
|
||||
$(error Source file does not exist: $@)
|
||||
|
||||
# Compiles an input C source file and generates an assembly listing for it
|
||||
%.s: %.c $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COMPILE_CMD) Generating assembly from C file \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -S $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) $< -o $@
|
||||
|
||||
# Compiles an input C++ source file and generates an assembly listing for it
|
||||
%.s: %.cpp $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COMPILE_CMD) Generating assembly from C++ file \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -S $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) $< -o $@
|
||||
|
||||
# Compiles an input C source file and generates a linkable object file for it
|
||||
$(OBJDIR)/%.o: %.c $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COMPILE_CMD) Compiling C file \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
|
||||
|
||||
# Compiles an input C++ source file and generates a linkable object file for it
|
||||
$(OBJDIR)/%.o: %.cpp $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COMPILE_CMD) Compiling C++ file \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
|
||||
|
||||
# Assembles an input ASM source file and generates a linkable object file for it
|
||||
$(OBJDIR)/%.o: %.S $(MAKEFILE_LIST)
|
||||
@echo $(MSG_ASSEMBLE_CMD) Assembling \"$(notdir $<)\"
|
||||
$(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_ASM_FLAGS) $(CC_FLAGS) $(ASM_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@
|
||||
|
||||
# Generates a library archive file from the user application, which can be linked into other applications
|
||||
.PRECIOUS : $(OBJECT_FILES)
|
||||
.SECONDARY : %.a
|
||||
%.a: $(OBJECT_FILES)
|
||||
@echo $(MSG_ARCHIVE_CMD) Archiving object files into \"$@\"
|
||||
$(CROSS)-ar rcs $@ $(OBJECT_FILES)
|
||||
|
||||
# Generates an ELF debug file from the user application, which can be further processed for FLASH and EEPROM data
|
||||
# files, or used for programming and debugging directly
|
||||
.PRECIOUS : $(OBJECT_FILES)
|
||||
.SECONDARY : %.elf
|
||||
%.elf: $(OBJECT_FILES)
|
||||
@echo $(MSG_LINK_CMD) Linking object files into \"$@\"
|
||||
$(CROSS)-gcc $^ -o $@ $(BASE_LD_FLAGS) $(LD_FLAGS)
|
||||
|
||||
# Extracts out the loadable FLASH memory data from the project ELF file, and creates an Intel HEX format file of it
|
||||
%.hex: %.elf
|
||||
@echo $(MSG_OBJCPY_CMD) Extracting HEX file data from \"$<\"
|
||||
$(CROSS)-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
||||
|
||||
# Extracts out the loadable FLASH memory data from the project ELF file, and creates an Binary format file of it
|
||||
%.bin: %.elf
|
||||
@echo $(MSG_OBJCPY_CMD) Extracting BIN file data from \"$<\"
|
||||
$(CROSS)-objcopy -O binary -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
||||
|
||||
# Extracts out the loadable EEPROM memory data from the project ELF file, and creates an Intel HEX format file of it
|
||||
%.eep: %.elf
|
||||
@echo $(MSG_OBJCPY_CMD) Extracting EEP file data from \"$<\"
|
||||
$(CROSS)-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $< $@ || exit 0
|
||||
|
||||
# Creates an assembly listing file from an input project ELF file, containing interleaved assembly and source data
|
||||
%.lss: %.elf
|
||||
@echo $(MSG_OBJDMP_CMD) Extracting LSS file data from \"$<\"
|
||||
$(CROSS)-objdump -h -d -S -z $< > $@
|
||||
|
||||
# Creates a symbol file listing the loadable and discarded symbols from an input project ELF file
|
||||
%.sym: %.elf
|
||||
@echo $(MSG_NM_CMD) Extracting SYM file data from \"$<\"
|
||||
$(CROSS)-nm -n $< > $@
|
||||
|
||||
# Include build dependency files
|
||||
-include $(DEPENDENCY_FILES)
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: build_begin build_end size symbol-sizes lib elf hex lss clean mostlyclean
|
||||
|
||||
@@ -1,172 +1,172 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += CORE
|
||||
LUFA_BUILD_TARGETS += help list_targets list_modules list_mandatory list_optional list_provided list_macros
|
||||
LUFA_BUILD_MANDATORY_VARS +=
|
||||
LUFA_BUILD_OPTIONAL_VARS +=
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA Core Build System Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of core build targets for the LUFA build system
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# help - Build system help
|
||||
# list_targets - List all build targets
|
||||
# list_modules - List all build modules
|
||||
# list_mandatory - List all mandatory make variables required by
|
||||
# the included build modules of the application
|
||||
# list_optional - List all optional make variables required by
|
||||
# the included build modules of the application
|
||||
# list_provided - List all provided make variables from the
|
||||
# included build modules of the application
|
||||
# list_macros - List all provided make macros from the
|
||||
# included build modules of the application
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# Converts a given input to a printable output using "(None)" if no items are in the list
|
||||
CONVERT_TO_PRINTABLE = $(if $(strip $(1)), $(1), (None))
|
||||
|
||||
|
||||
# Build sorted and filtered lists of the included build module data
|
||||
SORTED_LUFA_BUILD_MODULES = $(sort $(LUFA_BUILD_MODULES))
|
||||
SORTED_LUFA_BUILD_TARGETS = $(sort $(LUFA_BUILD_TARGETS))
|
||||
SORTED_LUFA_MANDATORY_VARS = $(sort $(LUFA_BUILD_MANDATORY_VARS))
|
||||
SORTED_LUFA_OPTIONAL_VARS = $(filter-out $(SORTED_LUFA_MANDATORY_VARS), $(sort $(LUFA_BUILD_OPTIONAL_VARS)))
|
||||
SORTED_LUFA_PROVIDED_VARS = $(sort $(LUFA_BUILD_PROVIDED_VARS))
|
||||
SORTED_LUFA_PROVIDED_MACROS = $(sort $(LUFA_BUILD_PROVIDED_MACROS))
|
||||
|
||||
# Create printable versions of the sorted build module data (use "(None)" when no data is available)
|
||||
PRINTABLE_LUFA_BUILD_MODULES = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_BUILD_MODULES))
|
||||
PRINTABLE_LUFA_BUILD_TARGETS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_BUILD_TARGETS))
|
||||
PRINTABLE_LUFA_MANDATORY_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_MANDATORY_VARS))
|
||||
PRINTABLE_LUFA_OPTIONAL_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_OPTIONAL_VARS))
|
||||
PRINTABLE_LUFA_PROVIDED_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_PROVIDED_VARS))
|
||||
PRINTABLE_LUFA_PROVIDED_MACROS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_PROVIDED_MACROS))
|
||||
|
||||
help:
|
||||
@echo "==================================================================="
|
||||
@echo " LUFA Build System 2.0 "
|
||||
@echo " (C) Dean Camera, 2013 { dean @ fourwalledcubicle . com } "
|
||||
@echo "==================================================================="
|
||||
@echo "DESCRIPTION: "
|
||||
@echo " This build system is a set of makefile modules for (GNU) Make, to "
|
||||
@echo " provide a simple system for building LUFA powered applications. "
|
||||
@echo " Each makefile module can be included from within a user makefile, "
|
||||
@echo " to expose the build rules documented in the comments at the top of"
|
||||
@echo " each build module. "
|
||||
@echo " "
|
||||
@echo "USAGE: "
|
||||
@echo " To execute a rule, define all variables indicated in the desired "
|
||||
@echo " module as a required parameter before including the build module "
|
||||
@echo " in your project makefile. Parameters marked as optional will "
|
||||
@echo " assume a default value in the modules if not user-assigned. "
|
||||
@echo " "
|
||||
@echo " By default the target output shows both a friendly summary, as "
|
||||
@echo " well as the actual invoked command. To suppress the output of the "
|
||||
@echo " invoked commands and show only the friendly command output, run "
|
||||
@echo " make with the \"-s\" switch added before the target(s). "
|
||||
@echo " "
|
||||
@echo "SEE ALSO: "
|
||||
@echo " For more information, see the 'Build System' chapter of the LUFA "
|
||||
@echo " project documentation. "
|
||||
@echo "==================================================================="
|
||||
@echo " "
|
||||
@echo " Currently used build system modules in this application: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_BUILD_MODULES:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Currently available build targets in this application: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_BUILD_TARGETS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Mandatory variables required by the selected build Modules: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_MANDATORY_VARS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Optional variables required by the selected build Modules: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_OPTIONAL_VARS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Variables provided by the selected build Modules: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_PROVIDED_VARS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Macros provided by the selected build Modules: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_PROVIDED_MACROS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo "==================================================================="
|
||||
@echo " The LUFA BuildSystem 2.0 - Powered By Duct Tape (tm) "
|
||||
@echo "==================================================================="
|
||||
|
||||
# Lists build modules included by the project makefile, in alphabetical order
|
||||
list_modules:
|
||||
@echo Currently Used Build System Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_BUILD_MODULES:%= - %\n)"
|
||||
|
||||
# Lists build targets included by the project makefile, in alphabetical order
|
||||
list_targets:
|
||||
@echo Currently Available Build Targets:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_BUILD_TARGETS:%= - %\n)"
|
||||
|
||||
# Lists mandatory variables that must be set by the project makefile, in alphabetical order
|
||||
list_mandatory:
|
||||
@echo Mandatory Variables for Included Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_MANDATORY_VARS:%= - %\n)"
|
||||
|
||||
# Lists optional variables that must be set by the project makefile, in alphabetical order
|
||||
list_optional:
|
||||
@echo Optional Variables for Included Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_OPTIONAL_VARS:%= - %\n)"
|
||||
|
||||
# Lists variables provided by the included build modules, in alphabetical order
|
||||
list_provided:
|
||||
@echo Variables Provided by the Included Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_PROVIDED_VARS:%= - %\n)"
|
||||
|
||||
# Lists macros provided by the included build modules, in alphabetical order
|
||||
list_macros:
|
||||
@echo Macros Provided by the Included Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_PROVIDED_MACROS:%= - %\n)"
|
||||
|
||||
# Disable default in-built make rules (those that are needed are explicitly
|
||||
# defined, and doing so has performance benefits when recursively building)
|
||||
.SUFFIXES:
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: help list_modules list_targets list_mandatory list_optional list_provided list_macros
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += CORE
|
||||
LUFA_BUILD_TARGETS += help list_targets list_modules list_mandatory list_optional list_provided list_macros
|
||||
LUFA_BUILD_MANDATORY_VARS +=
|
||||
LUFA_BUILD_OPTIONAL_VARS +=
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA Core Build System Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of core build targets for the LUFA build system
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# help - Build system help
|
||||
# list_targets - List all build targets
|
||||
# list_modules - List all build modules
|
||||
# list_mandatory - List all mandatory make variables required by
|
||||
# the included build modules of the application
|
||||
# list_optional - List all optional make variables required by
|
||||
# the included build modules of the application
|
||||
# list_provided - List all provided make variables from the
|
||||
# included build modules of the application
|
||||
# list_macros - List all provided make macros from the
|
||||
# included build modules of the application
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# Converts a given input to a printable output using "(None)" if no items are in the list
|
||||
CONVERT_TO_PRINTABLE = $(if $(strip $(1)), $(1), (None))
|
||||
|
||||
|
||||
# Build sorted and filtered lists of the included build module data
|
||||
SORTED_LUFA_BUILD_MODULES = $(sort $(LUFA_BUILD_MODULES))
|
||||
SORTED_LUFA_BUILD_TARGETS = $(sort $(LUFA_BUILD_TARGETS))
|
||||
SORTED_LUFA_MANDATORY_VARS = $(sort $(LUFA_BUILD_MANDATORY_VARS))
|
||||
SORTED_LUFA_OPTIONAL_VARS = $(filter-out $(SORTED_LUFA_MANDATORY_VARS), $(sort $(LUFA_BUILD_OPTIONAL_VARS)))
|
||||
SORTED_LUFA_PROVIDED_VARS = $(sort $(LUFA_BUILD_PROVIDED_VARS))
|
||||
SORTED_LUFA_PROVIDED_MACROS = $(sort $(LUFA_BUILD_PROVIDED_MACROS))
|
||||
|
||||
# Create printable versions of the sorted build module data (use "(None)" when no data is available)
|
||||
PRINTABLE_LUFA_BUILD_MODULES = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_BUILD_MODULES))
|
||||
PRINTABLE_LUFA_BUILD_TARGETS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_BUILD_TARGETS))
|
||||
PRINTABLE_LUFA_MANDATORY_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_MANDATORY_VARS))
|
||||
PRINTABLE_LUFA_OPTIONAL_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_OPTIONAL_VARS))
|
||||
PRINTABLE_LUFA_PROVIDED_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_PROVIDED_VARS))
|
||||
PRINTABLE_LUFA_PROVIDED_MACROS = $(call CONVERT_TO_PRINTABLE, $(SORTED_LUFA_PROVIDED_MACROS))
|
||||
|
||||
help:
|
||||
@echo "==================================================================="
|
||||
@echo " LUFA Build System 2.0 "
|
||||
@echo " (C) Dean Camera, 2013 { dean @ fourwalledcubicle . com } "
|
||||
@echo "==================================================================="
|
||||
@echo "DESCRIPTION: "
|
||||
@echo " This build system is a set of makefile modules for (GNU) Make, to "
|
||||
@echo " provide a simple system for building LUFA powered applications. "
|
||||
@echo " Each makefile module can be included from within a user makefile, "
|
||||
@echo " to expose the build rules documented in the comments at the top of"
|
||||
@echo " each build module. "
|
||||
@echo " "
|
||||
@echo "USAGE: "
|
||||
@echo " To execute a rule, define all variables indicated in the desired "
|
||||
@echo " module as a required parameter before including the build module "
|
||||
@echo " in your project makefile. Parameters marked as optional will "
|
||||
@echo " assume a default value in the modules if not user-assigned. "
|
||||
@echo " "
|
||||
@echo " By default the target output shows both a friendly summary, as "
|
||||
@echo " well as the actual invoked command. To suppress the output of the "
|
||||
@echo " invoked commands and show only the friendly command output, run "
|
||||
@echo " make with the \"-s\" switch added before the target(s). "
|
||||
@echo " "
|
||||
@echo "SEE ALSO: "
|
||||
@echo " For more information, see the 'Build System' chapter of the LUFA "
|
||||
@echo " project documentation. "
|
||||
@echo "==================================================================="
|
||||
@echo " "
|
||||
@echo " Currently used build system modules in this application: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_BUILD_MODULES:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Currently available build targets in this application: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_BUILD_TARGETS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Mandatory variables required by the selected build Modules: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_MANDATORY_VARS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Optional variables required by the selected build Modules: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_OPTIONAL_VARS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Variables provided by the selected build Modules: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_PROVIDED_VARS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo " "
|
||||
@echo " Macros provided by the selected build Modules: "
|
||||
@echo " "
|
||||
@printf " %b" "$(PRINTABLE_LUFA_PROVIDED_MACROS:%= - %\n)"
|
||||
@echo " "
|
||||
@echo "==================================================================="
|
||||
@echo " The LUFA BuildSystem 2.0 - Powered By Duct Tape (tm) "
|
||||
@echo "==================================================================="
|
||||
|
||||
# Lists build modules included by the project makefile, in alphabetical order
|
||||
list_modules:
|
||||
@echo Currently Used Build System Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_BUILD_MODULES:%= - %\n)"
|
||||
|
||||
# Lists build targets included by the project makefile, in alphabetical order
|
||||
list_targets:
|
||||
@echo Currently Available Build Targets:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_BUILD_TARGETS:%= - %\n)"
|
||||
|
||||
# Lists mandatory variables that must be set by the project makefile, in alphabetical order
|
||||
list_mandatory:
|
||||
@echo Mandatory Variables for Included Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_MANDATORY_VARS:%= - %\n)"
|
||||
|
||||
# Lists optional variables that must be set by the project makefile, in alphabetical order
|
||||
list_optional:
|
||||
@echo Optional Variables for Included Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_OPTIONAL_VARS:%= - %\n)"
|
||||
|
||||
# Lists variables provided by the included build modules, in alphabetical order
|
||||
list_provided:
|
||||
@echo Variables Provided by the Included Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_PROVIDED_VARS:%= - %\n)"
|
||||
|
||||
# Lists macros provided by the included build modules, in alphabetical order
|
||||
list_macros:
|
||||
@echo Macros Provided by the Included Modules:
|
||||
@printf " %b" "$(PRINTABLE_LUFA_PROVIDED_MACROS:%= - %\n)"
|
||||
|
||||
# Disable default in-built make rules (those that are needed are explicitly
|
||||
# defined, and doing so has performance benefits when recursively building)
|
||||
.SUFFIXES:
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: help list_modules list_targets list_mandatory list_optional list_provided list_macros
|
||||
|
||||
@@ -1,106 +1,106 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += CPPCHECK
|
||||
LUFA_BUILD_TARGETS += cppcheck cppcheck-config
|
||||
LUFA_BUILD_MANDATORY_VARS += SRC
|
||||
LUFA_BUILD_OPTIONAL_VARS += CPPCHECK_INCLUDES CPPCHECK_EXCLUDES CPPCHECK_MSG_TEMPLATE CPPCHECK_ENABLE \
|
||||
CPPCHECK_SUPPRESS CPPCHECK_FAIL_ON_WARNING CPPCHECK_QUIET CPPCHECK_FLAGS
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA CPPCheck Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to scan a project with the free "cppcheck" static
|
||||
# analysis tool, to check for code errors at runtime (see http://cppcheck.sourceforge.net).
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# cppcheck - Scan the project with CPPCheck
|
||||
# cppcheck-config - Use CPPCheck to look for missing include files
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# SRC - List of source files to statically analyze
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# CPPCHECK_INCLUDES - Extra include paths to search for missing
|
||||
# header files
|
||||
# CPPCHECK_EXCLUDES - Source file paths to exclude checking (can be
|
||||
# a path fragment if desired)
|
||||
# CPPCHECK_MSG_TEMPLATE - Template for cppcheck error and warning output
|
||||
# CPPCHECK_ENABLE - General cppcheck category checks to enable
|
||||
# CPPCHECK_SUPPRESS - Specific cppcheck warnings to disable by ID
|
||||
# CPPCHECK_FAIL_ON_WARNING - Set to Y to fail the build on cppcheck
|
||||
# warnings, N to continue even if warnings occur
|
||||
# CPPCHECK_QUIET - Enable cppcheck verbose or quiet output mode
|
||||
# CPPCHECK_FLAGS - Additional flags to pass to cppcheck
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
CPPCHECK_INCLUDES ?=
|
||||
CPPCHECK_EXCLUDES ?=
|
||||
CPPCHECK_MSG_TEMPLATE ?= {file}:{line}: {severity} ({id}): {message}
|
||||
CPPCHECK_ENABLE ?= all
|
||||
CPPCHECK_SUPPRESS ?= variableScope missingInclude
|
||||
CPPCHECK_FAIL_ON_WARNING ?= Y
|
||||
CPPCHECK_QUIET ?= Y
|
||||
CPPCHECK_FLAGS ?=
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, SRC)
|
||||
$(call ERROR_IF_EMPTY, CPPCHECK_MSG_TEMPLATE)
|
||||
$(call ERROR_IF_EMPTY, CPPCHECK_ENABLE)
|
||||
$(call ERROR_IF_NONBOOL, CPPCHECK_FAIL_ON_WARNING)
|
||||
$(call ERROR_IF_NONBOOL, CPPCHECK_QUIET)
|
||||
|
||||
# Build a default argument list for cppcheck
|
||||
BASE_CPPCHECK_FLAGS := --template="$(CPPCHECK_MSG_TEMPLATE)" $(CPPCHECK_INCLUDES:%=-I%) $(CPPCHECK_EXCLUDES:%=-i%) --inline-suppr --force --std=c99
|
||||
|
||||
# Sanity check parameters and construct additional command line arguments to cppcheck
|
||||
ifeq ($(CPPCHECK_FAIL_ON_WARNING), Y)
|
||||
BASE_CPPCHECK_FLAGS += --error-exitcode=1
|
||||
endif
|
||||
ifeq ($(CPPCHECK_QUIET), Y)
|
||||
BASE_CPPCHECK_FLAGS += --quiet
|
||||
endif
|
||||
|
||||
# Output Messages
|
||||
MSG_CPPCHECK_CMD := ' [CPPCHECK]:'
|
||||
|
||||
# Checks the CPPCheck configuration as used in the user project, to determine if any paths are missing or invalid
|
||||
cppcheck-config: $(MAKEFILE_LIST)
|
||||
@echo $(MSG_CPPCHECK_CMD) Checking cppcheck configuration check on source files
|
||||
cppcheck $(BASE_CPPCHECK_FLAGS) --check-config $(CPPCHECK_FLAGS) $(SRC)
|
||||
|
||||
# Runs a static analysis using CPPCheck to determine if there are any issues
|
||||
cppcheck: $(MAKEFILE_LIST)
|
||||
@echo $(MSG_CPPCHECK_CMD) Performing static analysis on source files
|
||||
cppcheck $(BASE_CPPCHECK_FLAGS) --enable=$(CPPCHECK_ENABLE) $(CPPCHECK_SUPPRESS:%=--suppress=%) $(CPPCHECK_FLAGS) $(SRC)
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: cppcheck-config cppcheck
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += CPPCHECK
|
||||
LUFA_BUILD_TARGETS += cppcheck cppcheck-config
|
||||
LUFA_BUILD_MANDATORY_VARS += SRC
|
||||
LUFA_BUILD_OPTIONAL_VARS += CPPCHECK_INCLUDES CPPCHECK_EXCLUDES CPPCHECK_MSG_TEMPLATE CPPCHECK_ENABLE \
|
||||
CPPCHECK_SUPPRESS CPPCHECK_FAIL_ON_WARNING CPPCHECK_QUIET CPPCHECK_FLAGS
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA CPPCheck Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to scan a project with the free "cppcheck" static
|
||||
# analysis tool, to check for code errors at runtime (see http://cppcheck.sourceforge.net).
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# cppcheck - Scan the project with CPPCheck
|
||||
# cppcheck-config - Use CPPCheck to look for missing include files
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# SRC - List of source files to statically analyze
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# CPPCHECK_INCLUDES - Extra include paths to search for missing
|
||||
# header files
|
||||
# CPPCHECK_EXCLUDES - Source file paths to exclude checking (can be
|
||||
# a path fragment if desired)
|
||||
# CPPCHECK_MSG_TEMPLATE - Template for cppcheck error and warning output
|
||||
# CPPCHECK_ENABLE - General cppcheck category checks to enable
|
||||
# CPPCHECK_SUPPRESS - Specific cppcheck warnings to disable by ID
|
||||
# CPPCHECK_FAIL_ON_WARNING - Set to Y to fail the build on cppcheck
|
||||
# warnings, N to continue even if warnings occur
|
||||
# CPPCHECK_QUIET - Enable cppcheck verbose or quiet output mode
|
||||
# CPPCHECK_FLAGS - Additional flags to pass to cppcheck
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
CPPCHECK_INCLUDES ?=
|
||||
CPPCHECK_EXCLUDES ?=
|
||||
CPPCHECK_MSG_TEMPLATE ?= {file}:{line}: {severity} ({id}): {message}
|
||||
CPPCHECK_ENABLE ?= all
|
||||
CPPCHECK_SUPPRESS ?= variableScope missingInclude
|
||||
CPPCHECK_FAIL_ON_WARNING ?= Y
|
||||
CPPCHECK_QUIET ?= Y
|
||||
CPPCHECK_FLAGS ?=
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, SRC)
|
||||
$(call ERROR_IF_EMPTY, CPPCHECK_MSG_TEMPLATE)
|
||||
$(call ERROR_IF_EMPTY, CPPCHECK_ENABLE)
|
||||
$(call ERROR_IF_NONBOOL, CPPCHECK_FAIL_ON_WARNING)
|
||||
$(call ERROR_IF_NONBOOL, CPPCHECK_QUIET)
|
||||
|
||||
# Build a default argument list for cppcheck
|
||||
BASE_CPPCHECK_FLAGS := --template="$(CPPCHECK_MSG_TEMPLATE)" $(CPPCHECK_INCLUDES:%=-I%) $(CPPCHECK_EXCLUDES:%=-i%) --inline-suppr --force --std=c99
|
||||
|
||||
# Sanity check parameters and construct additional command line arguments to cppcheck
|
||||
ifeq ($(CPPCHECK_FAIL_ON_WARNING), Y)
|
||||
BASE_CPPCHECK_FLAGS += --error-exitcode=1
|
||||
endif
|
||||
ifeq ($(CPPCHECK_QUIET), Y)
|
||||
BASE_CPPCHECK_FLAGS += --quiet
|
||||
endif
|
||||
|
||||
# Output Messages
|
||||
MSG_CPPCHECK_CMD := ' [CPPCHECK]:'
|
||||
|
||||
# Checks the CPPCheck configuration as used in the user project, to determine if any paths are missing or invalid
|
||||
cppcheck-config: $(MAKEFILE_LIST)
|
||||
@echo $(MSG_CPPCHECK_CMD) Checking cppcheck configuration check on source files
|
||||
cppcheck $(BASE_CPPCHECK_FLAGS) --check-config $(CPPCHECK_FLAGS) $(SRC)
|
||||
|
||||
# Runs a static analysis using CPPCheck to determine if there are any issues
|
||||
cppcheck: $(MAKEFILE_LIST)
|
||||
@echo $(MSG_CPPCHECK_CMD) Performing static analysis on source files
|
||||
cppcheck $(BASE_CPPCHECK_FLAGS) --enable=$(CPPCHECK_ENABLE) $(CPPCHECK_SUPPRESS:%=--suppress=%) $(CPPCHECK_FLAGS) $(SRC)
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: cppcheck-config cppcheck
|
||||
|
||||
@@ -1,95 +1,95 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += DFU
|
||||
LUFA_BUILD_TARGETS += flip flip-ee dfu dfu-ee
|
||||
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
||||
LUFA_BUILD_OPTIONAL_VARS +=
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA DFU Bootloader Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to re-program a device currently running a DFU
|
||||
# class bootloader with a project's FLASH and EEPROM files.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# flip - Program FLASH into target via Atmel FLIP
|
||||
# flip-ee - Program EEPROM into target via Atmel FLIP
|
||||
# dfu - Program FLASH into target via dfu-programmer
|
||||
# dfu-ee - Program EEPROM into target via dfu-programmer
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# MCU - Microcontroller device model name
|
||||
# TARGET - Application name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Sanity-check values of mandatory user-supplied variables
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
|
||||
# Output Messages
|
||||
MSG_COPY_CMD := ' [CP] :'
|
||||
MSG_REMOVE_CMD := ' [RM] :'
|
||||
MSG_DFU_CMD := ' [DFU] :'
|
||||
|
||||
# Programs in the target FLASH memory using BATCHISP, the command line tool used by FLIP
|
||||
flip: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\"
|
||||
batchisp -hardware usb -device $(MCU) -operation erase f loadbuffer $< program
|
||||
batchisp -hardware usb -device $(MCU) -operation start reset 0
|
||||
|
||||
# Programs in the target EEPROM memory using BATCHISP, the command line tool used by FLIP
|
||||
flip-ee: $(TARGET).eep $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COPY_CMD) Copying EEP file to temporary file \"$<.hex\"
|
||||
cp $< $<.hex
|
||||
@echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\"
|
||||
batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $<.hex program
|
||||
batchisp -hardware usb -device $(MCU) -operation start reset 0
|
||||
@echo $(MSG_REMOVE_CMD) Removing temporary file \"$<.hex\"
|
||||
rm $<.hex
|
||||
|
||||
# Programs in the target FLASH memory using DFU-PROGRAMMER
|
||||
dfu: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\"
|
||||
dfu-programmer $(MCU) erase
|
||||
dfu-programmer $(MCU) flash $<
|
||||
dfu-programmer $(MCU) reset
|
||||
|
||||
# Programs in the target EEPROM memory using DFU-PROGRAMMER
|
||||
dfu-ee: $(TARGET).eep $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\"
|
||||
dfu-programmer $(MCU) eeprom-flash $<
|
||||
dfu-programmer $(MCU) reset
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: flip flip-ee dfu dfu-ee
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += DFU
|
||||
LUFA_BUILD_TARGETS += flip flip-ee dfu dfu-ee
|
||||
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
||||
LUFA_BUILD_OPTIONAL_VARS +=
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA DFU Bootloader Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to re-program a device currently running a DFU
|
||||
# class bootloader with a project's FLASH and EEPROM files.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# flip - Program FLASH into target via Atmel FLIP
|
||||
# flip-ee - Program EEPROM into target via Atmel FLIP
|
||||
# dfu - Program FLASH into target via dfu-programmer
|
||||
# dfu-ee - Program EEPROM into target via dfu-programmer
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# MCU - Microcontroller device model name
|
||||
# TARGET - Application name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Sanity-check values of mandatory user-supplied variables
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
|
||||
# Output Messages
|
||||
MSG_COPY_CMD := ' [CP] :'
|
||||
MSG_REMOVE_CMD := ' [RM] :'
|
||||
MSG_DFU_CMD := ' [DFU] :'
|
||||
|
||||
# Programs in the target FLASH memory using BATCHISP, the command line tool used by FLIP
|
||||
flip: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\"
|
||||
batchisp -hardware usb -device $(MCU) -operation erase f loadbuffer $< program
|
||||
batchisp -hardware usb -device $(MCU) -operation start reset 0
|
||||
|
||||
# Programs in the target EEPROM memory using BATCHISP, the command line tool used by FLIP
|
||||
flip-ee: $(TARGET).eep $(MAKEFILE_LIST)
|
||||
@echo $(MSG_COPY_CMD) Copying EEP file to temporary file \"$<.hex\"
|
||||
cp $< $<.hex
|
||||
@echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\"
|
||||
batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $<.hex program
|
||||
batchisp -hardware usb -device $(MCU) -operation start reset 0
|
||||
@echo $(MSG_REMOVE_CMD) Removing temporary file \"$<.hex\"
|
||||
rm $<.hex
|
||||
|
||||
# Programs in the target FLASH memory using DFU-PROGRAMMER
|
||||
dfu: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\"
|
||||
dfu-programmer $(MCU) erase
|
||||
dfu-programmer $(MCU) flash $<
|
||||
dfu-programmer $(MCU) reset
|
||||
|
||||
# Programs in the target EEPROM memory using DFU-PROGRAMMER
|
||||
dfu-ee: $(TARGET).eep $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\"
|
||||
dfu-programmer $(MCU) eeprom-flash $<
|
||||
dfu-programmer $(MCU) reset
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: flip flip-ee dfu dfu-ee
|
||||
|
||||
@@ -1,100 +1,100 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += DOXYGEN
|
||||
LUFA_BUILD_TARGETS += doxygen doxygen_upgrade doxygen_create
|
||||
LUFA_BUILD_MANDATORY_VARS += LUFA_PATH
|
||||
LUFA_BUILD_OPTIONAL_VARS += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERRIDE_PARAMS
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA Doxygen Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to automatically build Doxygen documentation for
|
||||
# a project (see www.doxygen.org).
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# doxygen - Build Doxygen Documentation
|
||||
# doxygen_create - Create a new Doxygen configuration file using
|
||||
# the latest template
|
||||
# doxygen_upgrade - Upgrade an existing Doxygen configuration file
|
||||
# to the latest template
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# LUFA_PATH - Path to the LUFA library core
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# DOXYGEN_CONF - Doxygen configuration filename
|
||||
# DOXYGEN_FAIL_ON_WARNING - Set to Y to fail the build on Doxygen warnings,
|
||||
# N to continue even if warnings occur
|
||||
# DOXYGEN_OVERRIDE_PARAMS - Parameters to override in the doxygen
|
||||
# configuration file
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
DOXYGEN_CONF ?= Doxygen.conf
|
||||
DOXYGEN_FAIL_ON_WARNING ?= Y
|
||||
DOXYGEN_OVERRIDE_PARAMS ?= QUIET=YES HTML_EXTRA_STYLESHEET=$(patsubst %/,%,$(LUFA_PATH))/DoxygenPages/Style/Style.css
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, DOXYGEN_CONF)
|
||||
$(call ERROR_IF_EMPTY, LUFA_PATH)
|
||||
$(call ERROR_IF_NONBOOL, DOXYGEN_FAIL_ON_WARNING)
|
||||
|
||||
# Output Messages
|
||||
MSG_DOXYGEN_CMD := ' [DOXYGEN] :'
|
||||
|
||||
# Determine Doxygen invocation command
|
||||
BASE_DOXYGEN_CMD := ( cat $(DOXYGEN_CONF) $(DOXYGEN_OVERRIDE_PARAMS:%=; echo "%") ) | doxygen -
|
||||
ifeq ($(DOXYGEN_FAIL_ON_WARNING), Y)
|
||||
DOXYGEN_CMD := if ( $(BASE_DOXYGEN_CMD) 2>&1 | grep -v "warning: ignoring unsupported tag" ;); then exit 1; fi;
|
||||
else
|
||||
DOXYGEN_CMD := $(BASE_DOXYGEN_CMD)
|
||||
endif
|
||||
|
||||
# Error if the specified Doxygen configuration file does not exist
|
||||
$(DOXYGEN_CONF):
|
||||
$(error Doxygen configuration file $@ does not exist)
|
||||
|
||||
# Builds the project documentation using the specified configuration file and the DOXYGEN tool
|
||||
doxygen: $(DOXYGEN_CONF) $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DOXYGEN_CMD) Configuration file \"$(DOXYGEN_CONF)\" with parameters \"$(DOXYGEN_OVERRIDE_PARAMS)\"
|
||||
$(DOXYGEN_CMD)
|
||||
|
||||
# Upgrades an existing Doxygen configuration file to the latest Doxygen template, preserving settings
|
||||
doxygen_upgrade: $(DOXYGEN_CONF) $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DOXYGEN_CMD) Upgrading configuration file \"$(DOXYGEN_CONF)\" with latest template
|
||||
doxygen -u $(DOXYGEN_CONF) > /dev/null
|
||||
|
||||
# Creates a new Doxygen configuration file with the set file name
|
||||
doxygen_create: $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DOXYGEN_CMD) Creating new configuration file \"$(DOXYGEN_CONF)\" with latest template
|
||||
doxygen -g $(DOXYGEN_CONF) > /dev/null
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: doxygen doxygen_upgrade doxygen_create
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += DOXYGEN
|
||||
LUFA_BUILD_TARGETS += doxygen doxygen_upgrade doxygen_create
|
||||
LUFA_BUILD_MANDATORY_VARS += LUFA_PATH
|
||||
LUFA_BUILD_OPTIONAL_VARS += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERRIDE_PARAMS
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA Doxygen Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to automatically build Doxygen documentation for
|
||||
# a project (see www.doxygen.org).
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# doxygen - Build Doxygen Documentation
|
||||
# doxygen_create - Create a new Doxygen configuration file using
|
||||
# the latest template
|
||||
# doxygen_upgrade - Upgrade an existing Doxygen configuration file
|
||||
# to the latest template
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# LUFA_PATH - Path to the LUFA library core
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# DOXYGEN_CONF - Doxygen configuration filename
|
||||
# DOXYGEN_FAIL_ON_WARNING - Set to Y to fail the build on Doxygen warnings,
|
||||
# N to continue even if warnings occur
|
||||
# DOXYGEN_OVERRIDE_PARAMS - Parameters to override in the doxygen
|
||||
# configuration file
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Default values of optionally user-supplied variables
|
||||
DOXYGEN_CONF ?= Doxygen.conf
|
||||
DOXYGEN_FAIL_ON_WARNING ?= Y
|
||||
DOXYGEN_OVERRIDE_PARAMS ?= QUIET=YES HTML_EXTRA_STYLESHEET=$(patsubst %/,%,$(LUFA_PATH))/DoxygenPages/Style/Style.css
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, DOXYGEN_CONF)
|
||||
$(call ERROR_IF_EMPTY, LUFA_PATH)
|
||||
$(call ERROR_IF_NONBOOL, DOXYGEN_FAIL_ON_WARNING)
|
||||
|
||||
# Output Messages
|
||||
MSG_DOXYGEN_CMD := ' [DOXYGEN] :'
|
||||
|
||||
# Determine Doxygen invocation command
|
||||
BASE_DOXYGEN_CMD := ( cat $(DOXYGEN_CONF) $(DOXYGEN_OVERRIDE_PARAMS:%=; echo "%") ) | doxygen -
|
||||
ifeq ($(DOXYGEN_FAIL_ON_WARNING), Y)
|
||||
DOXYGEN_CMD := if ( $(BASE_DOXYGEN_CMD) 2>&1 | grep -v "warning: ignoring unsupported tag" ;); then exit 1; fi;
|
||||
else
|
||||
DOXYGEN_CMD := $(BASE_DOXYGEN_CMD)
|
||||
endif
|
||||
|
||||
# Error if the specified Doxygen configuration file does not exist
|
||||
$(DOXYGEN_CONF):
|
||||
$(error Doxygen configuration file $@ does not exist)
|
||||
|
||||
# Builds the project documentation using the specified configuration file and the DOXYGEN tool
|
||||
doxygen: $(DOXYGEN_CONF) $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DOXYGEN_CMD) Configuration file \"$(DOXYGEN_CONF)\" with parameters \"$(DOXYGEN_OVERRIDE_PARAMS)\"
|
||||
$(DOXYGEN_CMD)
|
||||
|
||||
# Upgrades an existing Doxygen configuration file to the latest Doxygen template, preserving settings
|
||||
doxygen_upgrade: $(DOXYGEN_CONF) $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DOXYGEN_CMD) Upgrading configuration file \"$(DOXYGEN_CONF)\" with latest template
|
||||
doxygen -u $(DOXYGEN_CONF) > /dev/null
|
||||
|
||||
# Creates a new Doxygen configuration file with the set file name
|
||||
doxygen_create: $(MAKEFILE_LIST)
|
||||
@echo $(MSG_DOXYGEN_CMD) Creating new configuration file \"$(DOXYGEN_CONF)\" with latest template
|
||||
doxygen -g $(DOXYGEN_CONF) > /dev/null
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: doxygen doxygen_upgrade doxygen_create
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += HID
|
||||
LUFA_BUILD_TARGETS += hid hid-ee teensy teensy-ee
|
||||
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
||||
LUFA_BUILD_OPTIONAL_VARS +=
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA HID Bootloader Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to re-program a device currently running a HID
|
||||
# class bootloader with a project's FLASH files.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# hid - Program FLASH into target via
|
||||
# hid_bootloader_cli
|
||||
# hid-ee - Program EEPROM into target via a temporary
|
||||
# AVR application and hid_bootloader_cli
|
||||
# teensy - Program FLASH into target via
|
||||
# teensy_loader_cli
|
||||
# teensy-ee - Program EEPROM into target via a temporary
|
||||
# AVR application and teensy_loader_cli
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# MCU - Microcontroller device model name
|
||||
# TARGET - Application name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Sanity-check values of mandatory user-supplied variables
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
|
||||
# Output Messages
|
||||
MSG_HID_BOOTLOADER_CMD := ' [HID] :'
|
||||
MSG_OBJCPY_CMD := ' [OBJCPY] :'
|
||||
MSG_MAKE_CMD := ' [MAKE] :'
|
||||
|
||||
# Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
|
||||
hid: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
|
||||
hid_bootloader_cli -mmcu=$(MCU) -v $<
|
||||
|
||||
# Programs in the target EEPROM memory using the HID_BOOTLOADER_CLI tool (note: clears target FLASH memory)
|
||||
hid-ee: $(TARGET).eep $(MAKEFILE_LIST)
|
||||
@echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
|
||||
avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin
|
||||
@echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
|
||||
make -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) clean hid
|
||||
|
||||
# Programs in the target FLASH memory using the TEENSY_BOOTLOADER_CLI tool
|
||||
teensy: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
|
||||
teensy_loader_cli -mmcu=$(MCU) -v $<
|
||||
|
||||
# Programs in the target EEPROM memory using the TEENSY_BOOTLOADER_CLI tool (note: clears target FLASH memory)
|
||||
teensy-ee: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
|
||||
avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin
|
||||
@echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
|
||||
make -s -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) clean hid-teensy
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: hid hid-ee teensy teensy-ee
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += HID
|
||||
LUFA_BUILD_TARGETS += hid hid-ee teensy teensy-ee
|
||||
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
||||
LUFA_BUILD_OPTIONAL_VARS +=
|
||||
LUFA_BUILD_PROVIDED_VARS +=
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA HID Bootloader Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of targets to re-program a device currently running a HID
|
||||
# class bootloader with a project's FLASH files.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# hid - Program FLASH into target via
|
||||
# hid_bootloader_cli
|
||||
# hid-ee - Program EEPROM into target via a temporary
|
||||
# AVR application and hid_bootloader_cli
|
||||
# teensy - Program FLASH into target via
|
||||
# teensy_loader_cli
|
||||
# teensy-ee - Program EEPROM into target via a temporary
|
||||
# AVR application and teensy_loader_cli
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# MCU - Microcontroller device model name
|
||||
# TARGET - Application name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Sanity-check values of mandatory user-supplied variables
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, MCU)
|
||||
$(call ERROR_IF_EMPTY, TARGET)
|
||||
|
||||
# Output Messages
|
||||
MSG_HID_BOOTLOADER_CMD := ' [HID] :'
|
||||
MSG_OBJCPY_CMD := ' [OBJCPY] :'
|
||||
MSG_MAKE_CMD := ' [MAKE] :'
|
||||
|
||||
# Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
|
||||
hid: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
|
||||
hid_bootloader_cli -mmcu=$(MCU) -v $<
|
||||
|
||||
# Programs in the target EEPROM memory using the HID_BOOTLOADER_CLI tool (note: clears target FLASH memory)
|
||||
hid-ee: $(TARGET).eep $(MAKEFILE_LIST)
|
||||
@echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
|
||||
avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin
|
||||
@echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
|
||||
make -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) clean hid
|
||||
|
||||
# Programs in the target FLASH memory using the TEENSY_BOOTLOADER_CLI tool
|
||||
teensy: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
|
||||
teensy_loader_cli -mmcu=$(MCU) -v $<
|
||||
|
||||
# Programs in the target EEPROM memory using the TEENSY_BOOTLOADER_CLI tool (note: clears target FLASH memory)
|
||||
teensy-ee: $(TARGET).hex $(MAKEFILE_LIST)
|
||||
@echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
|
||||
avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin
|
||||
@echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
|
||||
make -s -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) clean hid-teensy
|
||||
|
||||
# Phony build targets for this module
|
||||
.PHONY: hid hid-ee teensy teensy-ee
|
||||
|
||||
@@ -1,143 +1,143 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += SOURCES
|
||||
LUFA_BUILD_TARGETS +=
|
||||
LUFA_BUILD_MANDATORY_VARS += LUFA_PATH ARCH
|
||||
LUFA_BUILD_OPTIONAL_VARS +=
|
||||
LUFA_BUILD_PROVIDED_VARS += LUFA_SRC_USB_DEVICE LUFA_SRC_USB_HOST \
|
||||
LUFA_SRC_USB LUFA_SRC_USBCLASS_DEVICE \
|
||||
LUFA_SRC_USBCLASS_HOST LUFA_SRC_USBCLASS \
|
||||
LUFA_SRC_TEMPERATURE LUFA_SRC_SERIAL \
|
||||
LUFA_SRC_TWI LUFA_SRC_PLATFORM
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA Sources Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of makefile variables for the various LUFA module sources.
|
||||
# Once included, the sources required to use a given LUFA module will become
|
||||
# available using the makefile variable names listed in the LUFA project
|
||||
# documentation.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# LUFA_PATH - Path to the LUFA library core
|
||||
# ARCH - Device architecture name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# LUFA_SRC_USB_DEVICE - List of LUFA USB driver source files required
|
||||
# for USB Device mode only
|
||||
# LUFA_SRC_USB_HOST - List of LUFA USB driver source files required
|
||||
# for USB Host mode only
|
||||
# LUFA_SRC_USB - List of LUFA USB driver source files for all
|
||||
# USB modes
|
||||
# LUFA_SRC_USBCLASS_DEVICE - List of LUFA USB Class driver source files for
|
||||
# USB Device mode only
|
||||
# LUFA_SRC_USBCLASS_HOST - List of LUFA USB Class driver source files for
|
||||
# USB Host mode only
|
||||
# LUFA_SRC_USBCLASS - List of LUFA USB Class driver source files for
|
||||
# all USB modes
|
||||
# LUFA_SRC_TEMPERATURE - List of LUFA temperature sensor driver source
|
||||
# files
|
||||
# LUFA_SRC_SERIAL - List of LUFA Serial U(S)ART driver source files
|
||||
# LUFA_SRC_TWI - List of LUFA TWI driver source files
|
||||
# LUFA_SRC_PLATFORM - List of LUFA architecture specific platform
|
||||
# management source files
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, LUFA_PATH)
|
||||
$(call ERROR_IF_EMPTY, ARCH)
|
||||
|
||||
# Allow LUFA_ROOT_PATH to be overridden elsewhere to support legacy LUFA makefiles
|
||||
LUFA_ROOT_PATH ?= $(patsubst %/,%,$(LUFA_PATH))
|
||||
|
||||
# Construct LUFA module source variables
|
||||
LUFA_SRC_USB_COMMON := $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBController_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBInterrupt_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/ConfigDescriptors.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/Events.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/USBTask.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Common/HIDParser.c \
|
||||
|
||||
LUFA_SRC_USB_HOST := $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Host_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Pipe_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/PipeStream_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/HostStandardReq.c \
|
||||
$(LUFA_SRC_USB_COMMON)
|
||||
|
||||
LUFA_SRC_USB_DEVICE := $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Device_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Endpoint_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/EndpointStream_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/DeviceStandardReq.c \
|
||||
$(LUFA_SRC_USB_COMMON)
|
||||
|
||||
LUFA_SRC_USBCLASS_DEVICE := $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/AudioClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDCClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HIDClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorageClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDIClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDISClassDevice.c \
|
||||
|
||||
LUFA_SRC_USBCLASS_HOST := $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AudioClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDCClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HIDClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorageClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDIClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/PrinterClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDISClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/StillImageClassHost.c
|
||||
|
||||
LUFA_SRC_USB := $(sort $(LUFA_SRC_USB_COMMON) $(LUFA_SRC_USB_HOST) $(LUFA_SRC_USB_DEVICE))
|
||||
|
||||
LUFA_SRC_USBCLASS := $(LUFA_SRC_USBCLASS_DEVICE) $(LUFA_SRC_USBCLASS_HOST)
|
||||
|
||||
LUFA_SRC_TEMPERATURE := $(LUFA_ROOT_PATH)/Drivers/Board/Temperature.c
|
||||
|
||||
LUFA_SRC_SERIAL := $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/Serial_$(ARCH).c
|
||||
|
||||
LUFA_SRC_TWI := $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/TWI_$(ARCH).c
|
||||
|
||||
ifeq ($(ARCH), UC3)
|
||||
LUFA_SRC_PLATFORM := $(LUFA_ROOT_PATH)/Platform/UC3/Exception.S \
|
||||
$(LUFA_ROOT_PATH)/Platform/UC3/InterruptManagement.c
|
||||
else
|
||||
LUFA_SRC_PLATFORM :=
|
||||
endif
|
||||
|
||||
# Build a list of all available module sources
|
||||
LUFA_SRC_ALL_FILES := $(LUFA_SRC_USB) \
|
||||
$(LUFA_SRC_USBCLASS) \
|
||||
$(LUFA_SRC_TEMPERATURE) \
|
||||
$(LUFA_SRC_SERIAL) \
|
||||
$(LUFA_SRC_TWI) \
|
||||
$(LUFA_SRC_PLATFORM)
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2013.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
|
||||
LUFA_BUILD_MODULES += SOURCES
|
||||
LUFA_BUILD_TARGETS +=
|
||||
LUFA_BUILD_MANDATORY_VARS += LUFA_PATH ARCH
|
||||
LUFA_BUILD_OPTIONAL_VARS +=
|
||||
LUFA_BUILD_PROVIDED_VARS += LUFA_SRC_USB_DEVICE LUFA_SRC_USB_HOST \
|
||||
LUFA_SRC_USB LUFA_SRC_USBCLASS_DEVICE \
|
||||
LUFA_SRC_USBCLASS_HOST LUFA_SRC_USBCLASS \
|
||||
LUFA_SRC_TEMPERATURE LUFA_SRC_SERIAL \
|
||||
LUFA_SRC_TWI LUFA_SRC_PLATFORM
|
||||
LUFA_BUILD_PROVIDED_MACROS +=
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# LUFA Sources Buildsystem Makefile Module.
|
||||
# -----------------------------------------------------------------------------
|
||||
# DESCRIPTION:
|
||||
# Provides a set of makefile variables for the various LUFA module sources.
|
||||
# Once included, the sources required to use a given LUFA module will become
|
||||
# available using the makefile variable names listed in the LUFA project
|
||||
# documentation.
|
||||
# -----------------------------------------------------------------------------
|
||||
# TARGETS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# MANDATORY PARAMETERS:
|
||||
#
|
||||
# LUFA_PATH - Path to the LUFA library core
|
||||
# ARCH - Device architecture name
|
||||
#
|
||||
# OPTIONAL PARAMETERS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# PROVIDED VARIABLES:
|
||||
#
|
||||
# LUFA_SRC_USB_DEVICE - List of LUFA USB driver source files required
|
||||
# for USB Device mode only
|
||||
# LUFA_SRC_USB_HOST - List of LUFA USB driver source files required
|
||||
# for USB Host mode only
|
||||
# LUFA_SRC_USB - List of LUFA USB driver source files for all
|
||||
# USB modes
|
||||
# LUFA_SRC_USBCLASS_DEVICE - List of LUFA USB Class driver source files for
|
||||
# USB Device mode only
|
||||
# LUFA_SRC_USBCLASS_HOST - List of LUFA USB Class driver source files for
|
||||
# USB Host mode only
|
||||
# LUFA_SRC_USBCLASS - List of LUFA USB Class driver source files for
|
||||
# all USB modes
|
||||
# LUFA_SRC_TEMPERATURE - List of LUFA temperature sensor driver source
|
||||
# files
|
||||
# LUFA_SRC_SERIAL - List of LUFA Serial U(S)ART driver source files
|
||||
# LUFA_SRC_TWI - List of LUFA TWI driver source files
|
||||
# LUFA_SRC_PLATFORM - List of LUFA architecture specific platform
|
||||
# management source files
|
||||
#
|
||||
# PROVIDED MACROS:
|
||||
#
|
||||
# (None)
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||
|
||||
# Sanity check user supplied values
|
||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||
$(call ERROR_IF_EMPTY, LUFA_PATH)
|
||||
$(call ERROR_IF_EMPTY, ARCH)
|
||||
|
||||
# Allow LUFA_ROOT_PATH to be overridden elsewhere to support legacy LUFA makefiles
|
||||
LUFA_ROOT_PATH ?= $(patsubst %/,%,$(LUFA_PATH))
|
||||
|
||||
# Construct LUFA module source variables
|
||||
LUFA_SRC_USB_COMMON := $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBController_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBInterrupt_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/ConfigDescriptors.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/Events.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/USBTask.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Common/HIDParser.c \
|
||||
|
||||
LUFA_SRC_USB_HOST := $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Host_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Pipe_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/PipeStream_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/HostStandardReq.c \
|
||||
$(LUFA_SRC_USB_COMMON)
|
||||
|
||||
LUFA_SRC_USB_DEVICE := $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Device_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Endpoint_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/EndpointStream_$(ARCH).c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Core/DeviceStandardReq.c \
|
||||
$(LUFA_SRC_USB_COMMON)
|
||||
|
||||
LUFA_SRC_USBCLASS_DEVICE := $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/AudioClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDCClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HIDClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorageClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDIClassDevice.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDISClassDevice.c \
|
||||
|
||||
LUFA_SRC_USBCLASS_HOST := $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AudioClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDCClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HIDClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorageClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDIClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/PrinterClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDISClassHost.c \
|
||||
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/StillImageClassHost.c
|
||||
|
||||
LUFA_SRC_USB := $(sort $(LUFA_SRC_USB_COMMON) $(LUFA_SRC_USB_HOST) $(LUFA_SRC_USB_DEVICE))
|
||||
|
||||
LUFA_SRC_USBCLASS := $(LUFA_SRC_USBCLASS_DEVICE) $(LUFA_SRC_USBCLASS_HOST)
|
||||
|
||||
LUFA_SRC_TEMPERATURE := $(LUFA_ROOT_PATH)/Drivers/Board/Temperature.c
|
||||
|
||||
LUFA_SRC_SERIAL := $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/Serial_$(ARCH).c
|
||||
|
||||
LUFA_SRC_TWI := $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/TWI_$(ARCH).c
|
||||
|
||||
ifeq ($(ARCH), UC3)
|
||||
LUFA_SRC_PLATFORM := $(LUFA_ROOT_PATH)/Platform/UC3/Exception.S \
|
||||
$(LUFA_ROOT_PATH)/Platform/UC3/InterruptManagement.c
|
||||
else
|
||||
LUFA_SRC_PLATFORM :=
|
||||
endif
|
||||
|
||||
# Build a list of all available module sources
|
||||
LUFA_SRC_ALL_FILES := $(LUFA_SRC_USB) \
|
||||
$(LUFA_SRC_USBCLASS) \
|
||||
$(LUFA_SRC_TEMPERATURE) \
|
||||
$(LUFA_SRC_SERIAL) \
|
||||
$(LUFA_SRC_TWI) \
|
||||
$(LUFA_SRC_PLATFORM)
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
*
|
||||
* \param[in] x Value to check compile-time constantness of.
|
||||
*
|
||||
* \return Boolean true if the given value is known to be a compile time constant, false otherwise.
|
||||
* \return Boolean \c true if the given value is known to be a compile time constant, \c false otherwise.
|
||||
*/
|
||||
#define GCC_IS_COMPILE_CONST(x) __builtin_constant_p(x)
|
||||
#else
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
* - Library Applications:
|
||||
* - Added handler for SCSI_CMD_START_STOP_UNIT in demos using the Mass Storage class, to prevent ejection errors on *nix systems due to an
|
||||
* unknown SCSI command
|
||||
* - Fixed incorrect HID report descriptor generated for 16-bit axis ranges by the HID_DESCRIPTOR_MOUSE() and HID_DESCRIPTOR_JOYSTICK()
|
||||
* macros (thanks to Armory)
|
||||
*
|
||||
* \section Sec_ChangeLog130303 Version 130303
|
||||
* <b>New:</b>
|
||||
|
||||
@@ -151,7 +151,8 @@
|
||||
* solutions with no source code given. Those companies which have purchased a Commercial License to LUFA (see \ref Page_LicenseInfo)
|
||||
* are not listed here unless specifically requested.
|
||||
*
|
||||
* \li Arduino Uno, the official Arduino board: http://www.arduino.cc
|
||||
* \li Alphasphere, a MIDI input sphere device for music creation: http://www.alphasphere.com/
|
||||
* \li Arduino Uno and Leonardo, official Arduino boards: http://www.arduino.cc
|
||||
* \li ARPS Locator: http://la3t.hamradio.no/lab//?id=tracker_en
|
||||
* \li AsTeRICS assistive technologies project, HID actuator: http://www.asterics.eu
|
||||
* \li Ceberus, a MadCatz Xbox 360 arcade stick modifier: http://www.phreakmods.com/products/cerberus
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
(BOARD == BOARD_MICROPENDOUS_32U2) || defined(__DOXYGEN__))
|
||||
#include "../../LEDs.h"
|
||||
|
||||
/** Indicates the board has hardware LEDs mounted. */
|
||||
/** Indicates the board has a hardware LEDs mounted. */
|
||||
#define BOARD_HAS_LEDS
|
||||
#endif
|
||||
|
||||
|
||||
@@ -136,6 +136,9 @@
|
||||
#if (BOARD == BOARD_MICROPENDOUS_32U2)
|
||||
#define _BOARD_BUTTON1_MASK (1 << 7)
|
||||
#define _BOARD_BUTTON_PORTLETTER D
|
||||
#elif (BOARD == BOARD_MICROPENDOUS_32U4)
|
||||
#define _BOARD_BUTTON1_MASK (1 << 2)
|
||||
#define _BOARD_BUTTON_PORTLETTER E
|
||||
#elif (BOARD == BOARD_MICROPENDOUS_A)
|
||||
#define _BOARD_BUTTON1_MASK (1 << 2)
|
||||
#define _BOARD_BUTTON_PORTLETTER E
|
||||
|
||||
@@ -131,56 +131,46 @@
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void LEDs_Init(void)
|
||||
{
|
||||
//_BOARD_LED_DDR |= LEDS_ALL_LEDS;
|
||||
//_BOARD_LED_PORT &= ~LEDS_ALL_LEDS;
|
||||
DDRB |= (1 << PB1);
|
||||
PORTB |= (1 << PB1);
|
||||
_BOARD_LED_DDR |= LEDS_ALL_LEDS;
|
||||
_BOARD_LED_PORT &= ~LEDS_ALL_LEDS;
|
||||
}
|
||||
|
||||
static inline void LEDs_Disable(void)
|
||||
{
|
||||
//_BOARD_LED_DDR &= ~LEDS_ALL_LEDS;
|
||||
//_BOARD_LED_PORT &= ~LEDS_ALL_LEDS;
|
||||
DDRB &= ~(1 << PB1);
|
||||
PORTB &= ~(1 << PB1);
|
||||
_BOARD_LED_DDR &= ~LEDS_ALL_LEDS;
|
||||
_BOARD_LED_PORT &= ~LEDS_ALL_LEDS;
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
//_BOARD_LED_PORT |= LEDMask;
|
||||
PORTB |= LEDMask;
|
||||
_BOARD_LED_PORT |= LEDMask;
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
//_BOARD_LED_PORT &= ~LEDMask;
|
||||
PORTB &= ~LEDMask;
|
||||
_BOARD_LED_PORT &= ~LEDMask;
|
||||
}
|
||||
|
||||
static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
//_BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDS_ALL_LEDS) | LEDMask);
|
||||
PORTB = ((_BOARD_LED_PORT & ~LEDS_ALL_LEDS) | LEDMask);
|
||||
_BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDS_ALL_LEDS) | LEDMask);
|
||||
}
|
||||
|
||||
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
|
||||
const uint8_t ActiveMask)
|
||||
{
|
||||
//_BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDMask) | ActiveMask);
|
||||
PORTB = ((_BOARD_LED_PORT & ~LEDMask) | ActiveMask);
|
||||
_BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDMask) | ActiveMask);
|
||||
}
|
||||
|
||||
static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
//_BOARD_LED_PIN = LEDMask;
|
||||
PORTB = LEDMask;
|
||||
_BOARD_LED_PIN = LEDMask;
|
||||
}
|
||||
|
||||
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t LEDs_GetLEDs(void)
|
||||
{
|
||||
//return (_BOARD_LED_PORT & LEDS_ALL_LEDS);
|
||||
return (PORTB & (1 << PB0));
|
||||
return (_BOARD_LED_PORT & LEDS_ALL_LEDS);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -124,10 +124,10 @@
|
||||
#elif ((BOARD == BOARD_USB2AX) || (BOARD == BOARD_USB2AX_V3) || (BOARD == BOARD_USB2AX_V31))
|
||||
#include "AVR8/USB2AX/Board.h"
|
||||
#elif ((BOARD == BOARD_MICROPENDOUS_REV1) || (BOARD == BOARD_MICROPENDOUS_REV2) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_32U2) || (BOARD == BOARD_MICROPENDOUS_A) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_32U2) || (BOARD == BOARD_MICROPENDOUS_32U4) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_1) || (BOARD == BOARD_MICROPENDOUS_2) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_3) || (BOARD == BOARD_MICROPENDOUS_4) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_DIP))
|
||||
(BOARD == BOARD_MICROPENDOUS_DIP) || (BOARD == BOARD_MICROPENDOUS_A) )
|
||||
#include "AVR8/MICROPENDOUS/Board.h"
|
||||
#elif (BOARD == BOARD_B1_XPLAINED)
|
||||
#include "XMEGA/B1_XPLAINED/Board.h"
|
||||
|
||||
@@ -135,11 +135,11 @@
|
||||
#include "XMEGA/A3BU_XPLAINED/Buttons.h"
|
||||
#elif ((BOARD == BOARD_USB2AX) || (BOARD == BOARD_USB2AX_V3))
|
||||
#include "AVR8/USB2AX/Buttons.h"
|
||||
#elif ( (BOARD == BOARD_MICROPENDOUS_32U2) || (BOARD == BOARD_MICROPENDOUS_A) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_1) || (BOARD == BOARD_MICROPENDOUS_2) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_3) || (BOARD == BOARD_MICROPENDOUS_4) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_REV1) || (BOARD == BOARD_MICROPENDOUS_REV2) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_DIP) || (BOARD == BOARD_MICROPENDOUS_32U4) )
|
||||
#elif ((BOARD == BOARD_MICROPENDOUS_32U2) || (BOARD == BOARD_MICROPENDOUS_A) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_1) || (BOARD == BOARD_MICROPENDOUS_2) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_3) || (BOARD == BOARD_MICROPENDOUS_4) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_REV1) || (BOARD == BOARD_MICROPENDOUS_REV2) || \
|
||||
(BOARD == BOARD_MICROPENDOUS_DIP))
|
||||
#include "AVR8/MICROPENDOUS/Buttons.h"
|
||||
#elif (BOARD == BOARD_B1_XPLAINED)
|
||||
#include "XMEGA/B1_XPLAINED/Buttons.h"
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
*
|
||||
* \param[in,out] Buffer Pointer to a ring buffer structure to insert into.
|
||||
*
|
||||
* \return Boolean \c true if the buffer contains no free space, false otherwise.
|
||||
* \return Boolean \c true if the buffer contains no free space, \c false otherwise.
|
||||
*/
|
||||
static inline bool RingBuffer_IsEmpty(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
|
||||
static inline bool RingBuffer_IsEmpty(RingBuffer_t* const Buffer)
|
||||
@@ -218,7 +218,7 @@
|
||||
*
|
||||
* \param[in,out] Buffer Pointer to a ring buffer structure to insert into.
|
||||
*
|
||||
* \return Boolean \c true if the buffer contains no free space, false otherwise.
|
||||
* \return Boolean \c true if the buffer contains no free space, \c false otherwise.
|
||||
*/
|
||||
static inline bool RingBuffer_IsFull(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
|
||||
static inline bool RingBuffer_IsFull(RingBuffer_t* const Buffer)
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
/** Turns on inverse so that any following text is printed to the terminal in inverted colours. */
|
||||
#define ESC_INVERSE_ON ANSI_ESCAPE_SEQUENCE("7m")
|
||||
|
||||
/** Turns on strikethrough so that any following text is printed to the terminal with a line through the
|
||||
/** Turns on strike-through so that any following text is printed to the terminal with a line through the
|
||||
* center.
|
||||
*/
|
||||
#define ESC_STRIKETHROUGH_ON ANSI_ESCAPE_SEQUENCE("9m")
|
||||
@@ -110,7 +110,7 @@
|
||||
/** Turns off inverse so that any following text is printed to the terminal in non inverted colours. */
|
||||
#define ESC_INVERSE_OFF ANSI_ESCAPE_SEQUENCE("27m")
|
||||
|
||||
/** Turns off strikethrough so that any following text is printed to the terminal without a line through
|
||||
/** Turns off strike-through so that any following text is printed to the terminal without a line through
|
||||
* the center.
|
||||
*/
|
||||
#define ESC_STRIKETHROUGH_OFF ANSI_ESCAPE_SEQUENCE("29m")
|
||||
|
||||
@@ -369,7 +369,7 @@
|
||||
|
||||
/** Indicates if the current ADC conversion is completed, or still in progress.
|
||||
*
|
||||
* \return Boolean false if the reading is still taking place, or true if the conversion is
|
||||
* \return Boolean \c false if the reading is still taking place, or true if the conversion is
|
||||
* complete and ready to be read out with \ref ADC_GetResult().
|
||||
*/
|
||||
static inline bool ADC_IsReadingComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
* send and/or received.
|
||||
*
|
||||
* \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class host configuration and state.
|
||||
* \param[in] EnableStreaming Boolean true to enable streaming of the specified interface, false to disable
|
||||
* \param[in] EnableStreaming Boolean true to enable streaming of the specified interface, \c false to disable
|
||||
*
|
||||
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.
|
||||
*/
|
||||
|
||||
@@ -501,7 +501,7 @@
|
||||
UECONX |= (1 << STALLRQC);
|
||||
}
|
||||
|
||||
/** Determines if the currently selected endpoint is stalled, false otherwise.
|
||||
/** Determines if the currently selected endpoint is stalled, \c false otherwise.
|
||||
*
|
||||
* \ingroup Group_EndpointPacketManagement_AVR8
|
||||
*
|
||||
|
||||
@@ -236,7 +236,7 @@
|
||||
}
|
||||
|
||||
/** Determines if the attached device is currently issuing a Remote Wakeup request, requesting
|
||||
* that the host resume the USB bus and wake up the device, false otherwise.
|
||||
* that the host resume the USB bus and wake up the device, \c false otherwise.
|
||||
*
|
||||
* \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.
|
||||
*/
|
||||
|
||||
@@ -501,7 +501,7 @@
|
||||
(&AVR32_USBB.UECON0CLR)[USB_Endpoint_SelectedEndpoint].stallrqc = true;
|
||||
}
|
||||
|
||||
/** Determines if the currently selected endpoint is stalled, false otherwise.
|
||||
/** Determines if the currently selected endpoint is stalled, \c false otherwise.
|
||||
*
|
||||
* \ingroup Group_EndpointPacketManagement_UC3
|
||||
*
|
||||
|
||||
@@ -233,7 +233,7 @@
|
||||
}
|
||||
|
||||
/** Determines if the attached device is currently issuing a Remote Wakeup request, requesting
|
||||
* that the host resume the USB bus and wake up the device, false otherwise.
|
||||
* that the host resume the USB bus and wake up the device, \c false otherwise.
|
||||
*
|
||||
* \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.
|
||||
*/
|
||||
|
||||
@@ -495,7 +495,7 @@
|
||||
USB_Endpoint_SelectedHandle->CTRL &= ~USB_EP_STALL_bm;
|
||||
}
|
||||
|
||||
/** Determines if the currently selected endpoint is stalled, false otherwise.
|
||||
/** Determines if the currently selected endpoint is stalled, \c false otherwise.
|
||||
*
|
||||
* \ingroup Group_EndpointPacketManagement_XMEGA
|
||||
*
|
||||
|
||||
@@ -263,7 +263,7 @@ uint8_t ISPTarget_TransferSoftSPIByte(const uint8_t Byte)
|
||||
/** Asserts or deasserts the target's reset line, using the correct polarity as set by the host using a SET PARAM command.
|
||||
* When not asserted, the line is tristated so as not to interfere with normal device operation.
|
||||
*
|
||||
* \param[in] ResetTarget Boolean true when the target should be held in reset, false otherwise
|
||||
* \param[in] ResetTarget Boolean true when the target should be held in reset, \c false otherwise
|
||||
*/
|
||||
void ISPTarget_ChangeTargetResetLine(const bool ResetTarget)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ static void TINYNVM_SendWriteNVMRegister(const uint8_t Address)
|
||||
|
||||
/** Busy-waits while the NVM controller is busy performing a NVM operation, such as a FLASH page read.
|
||||
*
|
||||
* \return Boolean true if the NVM controller became ready within the timeout period, false otherwise
|
||||
* \return Boolean \c true if the NVM controller became ready within the timeout period, \c false otherwise
|
||||
*/
|
||||
bool TINYNVM_WaitWhileNVMBusBusy(void)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ bool TINYNVM_WaitWhileNVMBusBusy(void)
|
||||
/** Waits while the target's NVM controller is busy performing an operation, exiting if the
|
||||
* timeout period expires.
|
||||
*
|
||||
* \return Boolean true if the NVM controller became ready within the timeout period, false otherwise
|
||||
* \return Boolean \c true if the NVM controller became ready within the timeout period, \c false otherwise
|
||||
*/
|
||||
bool TINYNVM_WaitWhileNVMControllerBusy(void)
|
||||
{
|
||||
@@ -121,7 +121,7 @@ bool TINYNVM_WaitWhileNVMControllerBusy(void)
|
||||
|
||||
/** Enables the physical TPI interface on the target and enables access to the internal NVM controller.
|
||||
*
|
||||
* \return Boolean true if the TPI interface was enabled successfully, false otherwise
|
||||
* \return Boolean \c true if the TPI interface was enabled successfully, \c false otherwise
|
||||
*/
|
||||
bool TINYNVM_EnableTPI(void)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ void TINYNVM_DisableTPI(void)
|
||||
* \param[out] ReadBuffer Buffer to store read data into
|
||||
* \param[in] ReadSize Length of the data to read from the device
|
||||
*
|
||||
* \return Boolean true if the command sequence complete successfully
|
||||
* \return Boolean \c true if the command sequence complete successfully
|
||||
*/
|
||||
bool TINYNVM_ReadMemory(const uint16_t ReadAddress,
|
||||
uint8_t* ReadBuffer,
|
||||
@@ -198,7 +198,7 @@ bool TINYNVM_ReadMemory(const uint16_t ReadAddress,
|
||||
* \param[in] WriteBuffer Buffer to source data from
|
||||
* \param[in] WriteLength Total number of bytes to write to the device (must be an integer multiple of 2)
|
||||
*
|
||||
* \return Boolean true if the command sequence complete successfully
|
||||
* \return Boolean \c true if the command sequence complete successfully
|
||||
*/
|
||||
bool TINYNVM_WriteMemory(const uint16_t WriteAddress,
|
||||
uint8_t* WriteBuffer,
|
||||
@@ -245,7 +245,7 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress,
|
||||
* \param[in] EraseCommand NVM erase command to send to the device
|
||||
* \param[in] Address Address inside the memory space to erase
|
||||
*
|
||||
* \return Boolean true if the command sequence complete successfully
|
||||
* \return Boolean \c true if the command sequence complete successfully
|
||||
*/
|
||||
bool TINYNVM_EraseMemory(const uint8_t EraseCommand,
|
||||
const uint16_t Address)
|
||||
|
||||
@@ -67,7 +67,7 @@ static void XMEGANVM_SendNVMRegAddress(const uint8_t Register)
|
||||
/** Busy-waits while the NVM controller is busy performing a NVM operation, such as a FLASH page read or CRC
|
||||
* calculation.
|
||||
*
|
||||
* \return Boolean true if the NVM controller became ready within the timeout period, false otherwise
|
||||
* \return Boolean \c true if the NVM controller became ready within the timeout period, \c false otherwise
|
||||
*/
|
||||
bool XMEGANVM_WaitWhileNVMBusBusy(void)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ bool XMEGANVM_WaitWhileNVMBusBusy(void)
|
||||
/** Waits while the target's NVM controller is busy performing an operation, exiting if the
|
||||
* timeout period expires.
|
||||
*
|
||||
* \return Boolean true if the NVM controller became ready within the timeout period, false otherwise
|
||||
* \return Boolean \c true if the NVM controller became ready within the timeout period, \c false otherwise
|
||||
*/
|
||||
bool XMEGANVM_WaitWhileNVMControllerBusy(void)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ bool XMEGANVM_WaitWhileNVMControllerBusy(void)
|
||||
|
||||
/** Enables the physical PDI interface on the target and enables access to the internal NVM controller.
|
||||
*
|
||||
* \return Boolean true if the PDI interface was enabled successfully, false otherwise
|
||||
* \return Boolean \c true if the PDI interface was enabled successfully, \c false otherwise
|
||||
*/
|
||||
bool XMEGANVM_EnablePDI(void)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ void XMEGANVM_DisablePDI(void)
|
||||
* \param[in] CRCCommand NVM CRC command to issue to the target
|
||||
* \param[out] CRCDest CRC Destination when read from the target
|
||||
*
|
||||
* \return Boolean true if the command sequence complete successfully
|
||||
* \return Boolean \c true if the command sequence complete successfully
|
||||
*/
|
||||
bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand,
|
||||
uint32_t* const CRCDest)
|
||||
@@ -221,7 +221,7 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand,
|
||||
* \param[out] ReadBuffer Buffer to store read data into
|
||||
* \param[in] ReadSize Number of bytes to read
|
||||
*
|
||||
* \return Boolean true if the command sequence complete successfully
|
||||
* \return Boolean \c true if the command sequence complete successfully
|
||||
*/
|
||||
bool XMEGANVM_ReadMemory(const uint32_t ReadAddress,
|
||||
uint8_t* ReadBuffer,
|
||||
@@ -258,7 +258,7 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress,
|
||||
* \param[in] WriteAddress Address to write to within the target's address space
|
||||
* \param[in] Byte Byte to write to the target
|
||||
*
|
||||
* \return Boolean true if the command sequence complete successfully
|
||||
* \return Boolean \c true if the command sequence complete successfully
|
||||
*/
|
||||
bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand,
|
||||
const uint32_t WriteAddress,
|
||||
@@ -291,7 +291,7 @@ bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand,
|
||||
* \param[in] WriteBuffer Buffer to source data from
|
||||
* \param[in] WriteSize Number of bytes to write
|
||||
*
|
||||
* \return Boolean true if the command sequence complete successfully
|
||||
* \return Boolean \c true if the command sequence complete successfully
|
||||
*/
|
||||
bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand,
|
||||
const uint8_t EraseBuffCommand,
|
||||
@@ -368,7 +368,7 @@ bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand,
|
||||
* \param[in] EraseCommand NVM erase command to send to the device
|
||||
* \param[in] Address Address inside the memory space to erase
|
||||
*
|
||||
* \return Boolean true if the command sequence complete successfully
|
||||
* \return Boolean \c true if the command sequence complete successfully
|
||||
*/
|
||||
bool XMEGANVM_EraseMemory(const uint8_t EraseCommand,
|
||||
const uint32_t Address)
|
||||
|
||||
@@ -314,7 +314,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
*
|
||||
* \param[in] CurrentItem Pointer to the item the HID report parser is currently working with
|
||||
*
|
||||
* \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded
|
||||
* \return Boolean \c true if the item should be stored into the HID report structure, \c false if it should be discarded
|
||||
*/
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user