USBLibAPIGuide  1.00.00.01
Data Structures | Macros | Typedefs | Functions | Variables
Internal USB DMA functions

Data Structures

struct  tUSBDMAInstance
 

Macros

#define UDMAConfigIsRx(ui32Config)   ((ui32Config & UDMA_SRC_INC_NONE) == UDMA_SRC_INC_NONE)
 
#define UDMAConfigIsTx(ui32Config)   ((ui32Config & UDMA_DEST_INC_NONE) == UDMA_DEST_INC_NONE)
 
#define MAX_USB_TICK_HANDLERS   6
 
#define USB_SOF_TICK_DIVIDE   5
 
#define InternalUSBGetTime()   g_ui32CurrentUSBTick
 
#define USBBaseToIndex(BaseAddr)   (0)
 
#define USBIndexToBase(Index)   (USB0_BASE)
 
#define USB_MAX_DMA_CHANNELS_0   6
 
#define USB_MAX_DMA_CHANNELS   8
 
#define USBLIBSTATUS_DMA_IDLE   0x00000000
 
#define USBLIBSTATUS_DMA_COMPLETE   0x00000001
 
#define USBLIBSTATUS_DMA_ERROR   0x00000002
 
#define USBLIBSTATUS_DMA_PENDING   0x00000004
 
#define USB_DMA_EP_RX   0x00000080
 
#define USB_DMA_EP_TX   0x00000000
 
#define USB_DMA_EP_HOST   0x00000040
 
#define USB_DMA_EP_DEVICE   0x00000000
 
#define USB_DMA_EP_TYPE_CTRL   0x00000000
 
#define USB_DMA_EP_TYPE_ISOC   0x00000001
 
#define USB_DMA_EP_TYPE_BULK   0x00000002
 
#define USB_DMA_EP_TYPE_INT   0x00000003
 
#define USB_DMA_EP_TYPE_M   0x00000003
 
#define USBLibDMAChannelStatus(psUSBDMAInst, ui32Channel)   psUSBDMAInst->pfnChannelStatus(psUSBDMAInst, ui32Channel)
 
#define USBLibDMAStatus(psUSBDMAInst)   psUSBDMAInst->pfnStatus(psUSBDMAInst)
 
#define USBLibDMAIntStatus(psUSBDMAInst)   psUSBDMAInst->pfnIntStatus(psUSBDMAInst)
 
#define USBLibDMAIntStatusClear(psUSBDMAInst, ui32Status)   psUSBDMAInst->pfnIntStatusClear(psUSBDMAInst, ui32Status)
 
#define USBLibDMAChannelEnable(psUSBDMAInst, ui32Channel)   psUSBDMAInst->pfnChannelEnable(psUSBDMAInst, ui32Channel)
 
#define USBLibDMAChannelDisable(psUSBDMAInst, ui32Channel)   psUSBDMAInst->pfnChannelDisable(psUSBDMAInst, ui32Channel)
 
#define USBLibDMATransfer(psUSBDMAInst, ui32Channel, pvBuffer, ui32Size)
 
#define USBLibDMAIntHandler(psUSBDMAInst, ui32Status)   psUSBDMAInst->pfnIntHandler(psUSBDMAInst, ui32Status)
 
#define USBLibDMAChannelAllocate(psUSBDMAInst, ui8Endpoint, ui32MaxPacketSize, ui32Config)
 
#define USBLibDMAChannelRelease(psUSBDMAInst, ui8Endpoint)   psUSBDMAInst->pfnChannelRelease(psUSBDMAInst, ui8Endpoint)
 
#define USBLibDMAUnitSizeSet(psUSBDMAInst, ui32Channel, ui32BitSize)
 
#define USBLibDMAArbSizeSet(psUSBDMAInst, ui32Channel, ui32ArbSize)
 
#define USBLibDMAChannelIntEnable(psUSBDMAInst, ui32Channel)   psUSBDMAInst->pfnChannelIntEnable(psUSBDMAInst, ui32Channel)
 
#define USBLibDMAChannelIntDisable(psUSBDMAInst, ui32Channel)   psUSBDMAInst->pfnChannelIntDisable(psUSBDMAInst, ui32Channel)
 

Typedefs

typedef void(* tUSBTickHandler) (void *pvInstance, uint32_t ui32TicksmS)
 

Functions

void * USBLibDMAAddrGet (tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel)
 
uint32_t USBLibDMASizeGet (tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel)
 
tUSBDMAInstanceUSBLibDMAInit (uint32_t ui32Index)
 
void USBDeviceIntHandlerInternal (uint32_t ui32Index, uint32_t ui32Status)
 
void USBHostIntHandlerInternal (uint32_t ui32Index, uint32_t ui32Status)
 
void InternalUSBTickInit (void)
 
void InternalUSBTickReset (void)
 
int32_t InternalUSBRegisterTickHandler (tUSBTickHandler pfnHandler, void *pvInstance)
 
void InternalUSBStartOfFrameTick (uint32_t ui32TicksmS)
 
void InternalUSBHCDSendEvent (uint32_t ui32Index, tEventInfo *psEvent, uint32_t ui32EvFlag)
 

Variables

uint32_t g_ui32CurrentUSBTick
 
uint32_t g_ui32USBSOFCount
 

Detailed Description

Macro Definition Documentation

§ UDMAConfigIsRx

#define UDMAConfigIsRx (   ui32Config)    ((ui32Config & UDMA_SRC_INC_NONE) == UDMA_SRC_INC_NONE)

§ UDMAConfigIsTx

#define UDMAConfigIsTx (   ui32Config)    ((ui32Config & UDMA_DEST_INC_NONE) == UDMA_DEST_INC_NONE)

§ MAX_USB_TICK_HANDLERS

#define MAX_USB_TICK_HANDLERS   6

§ USB_SOF_TICK_DIVIDE

#define USB_SOF_TICK_DIVIDE   5

§ InternalUSBGetTime

#define InternalUSBGetTime ( )    g_ui32CurrentUSBTick

§ USBBaseToIndex

#define USBBaseToIndex (   BaseAddr)    (0)

§ USBIndexToBase

#define USBIndexToBase (   Index)    (USB0_BASE)

Referenced by USBDCompositeInit().

§ USB_MAX_DMA_CHANNELS_0

#define USB_MAX_DMA_CHANNELS_0   6

§ USB_MAX_DMA_CHANNELS

#define USB_MAX_DMA_CHANNELS   8

§ USBLIBSTATUS_DMA_IDLE

#define USBLIBSTATUS_DMA_IDLE   0x00000000

§ USBLIBSTATUS_DMA_COMPLETE

#define USBLIBSTATUS_DMA_COMPLETE   0x00000001

§ USBLIBSTATUS_DMA_ERROR

#define USBLIBSTATUS_DMA_ERROR   0x00000002

§ USBLIBSTATUS_DMA_PENDING

#define USBLIBSTATUS_DMA_PENDING   0x00000004

§ USB_DMA_EP_RX

#define USB_DMA_EP_RX   0x00000080

§ USB_DMA_EP_TX

#define USB_DMA_EP_TX   0x00000000

§ USB_DMA_EP_HOST

#define USB_DMA_EP_HOST   0x00000040

§ USB_DMA_EP_DEVICE

#define USB_DMA_EP_DEVICE   0x00000000

§ USB_DMA_EP_TYPE_CTRL

#define USB_DMA_EP_TYPE_CTRL   0x00000000

§ USB_DMA_EP_TYPE_ISOC

#define USB_DMA_EP_TYPE_ISOC   0x00000001

§ USB_DMA_EP_TYPE_BULK

#define USB_DMA_EP_TYPE_BULK   0x00000002

§ USB_DMA_EP_TYPE_INT

#define USB_DMA_EP_TYPE_INT   0x00000003

§ USB_DMA_EP_TYPE_M

#define USB_DMA_EP_TYPE_M   0x00000003

§ USBLibDMAChannelStatus

#define USBLibDMAChannelStatus (   psUSBDMAInst,
  ui32Channel 
)    psUSBDMAInst->pfnChannelStatus(psUSBDMAInst, ui32Channel)

This function returns the current DMA status for a given DMA channel.

Parameters
psUSBDMAInstis the DMA structure pointer for this instance.
ui32Channelis the DMA channel number used to retrieve the DMA status.

This function returns the current status of a DMA transfer on a given DMA channel. The DMA channel is specified by the ui32Channel parameter.

Returns
This function returns one of the USBLIBSTATUS_DMA_* values.

§ USBLibDMAStatus

#define USBLibDMAStatus (   psUSBDMAInst)    psUSBDMAInst->pfnStatus(psUSBDMAInst)

This function is used to return any global status information for USB DMA.

Parameters
psUSBDMAInstis a generic instance pointer that can be used to distinguish between different hardware instances.

This function performs returns the global status for the USB DMA interface.

Returns
Always returns 0.

§ USBLibDMAIntStatus

#define USBLibDMAIntStatus (   psUSBDMAInst)    psUSBDMAInst->pfnIntStatus(psUSBDMAInst)

This function returns the current DMA interrupt status.

Parameters
psUSBDMAInstis the DMA structure pointer for this instance.

This function returns the interrupt status for all DMA channels. The value returned is a per channel interrupt mapping with the DMA channels mapped into bits 0-31 by channel number with channel 1 starting at bit 0.

Note
This function does not return an endpoint interrupt status, but the interrupt status for the DMA interface used with the USB controller.
Returns
This function returns the pending DMA interrupts.

Referenced by USBDeviceIntHandlerInternal().

§ USBLibDMAIntStatusClear

#define USBLibDMAIntStatusClear (   psUSBDMAInst,
  ui32Status 
)    psUSBDMAInst->pfnIntStatusClear(psUSBDMAInst, ui32Status)

This function clears the requested DMA interrupt status.

Parameters
psUSBDMAInstis the DMA structure pointer for this instance.
ui32Statuscontains the interrupts to clear.

This function clears the current DMA interrupt status for the controller specified by the ui32Instance parameter. The ui32Status value has the same format as the value returned from the USBLibDMAIntStatus() function which is a per channel interrupt mapping. The DMA channels are mapped into bits 0-31 by channel number with channel 1 starting at bit 0.

Returns
None.

§ USBLibDMAChannelEnable

#define USBLibDMAChannelEnable (   psUSBDMAInst,
  ui32Channel 
)    psUSBDMAInst->pfnChannelEnable(psUSBDMAInst, ui32Channel)

This function enables DMA for a given channel.

Parameters
psUSBDMAInstis the DMA structure pointer for this instance.
ui32Channelis the DMA channel to enable.

This function enables DMA on the channel number passed in the ui32Channel parameter.

Returns
None.

§ USBLibDMAChannelDisable

#define USBLibDMAChannelDisable (   psUSBDMAInst,
  ui32Channel 
)    psUSBDMAInst->pfnChannelDisable(psUSBDMAInst, ui32Channel)

This function disables DMA for a given DMA channel.

Parameters
psUSBDMAInstis the DMA structure pointer for this instance.
ui32Channelis the DMA channel to disable.

This function disables DMA on the channel number passed in the ui32Channel parameter.

Returns
None.

§ USBLibDMATransfer

#define USBLibDMATransfer (   psUSBDMAInst,
  ui32Channel,
  pvBuffer,
  ui32Size 
)
Value:
psUSBDMAInst->pfnTransfer(psUSBDMAInst, ui32Channel, \
pvBuffer, ui32Size)

This function is configures a USB transfer on a given DMA channel.

Parameters
psUSBDMAInstis the DMA structure pointer for this instance.
ui32Channelis the DMA channel to use.
pvBufferis a pointer to the buffer to use for the transfer.
ui32Sizeis the size of the data to be transferred in bytes.

This function is called to configure a transfer using the USB controller depending on the parameters. The ui32Channel parameter holds the channel number to use for this transfer which must have already been allocated with a call to the USBLibDMAChannelAllocate() function. The transaction is configured to transfer ui32Size bytes to/from the buffer held in the pvBuffer pointer.

Returns
This function returns the number of bytes scheduled to be transferred.

§ USBLibDMAIntHandler

#define USBLibDMAIntHandler (   psUSBDMAInst,
  ui32Status 
)    psUSBDMAInst->pfnIntHandler(psUSBDMAInst, ui32Status)

This function is called by the USB interrupt handler.

Parameters
psUSBDMAInstis the DMA structure pointer for this instance.
ui32Statusis the DMA interrupt status.

This function is called by the USB interrupt handler to allow the DMA interface to handle interrupts outside of the context of the normal USB interrupt handler. The ui32Status is the current DMA interrupt status at the time of the USB interrupt. Since some DMA controller interrupts are cleared automatically when read, this value must be retrieved by calling the USBLibDMAIntStatus() function and passed into this function.

Returns
None.

Referenced by USBDeviceIntHandlerInternal().

§ USBLibDMAChannelAllocate

#define USBLibDMAChannelAllocate (   psUSBDMAInst,
  ui8Endpoint,
  ui32MaxPacketSize,
  ui32Config 
)
Value:
psUSBDMAInst->pfnChannelAllocate(psUSBDMAInst, \
ui8Endpoint, \
ui32MaxPacketSize, \
ui32Config)

This function is used to assign a DMA channel to an endpoint.

Parameters
psUSBDMAInstis the DMA instance data for a USB controller.
ui8Endpointis the endpoint number to assign a DMA channel.
ui32MaxPacketSizeis the maximum packet size for the endpoint assigned that is being assigned to the DMA channel.
ui32Configare the basic configuration options for the DMA channel.

This function assigns a DMA channel to a given endpoint. The ui8Endpoint parameter is the zero based endpoint number that is assigned a DMA channel. The ui32Config parameter contains any configuration options for the DMA channel. The current options include the following:

  • USB_DMA_EP_TX - this request is for a transmit DMA channel.
  • USB_DMA_EP_RX - this request is for a receive DMA channel.
Note
The maximum number of available DMA channels to endpoints varies between devices.
Returns
Zero or the DMA channel assigned to the endpoint.

§ USBLibDMAChannelRelease

#define USBLibDMAChannelRelease (   psUSBDMAInst,
  ui8Endpoint 
)    psUSBDMAInst->pfnChannelRelease(psUSBDMAInst, ui8Endpoint)

This function is used to free a DMA channel that was assigned to an endpoint.

Parameters
psUSBDMAInstis the DMA instance data for a USB controller.
ui8Endpointis the DMA channel number to free up.

This function frees up a DMA channel that was allocated to an endpoint by the USBLibDMAChannelAllocate() function.

Returns
None.

§ USBLibDMAUnitSizeSet

#define USBLibDMAUnitSizeSet (   psUSBDMAInst,
  ui32Channel,
  ui32BitSize 
)
Value:
psUSBDMAInst->pfnUnitSizeSet(psUSBDMAInst, ui32Channel, \
ui32BitSize);

This function is used to set the individual transfer size of a DMA channel.

Parameters
psUSBDMAInstis the DMA instance data for a USB controller.
ui32Channelis the DMA channel number to modify.
ui32BitSizeis the individual transfer size in bits(8, 16 or 32).

This function configures the individual transfer size of the DMA channel provided in the ui32Channel parameter. The ui32Channel must already be allocated to an endpoint by calling the USBLibDMAChannelAllocate() function. The ui32BitSize parameter should be on of the following values: 8, 16 or 32.

Returns
None.

§ USBLibDMAArbSizeSet

#define USBLibDMAArbSizeSet (   psUSBDMAInst,
  ui32Channel,
  ui32ArbSize 
)
Value:
psUSBDMAInst->pfnArbSizeSet(psUSBDMAInst, ui32Channel, \
ui32ArbSize);

This function is used to set the arbitration size for a DMA channel.

Parameters
psUSBDMAInstis the DMA instance data for a USB controller.
ui32Channelis the DMA channel number to modify.
ui32ArbSizeis the transfer arbitration size in bytes.

This function configures the individual transfer size of the DMA channel provided in the ui32Channel parameter. The ui32Channel must already be allocated to an endpoint by calling the USBLibDMAChannelAllocate() function.

Returns
None.

§ USBLibDMAChannelIntEnable

#define USBLibDMAChannelIntEnable (   psUSBDMAInst,
  ui32Channel 
)    psUSBDMAInst->pfnChannelIntEnable(psUSBDMAInst, ui32Channel)

This function enables the DMA interrupt for a given channel.

Parameters
psUSBDMAInstis the DMA structure pointer for this instance.
ui32Channelis the DMA channel interrupt to enable.

This function enables DMA interrupt on the channel number passed in the ui32Channel parameter.

Returns
None.

§ USBLibDMAChannelIntDisable

#define USBLibDMAChannelIntDisable (   psUSBDMAInst,
  ui32Channel 
)    psUSBDMAInst->pfnChannelIntDisable(psUSBDMAInst, ui32Channel)

This function disables DMA interrupt for a given DMA channel.

Parameters
psUSBDMAInstis the DMA structure pointer for this instance.
ui32Channelis the DMA channel interrupt to disable.

This function disables the DMA interrupt on the channel number passed in the ui32Channel parameter.

Returns
None.

Typedef Documentation

§ tUSBTickHandler

typedef void(* tUSBTickHandler) (void *pvInstance, uint32_t ui32TicksmS)

Function Documentation

§ USBLibDMAAddrGet()

void * USBLibDMAAddrGet ( tUSBDMAInstance psUSBDMAInst,
uint32_t  ui32Channel 
)

This function is used to return the current DMA pointer for a given DMA channel.

Parameters
psUSBDMAInstis a generic instance pointer that can be used to distinguish between different hardware instances.
ui32Channelis the DMA channel number for this request.

This function returns the address that is in use by the DMA channel passed in via the ui32Channel parameter. This is not the real-time pointer, but the starting address of the DMA transfer for this DMA channel.

Returns
The current DMA address for the given DMA channel.

References tUSBDMAInstance::ppui32Data.

§ USBLibDMASizeGet()

uint32_t USBLibDMASizeGet ( tUSBDMAInstance psUSBDMAInst,
uint32_t  ui32Channel 
)

This function is used to return the current DMA transfer size for a given DMA channel.

Parameters
psUSBDMAInstis a generic instance pointer that can be used to distinguish between different hardware instances.
ui32Channelis the DMA channel number for this request.

This function returns the DMA transfer size that is in use by the DMA channel passed in via the ui32Channel parameter.

Returns
The current DMA transfer size for the given DMA channel.

References tUSBDMAInstance::pui32Count.

§ USBLibDMAInit()

tUSBDMAInstance * USBLibDMAInit ( uint32_t  ui32Index)

This function is used to initialize the DMA interface for a USB instance.

Parameters
ui32Indexis the index of the USB controller for this instance.

This function performs any initialization and configuration of the DMA portions of the USB controller. This function returns a pointer that is used with the remaining USBLibDMA APIs or the function returns zero if the requested controller cannot support DMA. If this function is called when already initialized it will not reinitialize the DMA controller and will instead return the previously initialized DMA instance.

Returns
A pointer to use with USBLibDMA APIs.

References tUSBDMAInstance::pfnArbSizeSet, tUSBDMAInstance::ui32Base, and tUSBDMAInstance::ui32IntNum.

§ USBDeviceIntHandlerInternal()

void USBDeviceIntHandlerInternal ( uint32_t  ui32Index,
uint32_t  ui32Status 
)

§ USBHostIntHandlerInternal()

void USBHostIntHandlerInternal ( uint32_t  ui32Index,
uint32_t  ui32Status 
)

§ InternalUSBTickInit()

void InternalUSBTickInit ( void  )

§ InternalUSBTickReset()

void InternalUSBTickReset ( void  )

References g_bUSBTimerInitialized.

Referenced by USBDCDTerm().

§ InternalUSBRegisterTickHandler()

int32_t InternalUSBRegisterTickHandler ( tUSBTickHandler  pfnHandler,
void *  pvInstance 
)

§ InternalUSBStartOfFrameTick()

void InternalUSBStartOfFrameTick ( uint32_t  ui32TicksmS)

§ InternalUSBHCDSendEvent()

void InternalUSBHCDSendEvent ( uint32_t  ui32Index,
tEventInfo psEvent,
uint32_t  ui32EvFlag 
)

Referenced by USB0_IRQOTGModeHandler().

Variable Documentation

§ g_ui32CurrentUSBTick

uint32_t g_ui32CurrentUSBTick

§ g_ui32USBSOFCount

uint32_t g_ui32USBSOFCount
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale