Add branch for the conversion of demos to use standard C header files for configuration, rather than makefile defined macros.
This commit is contained in:
parent
e8570c4a37
commit
359fbfe14d
395 changed files with 9912 additions and 2756 deletions
|
@ -41,6 +41,29 @@
|
|||
*/
|
||||
static bool RunBootloader = true;
|
||||
|
||||
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
|
||||
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
|
||||
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
|
||||
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
|
||||
*/
|
||||
uint32_t MagicBootKey ATTR_NO_INIT;
|
||||
|
||||
|
||||
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
|
||||
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
|
||||
* this will force the user application to start via a software jump.
|
||||
*/
|
||||
void Application_Jump_Check(void)
|
||||
{
|
||||
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
|
||||
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||
{
|
||||
MagicBootKey = 0;
|
||||
// cppcheck-suppress constStatement
|
||||
((void (*)(void))0x0000)();
|
||||
}
|
||||
}
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously
|
||||
* runs the bootloader processing routine until instructed to soft-exit.
|
||||
*/
|
||||
|
@ -58,6 +81,9 @@ int main(void)
|
|||
/* Disconnect from the host - USB interface will be reset later along with the AVR */
|
||||
USB_Detach();
|
||||
|
||||
/* Unlock the forced application start mode of the bootloader if it is restarted */
|
||||
MagicBootKey = MAGIC_BOOT_KEY;
|
||||
|
||||
/* Enable the watchdog and force a timeout to reset the AVR */
|
||||
wdt_enable(WDTO_250MS);
|
||||
|
||||
|
@ -85,9 +111,7 @@ static void SetupHardware(void)
|
|||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
/* Setup HID Report Endpoint */
|
||||
Endpoint_ConfigureEndpoint(HID_IN_EPNUM, EP_TYPE_INTERRUPT,
|
||||
ENDPOINT_DIR_IN, HID_IN_EPSIZE,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
Endpoint_ConfigureEndpoint(HID_IN_EPADDR, EP_TYPE_INTERRUPT, HID_IN_EPSIZE, 1);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
|
||||
|
|
|
@ -52,9 +52,14 @@
|
|||
/** Bootloader special address to start the user application */
|
||||
#define COMMAND_STARTAPPLICATION 0xFFFF
|
||||
|
||||
/** Magic bootloader key to unlock forced application start mode. */
|
||||
#define MAGIC_BOOT_KEY 0xDC42CACA
|
||||
|
||||
/* Function Prototypes: */
|
||||
static void SetupHardware(void);
|
||||
|
||||
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
|
||||
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||
|
||||
|
|
|
@ -51,10 +51,10 @@
|
|||
* from PJRC (used with permission). This bootloader is deliberatley non-compatible with the properietary PJRC
|
||||
* HalfKay bootloader GUI; only the command line interface software accompanying this bootloader will work with it.
|
||||
*
|
||||
* Out of the box this bootloader builds for the USB1287, and will fit into 2KB of bootloader space for the
|
||||
* Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for all other models. If you wish to
|
||||
* enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU values in the
|
||||
* accompanying makefile.
|
||||
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
|
||||
* into 2KB of bootloader space for the Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for
|
||||
* all other models. 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.
|
||||
*
|
||||
* \section Sec_Installation Driver Installation
|
||||
*
|
||||
|
|
|
@ -137,10 +137,10 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
|||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DIR_IN | HID_IN_EPNUM),
|
||||
.EndpointAddress = HID_IN_EPADDR,
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = HID_IN_EPSIZE,
|
||||
.PollingIntervalMS = 0x01
|
||||
.PollingIntervalMS = 0x05
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint number of the HID data IN endpoint. */
|
||||
#define HID_IN_EPNUM 1
|
||||
/** Endpoint address of the HID data IN endpoint. */
|
||||
#define HID_IN_EPADDR (ENDPOINT_DIR_IN | 1)
|
||||
|
||||
/** Size in bytes of the HID reporting IN endpoint. */
|
||||
#define HID_IN_EPSIZE 64
|
||||
|
|
|
@ -970,13 +970,9 @@ void parse_options(int argc, char **argv)
|
|||
} else if (strncmp(arg, "-mmcu=", 6) == 0) {
|
||||
arg += 6;
|
||||
|
||||
uint8_t valid_prefix = 0;
|
||||
|
||||
if (strncmp(arg, "at90usb", 7) == 0) {
|
||||
valid_prefix = 1;
|
||||
arg += 7;
|
||||
} else if (strncmp(arg, "atmega", 6) == 0) {
|
||||
valid_prefix = 1;
|
||||
arg += 6;
|
||||
} else {
|
||||
die("Unknown MCU type\n");
|
||||
|
|
|
@ -95,7 +95,7 @@ F_USB = $(F_CPU)
|
|||
# Note that the bootloader size and start address given in AVRStudio is in words and not
|
||||
# bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC.
|
||||
FLASH_SIZE_KB = 128
|
||||
BOOT_SECTION_SIZE_KB = 4
|
||||
BOOT_SECTION_SIZE_KB = 8
|
||||
|
||||
|
||||
# Formulas used to calculate the starting address of the Bootloader section. These formulas
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue