diff options
Diffstat (limited to 'Bootloaders')
-rw-r--r-- | Bootloaders/CDC/BootloaderAPI.h | 4 | ||||
-rw-r--r-- | Bootloaders/CDC/BootloaderCDC.c | 8 | ||||
-rw-r--r-- | Bootloaders/CDC/BootloaderCDC.h | 2 | ||||
-rw-r--r-- | Bootloaders/CDC/Descriptors.h | 4 | ||||
-rw-r--r-- | Bootloaders/DFU/BootloaderAPI.h | 4 | ||||
-rw-r--r-- | Bootloaders/DFU/BootloaderDFU.c | 9 | ||||
-rw-r--r-- | Bootloaders/DFU/Descriptors.c | 8 | ||||
-rw-r--r-- | Bootloaders/DFU/Descriptors.h | 2 | ||||
-rw-r--r-- | Bootloaders/HID/BootloaderHID.c | 29 | ||||
-rw-r--r-- | Bootloaders/HID/BootloaderHID.h | 23 | ||||
-rw-r--r-- | Bootloaders/HID/Descriptors.c | 53 | ||||
-rw-r--r-- | Bootloaders/HID/Descriptors.h | 19 | ||||
-rw-r--r-- | Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c | 6 |
13 files changed, 88 insertions, 83 deletions
diff --git a/Bootloaders/CDC/BootloaderAPI.h b/Bootloaders/CDC/BootloaderAPI.h index fd351104e..9d652c840 100644 --- a/Bootloaders/CDC/BootloaderAPI.h +++ b/Bootloaders/CDC/BootloaderAPI.h @@ -40,9 +40,9 @@ #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); diff --git a/Bootloaders/CDC/BootloaderCDC.c b/Bootloaders/CDC/BootloaderCDC.c index 7695e33d8..0e7920a15 100644 --- a/Bootloaders/CDC/BootloaderCDC.c +++ b/Bootloaders/CDC/BootloaderCDC.c @@ -104,10 +104,10 @@ void SetupHardware(void) /* Initialize USB Subsystem */ USB_Init(); LEDs_Init(); - + /* Bootloader active LED toggle timer initialization */ TIMSK1 = (1 << TOIE1); - TCCR1B = ((1 << CS11) | (1 << CS10)); + TCCR1B = ((1 << CS11) | (1 << CS10)); } /** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */ @@ -266,7 +266,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command) { LowByte = FetchNextCommandByte(); } - + HighByte = !HighByte; } else @@ -365,7 +365,7 @@ void CDC_Task(void) if (Command == 'E') { RunBootloader = false; - + /* Send confirmation byte back to the host */ WriteNextResponseByte('\r'); } diff --git a/Bootloaders/CDC/BootloaderCDC.h b/Bootloaders/CDC/BootloaderCDC.h index 41280fe8f..bfc8af585 100644 --- a/Bootloaders/CDC/BootloaderCDC.h +++ b/Bootloaders/CDC/BootloaderCDC.h @@ -46,7 +46,7 @@ #include <stdbool.h> #include "Descriptors.h" - #include "BootloaderAPI.h" + #include "BootloaderAPI.h" #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Board/LEDs.h> diff --git a/Bootloaders/CDC/Descriptors.h b/Bootloaders/CDC/Descriptors.h index c843bec82..842f22c2a 100644 --- a/Bootloaders/CDC/Descriptors.h +++ b/Bootloaders/CDC/Descriptors.h @@ -115,14 +115,14 @@ typedef struct { USB_Descriptor_Configuration_Header_t Config; - + // CDC Control Interface USB_Descriptor_Interface_t CDC_CCI_Interface; USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; - + // CDC Data Interface USB_Descriptor_Interface_t CDC_DCI_Interface; USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; diff --git a/Bootloaders/DFU/BootloaderAPI.h b/Bootloaders/DFU/BootloaderAPI.h index fd351104e..9d652c840 100644 --- a/Bootloaders/DFU/BootloaderAPI.h +++ b/Bootloaders/DFU/BootloaderAPI.h @@ -40,9 +40,9 @@ #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); diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 6e0c95d06..094801924 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -113,10 +113,10 @@ int main(void) /* If the TCK pin is not jumpered to ground, start the user application instead */ RunBootloader = (!(PINF & (1 << 4))); - + /* Re-enable JTAG debugging */ MCUCR &= ~(1 << JTD); - MCUCR &= ~(1 << JTD); + MCUCR &= ~(1 << JTD); #endif /* Turn on first LED on the board to indicate that the bootloader has started */ @@ -153,7 +153,7 @@ void SetupHardware(void) /* Initialize the USB subsystem */ USB_Init(); LEDs_Init(); - + /* Bootloader active LED toggle timer initialization */ TIMSK1 = (1 << TOIE1); TCCR1B = ((1 << CS11) | (1 << CS10)); @@ -181,7 +181,7 @@ ISR(TIMER1_OVF_vect, ISR_BLOCK) * internally. */ void EVENT_USB_Device_ControlRequest(void) -{ +{ /* Ignore any requests that aren't directed to the DFU interface */ if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) != (REQTYPE_CLASS | REQREC_INTERFACE)) @@ -742,3 +742,4 @@ static void ProcessReadCommand(void) else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Read signature byte ResponseByte = SignatureInfo[DataIndexToRead - 0x30]; } + diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c index b9c77aa9a..44170e6c6 100644 --- a/Bootloaders/DFU/Descriptors.c +++ b/Bootloaders/DFU/Descriptors.c @@ -159,11 +159,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, Address = &DeviceDescriptor; Size = sizeof(USB_Descriptor_Device_t); break; - case DTYPE_Configuration: + case DTYPE_Configuration: Address = &ConfigurationDescriptor; Size = sizeof(USB_Descriptor_Configuration_t); break; - case DTYPE_String: + case DTYPE_String: if (!(DescriptorNumber)) { Address = &LanguageString; @@ -174,10 +174,10 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, Address = &ProductString; Size = ProductString.Header.Size; } - + break; } - + *DescriptorAddress = Address; return Size; } diff --git a/Bootloaders/DFU/Descriptors.h b/Bootloaders/DFU/Descriptors.h index 445557f70..42b4bb63f 100644 --- a/Bootloaders/DFU/Descriptors.h +++ b/Bootloaders/DFU/Descriptors.h @@ -161,7 +161,7 @@ typedef struct { USB_Descriptor_Configuration_Header_t Config; - + // DFU Interface USB_Descriptor_Interface_t DFU_Interface; USB_Descriptor_DFU_Functional_t DFU_Functional; diff --git a/Bootloaders/HID/BootloaderHID.c b/Bootloaders/HID/BootloaderHID.c index f4cb0f1a1..500d3fecb 100644 --- a/Bootloaders/HID/BootloaderHID.c +++ b/Bootloaders/HID/BootloaderHID.c @@ -9,13 +9,13 @@ /* Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + 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 + 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 + 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 disclaim all warranties with regard to this @@ -32,7 +32,7 @@ * * Main source file for the HID class bootloader. This file contains the complete bootloader logic. */ - + #include "BootloaderHID.h" /** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run @@ -41,20 +41,20 @@ */ static bool RunBootloader = true; -/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously +/** 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. */ int main(void) { /* Setup hardware required for the bootloader */ SetupHardware(); - + /* Enable global interrupts so that the USB stack can function */ sei(); while (RunBootloader) USB_USBTask(); - + /* Disconnect from the host - USB interface will be reset later along with the AVR */ USB_Detach(); @@ -108,17 +108,17 @@ void EVENT_USB_Device_ControlRequest(void) { case HID_REQ_SetReport: Endpoint_ClearSETUP(); - + /* Wait until the command has been sent by the host */ while (!(Endpoint_IsOUTReceived())); - + /* Read in the write destination address */ #if (FLASHEND > 0xFFFF) uint32_t PageAddress = ((uint32_t)Endpoint_Read_16_LE() << 8); #else uint16_t PageAddress = Endpoint_Read_16_LE(); #endif - + /* Check if the command is a program page command, or a start application command */ #if (FLASHEND > 0xFFFF) if ((uint16_t)(PageAddress >> 8) == COMMAND_STARTAPPLICATION) @@ -133,9 +133,9 @@ void EVENT_USB_Device_ControlRequest(void) /* Erase the given FLASH page, ready to be programmed */ boot_page_erase(PageAddress); boot_spm_busy_wait(); - + /* Write each of the FLASH page's bytes in sequence */ - for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++) + for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++) { /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ if (!(Endpoint_BytesInEndpoint())) @@ -162,3 +162,4 @@ void EVENT_USB_Device_ControlRequest(void) break; } } + diff --git a/Bootloaders/HID/BootloaderHID.h b/Bootloaders/HID/BootloaderHID.h index 190dff857..e0f648f59 100644 --- a/Bootloaders/HID/BootloaderHID.h +++ b/Bootloaders/HID/BootloaderHID.h @@ -8,14 +8,14 @@ /* Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this + + 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 + 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 + 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 disclaim all warranties with regard to this @@ -32,7 +32,7 @@ * * Header file for TeensyHID.c. */ - + #ifndef _TEENSYHID_H_ #define _TEENSYHID_H_ @@ -47,15 +47,16 @@ #include "Descriptors.h" #include <LUFA/Drivers/USB/USB.h> - - /* Macros: */ + + /* Macros: */ /** Bootloader special address to start the user application */ #define COMMAND_STARTAPPLICATION 0xFFFF - + /* Function Prototypes: */ void SetupHardware(void); void EVENT_USB_Device_ConfigurationChanged(void); void EVENT_USB_Device_UnhandledControlRequest(void); - + #endif + diff --git a/Bootloaders/HID/Descriptors.c b/Bootloaders/HID/Descriptors.c index bbb821491..48ef78e79 100644 --- a/Bootloaders/HID/Descriptors.c +++ b/Bootloaders/HID/Descriptors.c @@ -8,14 +8,14 @@ /* Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this + + 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 + 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 + 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 disclaim all warranties with regard to this @@ -30,9 +30,9 @@ /** \file * - * USB Device Descriptors, for library use when in USB device mode. Descriptors are special + * 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. + * the device's capabilities and functions. */ #include "Descriptors.h" @@ -52,7 +52,7 @@ const USB_Descriptor_HIDReport_Datatype_t HIDReport[] = HID_RI_LOGICAL_MINIMUM(8, 0x00), HID_RI_LOGICAL_MAXIMUM(8, 0xFF), HID_RI_REPORT_SIZE(8, 0x08), - HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)), + HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)), HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), HID_RI_END_COLLECTION(0), }; @@ -91,49 +91,49 @@ const USB_Descriptor_Device_t DeviceDescriptor = */ const USB_Descriptor_Configuration_t ConfigurationDescriptor = { - .Config = + .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_BUSPOWERED, - + .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) }, - - .HID_Interface = + + .HID_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, .InterfaceNumber = 0x00, .AlternateSetting = 0x00, - + .TotalEndpoints = 1, - + .Class = HID_CSCP_HIDClass, .SubClass = HID_CSCP_NonBootSubclass, .Protocol = HID_CSCP_NonBootProtocol, - + .InterfaceStrIndex = NO_DESCRIPTOR }, - .HID_VendorHID = - { + .HID_VendorHID = + { .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, - + .HIDSpec = VERSION_BCD(01.11), .CountryCode = 0x00, .TotalReportDescriptors = 1, .HIDReportType = HID_DTYPE_Report, .HIDReportLength = sizeof(HIDReport) }, - - .HID_ReportINEndpoint = + + .HID_ReportINEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -158,17 +158,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 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); + Size = sizeof(USB_Descriptor_Device_t); } else if (DescriptorType == DTYPE_Configuration) { Address = &ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); + Size = sizeof(USB_Descriptor_Configuration_t); } else if (DescriptorType == HID_DTYPE_HID) { @@ -184,3 +184,4 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, *DescriptorAddress = Address; return Size; } + diff --git a/Bootloaders/HID/Descriptors.h b/Bootloaders/HID/Descriptors.h index eb231f03f..ac9d08705 100644 --- a/Bootloaders/HID/Descriptors.h +++ b/Bootloaders/HID/Descriptors.h @@ -8,14 +8,14 @@ /* Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this + + 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 + 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 + 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 disclaim all warranties with regard to this @@ -47,18 +47,18 @@ typedef struct { USB_Descriptor_Configuration_Header_t Config; - + // Generic HID Interface USB_Descriptor_Interface_t HID_Interface; USB_HID_Descriptor_HID_t HID_VendorHID; USB_Descriptor_Endpoint_t HID_ReportINEndpoint; } USB_Descriptor_Configuration_t; - + /* Macros: */ /** Endpoint number of the HID data IN endpoint. */ #define HID_IN_EPNUM 1 - /** Size in bytes of the HID reporting IN endpoint. */ + /** Size in bytes of the HID reporting IN endpoint. */ #define HID_IN_EPSIZE 64 /* Function Prototypes: */ @@ -68,3 +68,4 @@ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); #endif + diff --git a/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c b/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c index e22d39404..e1f2ea03d 100644 --- a/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c +++ b/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c @@ -710,10 +710,10 @@ int teensy_open(void) { teensy_close(); uhid_teensy_fd = open_usb_device(0x16C0, 0x0478); - + if (uhid_teensy_fd < 0) uhid_teensy_fd = open_usb_device(0x03eb, 0x2067); - + if (uhid_teensy_fd < 0) return 0; return 1; } @@ -826,7 +826,7 @@ parse_hex_line(char *line) int addr, code, num; int sum, len, cksum, i; char *ptr; - + num = 0; if (line[0] != ':') return 0; if (strlen(line) < 11) return 0; |