![]() |
![]() |
Contains APIs related to handling of Control Endpoint.
Functions | |
uint8_t | USB_init (void) |
uint8_t | USB_setup (uint8_t connectEnable, uint8_t eventsEnable) |
uint8_t | USB_enable () |
uint8_t | USB_disable (void) |
uint8_t | USB_setEnabledEvents (uint16_t events) |
uint16_t | USB_getEnabledEvents () |
uint8_t | USB_reset () |
uint8_t | USB_connect () |
uint8_t | USB_disconnect () |
uint8_t | USB_forceRemoteWakeup () |
uint8_t | USB_getConnectionInformation () |
uint8_t | USB_getConnectionState () |
uint8_t USB_init | ( | void | ) |
Initializes the USB Module.
Initializes the USB module by configuring power and clocks, and configures pins that are critical for USB. This should be called very soon after the beginning of program execution.
Note that this does not enable the USB module (that is, does not set USB_EN bit). Rather, it prepares the USB module to detect the application of power to VBUS, after which the application may choose to enable the module and connect to USB. Calling this function is necessary to achieve expected LPM3 current consumption into DVCC.
Referenced by USB_setup().
uint8_t USB_setup | ( | uint8_t | connectEnable, |
uint8_t | eventsEnable | ||
) |
Initializes the USB Module. Also enables events and connects.
Initializes the USB module by configuring power and clocks, and configures pins that are critical for USB. This should be called very soon after the beginning of program execution.
If connectEnable is TRUE, then this API then enables the USB module, which includes activating the PLL and setting the USB_EN bit. AFter enabling the USB module, this API will connect to the host if VBUS is present.
If eventsEnable is set to TRUE then all USB events are enabled by this API.
connectEnable | If TRUE, Connect to host if VBUS is present by pulling the D+ signal high using the PUR pin. |
eventsEnable | If TRUE, all USB events handlers are enabled |
uint8_t USB_enable | ( | ) |
Enables the USB Module.
Enables the USB module, which includes activating the PLL and setting the USB_EN bit. Power consumption increases as a result of this operation (see device datasheet for specifics). This call should only be made after an earlier call to USB_init(), and prior to any other call except than USB_setEnabledEvents(), or USB_getEnabledEvents(). It is usually called just prior to attempting to connect with a host after a bus connection has already been detected.
Referenced by USB_handleVbusOnEvent(), and USB_setup().
uint8_t USB_disable | ( | void | ) |
Disables the USB Module and PLL.
Disables the USB module and PLL. If USB is not enabled when this call is made, no error is returned - the call simply exits with success.
If a handleVbusOffEvent() occurs, or if USB_getConnectionState() begins returning ST_USB_DISCONNECTED, this function should be called (following a call to USB_disconnect()), in order to avoid unnecessary current draw.
Referenced by USB_handleClockEvent().
uint8_t USB_setEnabledEvents | ( | uint16_t | events) |
Enables/Disables the Various USB Events.
events | is the mask for what is to be enabled/disabled.
|
Enables/disables various USB events. Within the events byte, all bits with '1' values will be enabled, and all bits with '0' values will be disabled. (There are no bit-wise operations). By default (that is, prior to any call to this function), all events are disabled.
The status of event enabling can be read with the USB_getEnabledEvents() function. This call can be made at any time after a call to USB_init().
USB_setEnabledEvents() can be thought of in a similar fashion to setting/clearing interrupt enable bits. The only benefit in keeping an event disabled is to save the unnecessary execution cycles incurred from running an "empty" event handler.
The mask constant USB_ALL_USB_EVENTS is used to enable/disable all events pertaining to core USB functions; in other words, it enables all those with a kUSB_ prefix.
See Sec. 10 of "Programmer's Guide: MSP430 USB API Stack for CDC/PHDC/HID/MSC" for more information about events.
Referenced by USB_setup().
uint16_t USB_getEnabledEvents | ( | ) |
Returns Which Events are Enabled/Disabled.
Returns which events are enabled and which are disabled. The definition of events is the same as for USB_enableEvents() above.
If the bit is set, the event is enabled. If cleared, the event is disabled. By default (that is, prior to calling USB_setEnabledEvents() ), all events are disabled. This call can be made at any time after a call to USB_init().
uint8_t USB_reset | ( | ) |
Resets the USB Module and the Internal State of the API.
Resets the USB module and also the internal state of the API. The interrupt register is cleared to make sure no interrupts are pending. If the device had been enumerated, the enumeration is now lost. All open send/receive operations are aborted.
This function is most often called immediately before a call to USB_connect(). It should not be called prior to USB_enable().
Referenced by USB_handleVbusOnEvent(), and USB_setup().
uint8_t USB_connect | ( | ) |
Makes USB Module Available to Host for Connection.
Instructs the USB module to make itself available to the host for connection, by pulling the D+ signal high using the PUR pin. This call should only be made after a call to USB_enable().
Referenced by USB_handleVbusOnEvent(), and USB_setup().
uint8_t USB_disconnect | ( | ) |
Forces a Disconnect From the USB Host.
Forces a logical disconnect from the USB host by pulling the PUR pin low, removing the pullup on the D+ signal. The USB module and PLL remain enabled. If the USB is not connected when this call is made, no error is returned - the call simply exits with success after ensuring PUR is low.
Referenced by USB_handleClockEvent().
uint8_t USB_forceRemoteWakeup | ( | ) |
Remote Wakeup of USB Host.
Prompts a remote wakeup of the USB host. The user must ensure that the USB descriptors had indicated remote wakeup capability (using the Descriptor Tool); otherwise the host will ignore the request.
If the function returns USB_GENERAL_ERROR, it means that the host did not grant the device the ability to perform a remote wakeup, when it enumerated the device.
uint8_t USB_getConnectionInformation | ( | ) |
Gets Connection Info.
Returns low-level status information about the USB connection.
Because multiple flags can be returned, the possible values can be masked together - for example, USB_VBUS_PRESENT + USB_SUSPENDED.
Referenced by USB_setup().
uint8_t USB_getConnectionState | ( | ) |
Gets State of the USB Connection.
Returns the state of the USB connection, according to the state diagram in Sec. 6 of "Programmer's Guide: MSP430 USB API Stack for CDC/PHDC/HID/MSC".