ThomasChevalier / passwordWallet

USB Password Manager
MIT License
0 stars 0 forks source link

Reduce lufa code size #30

Open ThomasChevalier opened 7 years ago

ThomasChevalier commented 7 years ago

To reduce the FLASH requirements of the library if only device or host mode is required, 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. 

To reduce the FLASH requirements of the library if only fixed settings 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. 

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.See alsoDevice Management for the USB_DEVICEOPT* masks.

◆ USB_ResetInterface()

void USB_ResetInterface(void )

Resets the interface, when already initialized. This will re-enumerate the device if already connected to a host, or re-enumerate an already attached device when in host mode.

◆ USB_VBUS_GetStatus()

static bool USB_VBUS_GetStatus(void )inlinestatic

Determines if the VBUS line is currently high (i.e. the USB host is supplying power).

NoteThis function is not available on some AVR models which do not support hardware VBUS monitoring.ReturnsBoolean true if the VBUS line is currently detecting power from a host, false otherwise.

Variable Documentation

◆ USB_CurrentMode

volatile uint8_t USB_CurrentMode

Indicates the mode that the USB interface is currently initialized to, a value from the USB_Modes_t enum.

AttentionThis variable should be treated as read-only in the user application, and never manually changed in value.NoteWhen the controller is initialized into UID auto-detection mode, this variable will hold the currently selected USB mode (i.e. USB_MODE_Device or USB_MODE_Host). If the controller is fixed into a specific mode (either through the USB_DEVICE_ONLY or USB_HOST_ONLY compile time options, or a limitation of the USB controller in the chosen device model) this will evaluate to a constant of the appropriate value and will never evaluate to USB_MODE_None even when the USB interface is not initialized.

◆ USB_Options

volatile uint8_t USB_Options

Indicates the current USB options that the USB interface was initialized with when USB_Init() was called. This value will be one of the USBMODE* masks defined elsewhere in this module.

AttentionThis variable should be treated as read-only in the user application, and never manually changed in value.

Source : http://www.fourwalledcubicle.com/files/LUFA/Doc/170418/html/group___group___u_s_b_management___a_v_r8.html#gaa6fa034a919f41e17908bdcd7d5ae151

ThomasChevalier commented 7 years ago

This is already done in LufaConfig.h but check line 79 of this file