Removed two-step endpoint/pipe bank clear and switch sequence for smaller, faster endpoint/pipe code.

Added spacing between multiple paragraphs in Doxygen \note sections.

Removed call to the clock prescaler reset function in the Teensy bootloader to save space - the user application is accessed via a watchdog reset anyway, so the prescale reset would only affect the speed of the bootloader itself.
pull/1469/head
Dean Camera 14 years ago
parent 19ecd04f37
commit 7b79325aa0

@ -68,9 +68,6 @@ void SetupHardware(void)
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);

@ -47,7 +47,7 @@
* This bootloader enumerates to the host as a HID Class device, allowing for Teensy compatible programming
* software to load firmware onto the AVR, such as the official software at <a>http://www.pjrc.com/teensy/</a>.
*
* Out of the box this bootloader builds for the ATMEGA32U4, and will fit into 4KB of bootloader space. For other
* Out of the box this bootloader builds for the ATMEGA32U4, and will fit into 2-4KB of bootloader space. For other
* devices, the makefile will need to be updated to reflect the altered MCU model and bootloader start address. When
* calculating the bootloader start address, use (TARGET_FLASH_SIZE_BYTES - 4096).
*

@ -146,9 +146,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
uint8_t UsedKeyCodes = 0;
KeyboardReport->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT;
if (JoyStatus_LCL & JOY_UP)
KeyboardReport->KeyCode[UsedKeyCodes++] = 0x04; // A
else if (JoyStatus_LCL & JOY_DOWN)
@ -165,6 +163,9 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
KeyboardReport->KeyCode[UsedKeyCodes++] = 0x09; // F
if (UsedKeyCodes)
KeyboardReport->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT;
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
return false;
}

@ -125,13 +125,13 @@
#if !(defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
/** MUX mask define for the ADC2 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.
*
* \note Note available on all AVR models.
* \note Not available on all AVR models.
*/
#define ADC_CHANNEL2 (0x02 << MUX0)
/** MUX mask define for the ADC3 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.
*
* \note Note available on all AVR models.
* \note Not available on all AVR models.
*/
#define ADC_CHANNEL3 (0x03 << MUX0)
#endif
@ -154,44 +154,44 @@
#if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
/** MUX mask define for the ADC8 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.
*
* \note Note available on all AVR models.
* \note Not available on all AVR models.
*/
#define ADC_CHANNEL8 ((1 << 8) | (0x00 << MUX0))
/** MUX mask define for the ADC9 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.
*
* \note Note available on all AVR models.
* \note Not available on all AVR models.
*/
#define ADC_CHANNEL9 ((1 << 8) | (0x01 << MUX0))
/** MUX mask define for the ADC10 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.
*
* \note Note available on all AVR models.
* \note Not available on all AVR models.
*/
#define ADC_CHANNEL10 ((1 << 8) | (0x02 << MUX0))
/** MUX mask define for the ADC11 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.
*
* \note Note available on all AVR models.
* \note Not available on all AVR models.
*/
#define ADC_CHANNEL11 ((1 << 8) | (0x03 << MUX0))
/** MUX mask define for the ADC12 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.
*
* \note Note available on all AVR models.
* \note Not available on all AVR models.
*/
#define ADC_CHANNEL12 ((1 << 8) | (0x04 << MUX0))
/** MUX mask define for the ADC13 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.
*
* \note Note available on all AVR models.
* \note Not available on all AVR models.
*/
#define ADC_CHANNEL13 ((1 << 8) | (0x05 << MUX0))
/** MUX mask define for the internal temperature sensor channel of the ADC. See \ref ADC_StartReading and
* \ref ADC_GetChannelReading.
*
* \note Note available on all AVR models.
* \note Not available on all AVR models.
*/
#define ADC_INT_TEMP_SENS ((1 << 8) | (0x07 << MUX0))
#endif
@ -250,6 +250,7 @@
*
* \note This must only be called for ADC channels with are connected to a physical port
* pin of the AVR, denoted by its special alternative function ADCx.
* \n\n
*
* \note The channel number must be specified as an integer, and NOT a ADC_CHANNELx mask.
*

@ -219,6 +219,7 @@
* the correct endpoint is selected and ready for data.
*
* \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
*
* \return Signed 24-bit audio sample from the audio interface
*/
static inline int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_ALWAYS_INLINE;

@ -169,6 +169,7 @@
*
* \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the
* call will fail.
* \n\n
*
* \note The destination buffer should be large enough to accommodate the largest report that the attached device
* can generate.
@ -186,6 +187,7 @@
*
* \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the
* call will fail.
* \n\n
*
* \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method is unavailable.
*
@ -204,6 +206,7 @@
*
* \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the
* call will fail.
* \n\n
*
* \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, the ReportID parameter is removed
* from the parameter list of this function.
@ -256,6 +259,7 @@
*
* \note Whether this function is used or not, the \ref CALLBACK_HIDParser_FilterHIDReportItem() callback from the HID
* Report Parser this function references <b>must</b> be implemented in the user code.
* \n\n
*
* \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method is unavailable.
*

@ -102,6 +102,7 @@
* event has fired (if connected before the role change).
*
* \note This event only exists on USB AVR models which support dual role modes.
* \n\n
*
* \note This event does not exist if the USB_DEVICE_ONLY or USB_HOST_ONLY tokens have been supplied
* to the compiler (see \ref Group_USBManagement documentation).
@ -114,6 +115,7 @@
* \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_Host_ErrorCodes_t
*
* \note This event only exists on USB AVR models which supports host mode.
* \n\n
*
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
@ -126,6 +128,7 @@
* management task to reduce CPU consumption.
*
* \note This event only exists on USB AVR models which supports host mode.
* \n\n
*
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
@ -139,6 +142,7 @@
* can be used to programmatically stop the USB management task to reduce CPU consumption.
*
* \note This event only exists on USB AVR models which supports host mode.
* \n\n
*
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
@ -158,6 +162,7 @@
* code returned by the \ref USB_Host_SendControlRequest() function.
*
* \note This event only exists on USB AVR models which supports host mode.
* \n\n
*
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
@ -186,6 +191,7 @@
* needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
* passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
* and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
* \n\n
*
* \note This event may fire multiple times during device enumeration on the series 2 USB AVRs with limited USB controllers
* if NO_LIMITED_CONTROLLER_CONNECT is not defined.
@ -203,6 +209,7 @@
* needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
* passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
* and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.
* \n\n
*
* \note This event may fire multiple times during device enumeration on the series 2 USB AVRs with limited USB controllers
* if NO_LIMITED_CONTROLLER_CONNECT is not defined.
@ -226,6 +233,7 @@
*
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
* \n\n
*
* \note Requests should be handled in the same manner as described in the USB 2.0 Specification,
* or appropriate class specification. In all instances, the library has already read the
@ -256,6 +264,7 @@
*
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
* \n\n
*
* \note This event does not exist on the series 2 USB AVRs when the NO_LIMITED_CONTROLLER_CONNECT
* compile time token is not set - see \ref EVENT_USB_Device_Disconnect.
@ -272,6 +281,7 @@
*
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).
* \n\n
*
* \note This event does not exist on the series 2 USB AVRs when the NO_LIMITED_CONTROLLER_CONNECT
* compile time token is not set - see \ref EVENT_USB_Device_Connect.
@ -301,6 +311,7 @@
*
* \note This event is not normally active - it must be manually enabled and disabled via the
* \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration.
* \n\n
*
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation).

@ -36,7 +36,7 @@ void USB_INT_DisableAllInterrupts(void)
#if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
USBCON &= ~((1 << VBUSTE) | (1 << IDTE));
#elif defined(USB_SERIES_4_AVR)
USBCON &= ~(1 << VBUSTE);
USBCON &= ~(1 << VBUSTE);
#endif
#if defined(USB_CAN_BE_HOST)

@ -135,6 +135,7 @@
* implicitly via the library APIs.
*
* \note This global is only present if the user application can be a USB device.
* \n\n
*
* \note This variable should be treated as read-only in the user application, and never manually
* changed in value except in the circumstances outlined above.

@ -103,6 +103,7 @@
*
* \note This variable should be treated as read-only in the user application, and never manually
* changed in value.
* \n\n
*
* \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported,
* this global and the underlying management code can be disabled by defining the

@ -73,6 +73,7 @@
* USB interface should be initialized in low speed (1.5Mb/s) mode.
*
* \note Low Speed mode is not available on all USB AVR models.
* \n\n
*
* \note Restrictions apply on the number, size and type of endpoints which can be used
* when running in low speed mode -- refer to the USB 2.0 standard.

@ -405,15 +405,13 @@
#define Endpoint_ClearSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE
#if !defined(CONTROL_ONLY_DEVICE)
#define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \
UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Endpoint_ClearIN() MACROS{ UEINTX &= ~((1 << TXINI) | (1 << FIFOCON)); }MACROE
#else
#define Endpoint_ClearIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE
#endif
#if !defined(CONTROL_ONLY_DEVICE)
#define Endpoint_ClearOUT() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \
UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Endpoint_ClearOUT() MACROS{ UEINTX &= ~((1 << RXOUTI) | (1 << FIFOCON)); }MACROE
#else
#define Endpoint_ClearOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE
#endif
@ -747,7 +745,8 @@
* The banking mode may be either \ref ENDPOINT_BANK_SINGLE or \ref ENDPOINT_BANK_DOUBLE.
*
* \note The default control endpoint does not have to be manually configured, as it is automatically
* configured by the library internally.
* configured by the library internally.
* \n\n
*
* \note This routine will select the specified endpoint, and the endpoint will remain selected
* once the routine completes regardless of if the endpoint configuration succeeds.
@ -971,6 +970,7 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -990,6 +990,7 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -1009,8 +1010,10 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -1033,6 +1036,7 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -1052,6 +1056,7 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -1071,8 +1076,10 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -1095,6 +1102,7 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -1114,6 +1122,7 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -1136,6 +1145,7 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -1155,6 +1165,7 @@
*
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
* to clear the status stage when using this routine in a control transaction.
* \n\n
*
* \note This routine should only be used on CONTROL type endpoints.
*

@ -113,9 +113,18 @@ void USB_ShutDown(void)
USB_Detach();
USB_Controller_Disable();
USB_INT_DisableAllInterrupts();
USB_INT_ClearAllInterrupts();
#if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
UHWCON &= ~(1 << UIMOD);
#endif
if (!(USB_Options & USB_OPT_MANUAL_PLL))
USB_PLL_Off();
USB_REG_Off();
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
USB_OTGPAD_Off();
#endif
@ -145,11 +154,11 @@ void USB_ResetInterface(void)
USB_ConfigurationNumber = 0;
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
USB_RemoteWakeupEnabled = false;
USB_RemoteWakeupEnabled = false;
#endif
#if !defined(NO_DEVICE_SELF_POWER)
USB_CurrentlySelfPowered = false;
USB_CurrentlySelfPowered = false;
#endif
#endif
@ -217,9 +226,9 @@ void USB_ResetInterface(void)
USB_INT_Clear(USB_INT_EORSTI);
USB_INT_Enable(USB_INT_EORSTI);
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
USB_INT_Enable(USB_INT_VBUS);
#endif
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
USB_INT_Enable(USB_INT_VBUS);
#endif
#elif defined(USB_HOST_ONLY)
USB_Host_HostMode_On();

@ -252,16 +252,18 @@
* mode speed.
*
* \note To reduce the FLASH requirements of the library if only device or host mode is required,
* this can be statically set via defining the token USB_DEVICE_ONLY for device mode or
* USB_HOST_ONLY for host mode in the use project makefile, passing the token to the compiler
* the mode can be statically set in the project makefile by defining the token USB_DEVICE_ONLY
* (for device mode) or USB_HOST_ONLY (for host mode), passing the token to the compiler
* via the -D switch. If the mode is statically set, this parameter does not exist in the
* function prototype.
* \n\n
*
* \note To reduce the FLASH requirements of the library if only fixed settings are are required,
* the options may be set statically in the same manner as the mode (see the Mode parameter of
* this function). To statically set the USB options, pass in the USE_STATIC_OPTIONS token,
* defined to the appropriate options masks. When the options are statically set, this
* parameter does not exist in the function prototype.
* \n\n
*
* \note The mode parameter does not exist on devices where only one mode is possible, such as USB
* AVR models which only implement the USB device mode in hardware.

@ -493,14 +493,11 @@
#define Pipe_IsSETUPSent() ((UPINTX & (1 << TXSTPI)) ? true : false)
#define Pipe_ClearIN() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << RXINI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearIN() MACROS{ UPINTX &= ~((1 << RXINI) | (1 << FIFOCON)); }MACROE
#define Pipe_ClearOUT() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXOUTI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearOUT() MACROS{ UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON)); }MACROE
#define Pipe_ClearSETUP() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXSTPI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearSETUP() MACROS{ UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON)); }MACROE
#define Pipe_IsNAKReceived() ((UPINTX & (1 << NAKEDI)) ? true : false)
@ -803,7 +800,8 @@
* \ref Pipe_SetFiniteINRequests().
*
* \note The default control pipe does not have to be manually configured, as it is automatically
* configured by the library internally.
* configured by the library internally.
* \n\n
*
* \note This routine will select the specified pipe, and the pipe will remain selected once the
* routine completes regardless of if the pipe configuration succeeds.

@ -26,6 +26,7 @@
* - All Class Driver Host mode demos now correctly set the board LEDs to READY once the enumeration process has completed
* - Added LIBUSB_FILTERDRV_COMPAT compile time option to the AVRISP programmer project to make the code compatible with Windows
* builds of avrdude at the expense of AVRStudio compatibility
* - Removed two-step endpoint/pipe bank clear and switch sequence for smaller, faster endpoint/pipe code
*
* <b>Fixed:</b>
* - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin

@ -40,7 +40,7 @@
* into difficulties or need some advice. In addition, you can also email the library author to recieve personalised
* support when you need it (subject to author's schedule).
*
* <small>* Atmel Stack Mouse Device Demo 4292 bytes, LUFA Mouse Low Level Device Demo 3392 bytes, under identical build
* <small>* Atmel Stack Mouse Device Demo 4292 bytes, LUFA Mouse Low Level Device Demo 3296 bytes, under identical build
* environments</small>
*/
Loading…
Cancel
Save