Functions
Usb_lpm

Functions

void USBHostLPMSend (uint32_t ui32Base, uint32_t ui32Address, uint32_t ui32Endpoint)
 
void USBHostLPMConfig (uint32_t ui32Base, uint32_t ui32ResumeTime, uint32_t ui32Config)
 
void USBHostLPMResume (uint32_t ui32Base)
 
void USBDevLPMRemoteWake (uint32_t ui32Base)
 
void USBDevLPMConfig (uint32_t ui32Base, uint32_t ui32Config)
 
void USBDevLPMEnable (uint32_t ui32Base)
 
void USBDevLPMDisable (uint32_t ui32Base)
 
uint32_t USBLPMLinkStateGet (uint32_t ui32Base)
 
uint32_t USBLPMEndpointGet (uint32_t ui32Base)
 
bool USBLPMRemoteWakeEnabled (uint32_t ui32Base)
 
uint32_t USBLPMIntStatus (uint32_t ui32Base)
 
void USBLPMIntEnable (uint32_t ui32Base, uint32_t ui32Ints)
 
void USBLPMIntDisable (uint32_t ui32Base, uint32_t ui32Ints)
 

Detailed Description

Function Documentation

§ USBHostLPMSend()

void USBHostLPMSend ( uint32_t  ui32Base,
uint32_t  ui32Address,
uint32_t  ui32Endpoint 
)

Sends an LPM request to a device at a specified address and endpoint number.

Parameters
ui32Basespecifies the USB module base address.
ui32Addressis the target device address for the LPM request.
ui32Endpointis the target endpoint for the LPM request.

This function sends an LPM request to a connected device in host mode. The ui32Address parameter specifies the device address and has a range of values from 1 to 127. The ui32Endpoint parameter specifies the endpoint on the device to which to send the LPM request and must be one of the USB_EP_* values. The function returns before the LPM request is sent, requiring the caller to poll the USBLPMIntStatus() function or wait for an interrupt to signal completion of the LPM transaction. This function must only be called after the USBHostLPMConfig() has configured the LPM transaction settings.

Example: Send an LPM request to the device at address 1 on endpoint 0.

//! //
//! // Send an LPM request to the device at address 1 on endpoint 0.
//! //
//! USBHostLPMSend(USB0_BASE, 1, USB_EP_0);
//! 
\note This function must only be called in host mode.

\return None.  

References ASSERT, HWREGB, HWREGH, USB_LPMATTR_ENDPT_M, USB_LPMATTR_ENDPT_S, USB_LPMCNTRL_TXLPM, USB_O_LPMATTR, USB_O_LPMCNTRL, USB_O_LPMFADDR, and USBEPToIndex.

§ USBHostLPMConfig()

void USBHostLPMConfig ( uint32_t  ui32Base,
uint32_t  ui32ResumeTime,
uint32_t  ui32Config 
)

Sets the global configuration for all LPM requests.

Parameters
ui32Basespecifies the USB module base address.
ui32ResumeTimespecifies the resume signaling duration in 75us increments.
ui32Configspecifies the combination of configuration options for LPM transactions.

This function sets the global configuration options for LPM transactions and must be called at least once before ever calling USBHostLPMSend(). The ui32ResumeTime specifies the length of time that the host drives resume signaling on the bus in microseconds. The valid values for ui32ResumeTime are from 50us to 1175us in 75us increments. The remaining configuration is specified by the ui32Config parameter and includes the following options:

  • USB_HOST_LPM_RMTWAKE allows the device to signal a remote wake from the LPM state.
  • USB_HOST_LPM_L1 is the LPM mode to enter and must always be included in the configuration.

Example: Set the LPM configuration to allow remote wake with a resume duration of 500us.

//! //
//! // Set the LPM configuration to allow remote wake with a resume
//! // duration of 500us.
//! //
//! USBHostLPMConfig(USB0_BASE, 500, USB_HOST_LPM_RMTWAKE | USB_HOST_LPM_L1);
//! 
\note This function must only be called in host mode.

\return None.  

References ASSERT, HWREGH, USB_LPMATTR_HIRD_S, and USB_O_LPMATTR.

§ USBHostLPMResume()

void USBHostLPMResume ( uint32_t  ui32Base)

Initiates resume signaling to wake a device from LPM suspend mode.

Parameters
ui32Basespecifies the USB module base address.

In host mode, this function initiates resume signaling to wake a device that has entered an LPM-triggered low power mode. This LPM-triggered low power mode is entered when the USBHostLPMSend() is called to put a specific device into a low power state.

Example: Initiate resume signaling.

//! //
//! // Initiate resume signaling.
//! //
//! USBHostLPMResume(USB0_BASE);
//! 
\note This function must only be called in host mode.

\return None.  

References ASSERT, HWREGB, USB_LPMCNTRL_RES, and USB_O_LPMCNTRL.

§ USBDevLPMRemoteWake()

void USBDevLPMRemoteWake ( uint32_t  ui32Base)

Initiates remote wake signaling to request the device to leave LPM suspend mode.

Parameters
ui32Basespecifies the USB module base address.

This function initiates remote wake signaling to request that the host wake a device that has entered an LPM-triggered low power mode.

Example: Initiate remote wake signaling.

//! //
//! // Initiate remote wake signaling.
//! //
//! USBDevLPMRemoteWake(USB0_BASE);
//! 
\note This function must only be called in device mode.

\return None.  

References ASSERT, HWREGB, USB_LPMCNTRL_RES, and USB_O_LPMCNTRL.

§ USBDevLPMConfig()

void USBDevLPMConfig ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Configures the USB device mode response to LPM requests.

Parameters
ui32Basespecifies the USB module base address.
ui32Configis the combination of configuration options for LPM transactions in device mode.

This function sets the global configuration options for LPM transactions in device mode and must be called before ever calling USBDevLPMEnable() to set the configuration for LPM transactions. The configuration options in device mode are specified in the ui32Config parameter and include one of the following:

  • USB_DEV_LPM_NONE disables the USB controller from responding to LPM transactions.
  • USB_DEV_LPM_EN enables the USB controller to respond to LPM and extended transactions.
  • USB_DEV_LPM_EXTONLY enables the USB controller to respond to extended transactions, but not LPM transactions.

The ui32Config option can also optionally include the USB_DEV_LPM_NAK value to cause the USB controller to NAK all transactions other than an LPM transaction once the USB controller is in LPM suspend mode. If this value is not included in the ui32Config parameter, the USB controller does not respond in suspend mode.

The USB controller does not enter LPM suspend mode until the application calls the USBDevLPMEnable() function.

Example: Enable LPM transactions and NAK while in LPM suspend mode.

//! //
//! // Enable LPM transactions and NAK while in LPM suspend mode.
//! //
//! USBDevLPMConfig(USB0_BASE, USB_DEV_LPM_NAK | USB_DEV_LPM_EN);
//! 
\note This function must only be called in device mode.

\return None.  

References ASSERT, HWREGB, and USB_O_LPMCNTRL.

§ USBDevLPMEnable()

void USBDevLPMEnable ( uint32_t  ui32Base)

Enables the USB controller to respond to LPM suspend requests.

Parameters
ui32Basespecifies the USB module base address.

This function is used to automatically respond to an LPM sleep request from the USB host controller. If there is no data pending in any transmit FIFOs, then the USB controller acknowledges the packet and enters the LPM L1 state and generates the USB_INTLPM_ACK interrupt. If the USB controller has pending transmit data in at least one FIFO, then the USB controller responds with NYET and signals the USB_INTLPM_INCOMPLETE or USB_INTLPM_NYET depending on if data is pending in receive or transmit FIFOs. A call to USBDevLPMEnable() is required after every LPM resume event to re-enable LPM mode.

Example: Enable LPM suspend mode.

//!     //
//!     // Enable LPM suspend mode.
//!     //
//!     USBDevLPMEnable(USB0_BASE);
//! 
\note This function must only be called in device mode.

\return None.  

References ASSERT, HWREGB, USB_LPMCNTRL_EN_LPMEXT, USB_LPMCNTRL_TXLPM, and USB_O_LPMCNTRL.

§ USBDevLPMDisable()

void USBDevLPMDisable ( uint32_t  ui32Base)

Disables the USB controller from responding to LPM suspend requests.

Parameters
ui32Basespecifies the USB module base address.

This function disables the USB controller from responding to LPM transactions. When the device enters LPM L1 mode, the USB controller automatically disables responding to further LPM transactions.

Note
If LPM transactions were enabled before calling this function, then an LPM request can still occur before this function returns. As a result, the application must continue to handle LPM requests until this function returns.

Example: Disable LPM suspend mode.

//!     //
//!     // Disable LPM suspend mode.
//!     //
//!     USBDevLPMDisable(USB0_BASE);
//! 
\note This function must only be called in device mode.

\return None.  

References ASSERT, HWREGB, USB_LPMCNTRL_TXLPM, and USB_O_LPMCNTRL.

§ USBLPMLinkStateGet()

uint32_t USBLPMLinkStateGet ( uint32_t  ui32Base)

Returns the current link state setting.

Parameters
ui32Basespecifies the USB module base address.

This function returns the current link state setting for the USB controller. When the controller is operating as a host, this link state is sent with an LPM request. When the controller is acting as a device, this link state was received by the last LPM transaction whether it was acknowledged or stalled because the requested LPM mode is not supported.

Example: Get the link state for the last LPM transaction.

//! uint32_t ui32LinkState;
//!
//! //
//! // Get the endpoint number that received the LPM request.
//! //
//! ui32LinkState = USBLPMLinkStateGet(USB0_BASE);
//!
//! //
//! // Check if this was a supported link state.
//! //
//! if(ui32LinkState == USB_HOST_LPM_L1)
//! {
//!     //
//!     // Handle the supported L1 link state.
//!     //
//! }
//! else
//! {
//!     //
//!     // Handle the unsupported link state.
//!     //
//! }
//! 
\return The current LPM link state.  

References ASSERT, HWREGH, USB_LPMATTR_LS_M, and USB_O_LPMATTR.

§ USBLPMEndpointGet()

uint32_t USBLPMEndpointGet ( uint32_t  ui32Base)

Returns the current LPM endpoint value.

Parameters
ui32Basespecifies the USB module base address.

This function returns the current LPM endpoint value. The meaning of the value depends on the mode of operation of the USB controller. When in device mode, the value returned is the endpoint that received the last LPM transaction. When in host mode this is the endpoint that was last sent an LPM transaction, or the endpoint that is configured to be sent when the LPM transaction is triggered. The value returned is in the USB_EP_[0-7] value and a direct endpoint index.

Example: Get the endpoint for the last LPM transaction.

//! uint32_t ui32Endpoint;
//!
//! //
//! // Get the endpoint number that received the LPM request.
//! //
//! ui32LinkState = USBLPMEndpointGet(USB0_BASE);
//!
//! 
\return The last endpoint to receive an LPM request in device mode or the
endpoint that the host sends an LPM request as one of the \b USB_EP_[0-7]
values.  

References ASSERT, HWREGH, IndexToUSBEP, USB_LPMATTR_ENDPT_M, USB_LPMATTR_ENDPT_S, and USB_O_LPMATTR.

§ USBLPMRemoteWakeEnabled()

bool USBLPMRemoteWakeEnabled ( uint32_t  ui32Base)

Returns if remote wake is currently enabled.

Parameters
ui32Basespecifies the USB module base address.

This function returns the current state of the remote wake setting for host or device mode operation. If the controller is acting as a host this returns the current setting that is sent to devices when LPM requests are sent to a device. If the controller is in device mode, this function returns the state of the last LPM request sent from the host and indicates if the host enabled remote wakeup.

Example: Issue remote wake if remote wake is enabled.

//!
//! if(USBLPMRemoteWakeEnabled(USB0_BASE))
//! {
//!     USBDevLPMRemoteWake(USB0_BASE);
//! }
//!
//! 
\return The \b true if remote wake is enabled or \b false if it is not.  

References ASSERT, HWREGH, USB_LPMATTR_RMTWAK, and USB_O_LPMATTR.

§ USBLPMIntStatus()

uint32_t USBLPMIntStatus ( uint32_t  ui32Base)

Returns the current LPM interrupt status.

Parameters
ui32Basespecifies the USB module base address.

This function returns the current LPM interrupt status for the USB controller.

The valid interrupt status bits when the USB controller is acting as a host are the following:

  • USB_INTLPM_ERROR a bus error occurred in the transmission of an LPM transaction.
  • USB_INTLPM_RESUME the USB controller has resumed from the LPM low power state.
  • USB_INTLPM_INCOMPLETE the LPM transaction failed because a timeout occurred or there were bit errors in the response for three attempts.
  • USB_INTLPM_ACK the device has acknowledged an LPM transaction.
  • USB_INTLPM_NYET the device has responded with a NYET to an LPM transaction.
  • USB_INTLPM_STALL the device has stalled an LPM transaction.

The valid interrupt status bits when the USB controller is acting as a device are the following:

  • USB_INTLPM_ERROR an LPM transaction was received that has an unsupported link state field. The transaction was stalled, but the requested link state can still be read using the USBLPMLinkStateGet() function.
  • USB_INTLPM_RESUME the USB controller has resumed from the LPM low power state.
  • USB_INTLPM_INCOMPLETE the USB controller responded to an LPM transaction with a NYET because data was still in the transmit FIFOs.
  • USB_INTLPM_ACK the USB controller acknowledged an LPM transaction and is now in the LPM suspend mode.
  • USB_INTLPM_NYET the USB controller responded to an LPM transaction with a NYET because LPM transactions are not yet enabled by a call to USBDevLPMEnable().
  • USB_INTLPM_STALL the USB controller has stalled an incoming LPM transaction.
Note
This call clears the source of all LPM status interrupts, so the caller must take care to save the value returned because a subsequent call to USBLPMIntStatus() does not return the previous value.

Example: Get the current LPM interrupt status.

//! uint32_t ui32LPMIntStatus;
//!
//! //
//! // Get the current LPM interrupt status.
//! //
//! ui32LPMIntStatus = USBLPMIntStatus(USB0_BASE);
//!
//! //
//! // Check if an LPM transaction was acknowledged.
//! //
//! if(ui32LPMIntStatus & USB_INTLPM_ACK)
//! {
//!     //
//!     // Handle entering LPM suspend mode.
//!     //
//!     ...
//! }
//! 
\return The current LPM interrupt status.  

References ASSERT, HWREGB, and USB_O_LPMRIS.

§ USBLPMIntEnable()

void USBLPMIntEnable ( uint32_t  ui32Base,
uint32_t  ui32Ints 
)

Enables LPM interrupts.

Parameters
ui32Basespecifies the USB module base address.
ui32Intsspecifies which LPM interrupts to enable.

This function enables a set of LPM interrupts so that they can trigger a USB interrupt. The ui32Ints parameter specifies which of the USB_INTLPM_* to enable.

The valid interrupt status bits when the USB controller is acting as a host are the following:

  • USB_INTLPM_ERROR a bus error occurred in the transmission of an LPM transaction.
  • USB_INTLPM_RESUME the USB controller has resumed from LPM low power state.
  • USB_INTLPM_INCOMPLETE the LPM transaction failed because a timeout occurred or there were bit errors in the response for three attempts.
  • USB_INTLPM_ACK the device has acknowledged an LPM transaction.
  • USB_INTLPM_NYET the device has responded with a NYET to an LPM transaction.
  • USB_INTLPM_STALL the device has stalled an LPM transaction.

The valid interrupt status bits when the USB controller is acting as a device are the following:

  • USB_INTLPM_ERROR an LPM transaction was received that has an unsupported link state field. The transaction was stalled, but the requested link state can still be read using the USBLPMLinkStateGet() function.
  • USB_INTLPM_RESUME the USB controller has resumed from the LPM low power state.
  • USB_INTLPM_INCOMPLETE the USB controller responded to an LPM transaction with a NYET because data was still in the transmit FIFOs.
  • USB_INTLPM_ACK the USB controller acknowledged an LPM transaction and is now in the LPM suspend mode.
  • USB_INTLPM_NYET the USB controller responded to an LPM transaction with a NYET because LPM transactions are not yet enabled by a call to USBDevLPMEnable().
  • USB_INTLPM_STALL the USB controller has stalled an incoming LPM transaction.

Example: Enable all LPM interrupt sources.

//! //
//! // Enable all LPM interrupt sources.
//! //
//! USBLPMIntEnable(USB0_BASE, USB_INTLPM_ERROR | USB_INTLPM_RESUME |
//!                            USB_INTLPM_INCOMPLETE | USB_INTLPM_ACK |
//!                            USB_INTLPM_NYET | USB_INTLPM_STALL);
//! 
\return None.  

References ASSERT, HWREGB, and USB_O_LPMIM.

§ USBLPMIntDisable()

void USBLPMIntDisable ( uint32_t  ui32Base,
uint32_t  ui32Ints 
)

Disables LPM interrupts.

Parameters
ui32Basespecifies the USB module base address.
ui32Intsspecifies which LPM interrupts to disable.

This function disables the LPM interrupts specified in the ui32Ints parameter, preventing them from triggering a USB interrupt.

The valid interrupt status bits when the USB controller is acting as a host are the following:

  • USB_INTLPM_ERROR a bus error occurred in the transmission of an LPM transaction.
  • USB_INTLPM_RESUME the USB controller has resumed from LPM low power state.
  • USB_INTLPM_INCOMPLETE the LPM transaction failed because a timeout occurred or there were bit errors in the response for three attempts.
  • USB_INTLPM_ACK the device has acknowledged an LPM transaction.
  • USB_INTLPM_NYET the device has responded with a NYET to an LPM transaction.
  • USB_INTLPM_STALL the device has stalled an LPM transaction.

The valid interrupt status bits when the USB controller is acting as a device are the following:

  • USB_INTLPM_ERROR an LPM transaction was received that has an unsupported link state field. The transaction was stalled, but the requested link state can still be read using the USBLPMLinkStateGet() function.
  • USB_INTLPM_RESUME the USB controller has resumed from the LPM low power state.
  • USB_INTLPM_INCOMPLETE the USB controller responded to an LPM transaction with a NYET because data was still in the transmit FIFOs.
  • USB_INTLPM_ACK the USB controller acknowledged an LPM transaction and is now in the LPM suspend mode.
  • USB_INTLPM_NYET the USB controller responded to an LPM transaction with a NYET because LPM transactions are not yet enabled by a call to USBDevLPMEnable().
  • USB_INTLPM_STALL the USB controller has stalled an incoming LPM transaction.

Example: Disable all LPM interrupt sources.

//! //
//! // Disable all LPM interrupt sources.
//! //
//! USBLPMIntDisable(USB0_BASE, USB_INTLPM_ERROR | USB_INTLPM_RESUME |
//!                             USB_INTLPM_INCOMPLETE | USB_INTLPM_ACK |
//!                             USB_INTLPM_NYET | USB_INTLPM_STALL);
//! 
\return None.  

References ASSERT, HWREGB, and USB_O_LPMIM.

Copyright 2018, Texas Instruments Incorporated