#include "type.h"
#include "usbstruct.h"
Go to the source code of this file.
Defines | |
#define | MAX_PACKET_SIZE0 64 |
#define | EP_STATUS_DATA (1<<0) |
#define | EP_STATUS_STALLED (1<<1) |
#define | EP_STATUS_SETUP (1<<2) |
#define | EP_STATUS_ERROR (1<<3) |
#define | EP_STATUS_NACKED (1<<4) |
#define | DEV_STATUS_CONNECT (1<<0) |
#define | DEV_STATUS_SUSPEND (1<<2) |
#define | DEV_STATUS_RESET (1<<4) |
#define | INACK_CI (1<<1) |
#define | INACK_CO (1<<2) |
#define | INACK_II (1<<3) |
#define | INACK_IO (1<<4) |
#define | INACK_BI (1<<5) |
#define | INACK_BO (1<<6) |
Typedefs | |
typedef void( | TFnEPIntHandler )(U8 bEP, U8 bEPStatus) |
typedef void( | TFnDevIntHandler )(U8 bDevStatus) |
typedef void( | TFnFrameHandler )(U16 wFrame) |
typedef BOOL( | TFnHandleRequest )(TSetupPacket *pSetup, int *piLen, U8 **ppbData) |
typedef BOOL( | TFnGetDescriptor )(U16 wTypeIndex, U16 wLangID, int *piLen, U8 **ppbData) |
Functions | |
void | USBHwISR (void) |
void | USBHwNakIntEnable (U8 bIntBits) |
void | USBHwConnect (BOOL fConnect) |
int | USBHwEPRead (U8 bEP, U8 *pbBuf, int iMaxLen) |
int | USBHwEPWrite (U8 bEP, U8 *pbBuf, int iLen) |
void | USBHwEPStall (U8 bEP, BOOL fStall) |
int | USBHwISOCEPRead (const U8 bEP, U8 *pbBuf, const int iMaxLen) |
void | USBHwRegisterEPIntHandler (U8 bEP, TFnEPIntHandler *pfnHandler) |
void | USBHwRegisterDevIntHandler (TFnDevIntHandler *pfnHandler) |
void | USBHwRegisterFrameHandler (TFnFrameHandler *pfnHandler) |
BOOL | USBInit (void) |
void | USBRegisterRequestHandler (int iType, TFnHandleRequest *pfnHandler, U8 *pbDataStore) |
void | USBRegisterCustomReqHandler (TFnHandleRequest *pfnHandler) |
BOOL | USBHandleStandardRequest (TSetupPacket *pSetup, int *piLen, U8 **ppbData) |
void | USBHandleControlTransfer (U8 bEP, U8 bEPStat) |
void | USBRegisterDescriptors (const U8 *pabDescriptors) |
BOOL | USBGetDescriptor (U16 wTypeIndex, U16 wLangID, int *piLen, U8 **ppbData) |
void | USBSetupDMADescriptor (volatile U32 dmaDescriptor[], volatile U32 nextDdPtr[], const U8 isIsocFlag, const U16 maxPacketSize, const U16 dmaLengthIsocNumFrames, void *dmaBufferStartAddress, U32 *isocPacketSizeMemoryAddress) |
void | USBInitializeISOCFrameArray (U32 isocFrameArr[], const U32 numElements, const U16 startFrameNumber, const U16 defaultFrameLength) |
void | USBInitializeUSBDMA (volatile U32 *udcaHeadArray[32]) |
void | USBSetHeadDDForDMA (const U8 bEp, volatile U32 *udcaHeadArray[32], volatile const U32 *dmaDescriptorPtr) |
void | USBEnableDMAForEndpoint (const U8 bEndpointNumber) |
void | USBDisableDMAForEndpoint (const U8 bEndpointNumber) |
Definition in file usbapi.h.
#define DEV_STATUS_SUSPEND (1<<2) |
#define EP_STATUS_ERROR (1<<3) |
typedef void( TFnDevIntHandler)(U8 bDevStatus) |
typedef void( TFnEPIntHandler)(U8 bEP, U8 bEPStatus) |
typedef void( TFnFrameHandler)(U16 wFrame) |
typedef BOOL( TFnGetDescriptor)(U16 wTypeIndex, U16 wLangID, int *piLen, U8 **ppbData) |
typedef BOOL( TFnHandleRequest)(TSetupPacket *pSetup, int *piLen, U8 **ppbData) |
void USBDisableDMAForEndpoint | ( | const U8 | bEndpointNumber | ) |
This function disables DMA for the endpoint indicated by the paramater.
[in] | bEndpointNumber | the endpoint number to be disabled. |
Definition at line 746 of file usbhw_lpc.c.
void USBEnableDMAForEndpoint | ( | const U8 | bEndpointNumber | ) |
Enables DMA for a particular endpoint.
[in] | bEndpontNumber | The endpoint to to enable DMA for. |
Definition at line 758 of file usbhw_lpc.c.
Parses the list of installed USB descriptors and attempts to find the specified USB descriptor.
[in] | wTypeIndex | Type and index of the descriptor |
[in] | wLangID | Language ID of the descriptor (currently unused) |
[out] | *piLen | Descriptor length |
[out] | *ppbData | Descriptor data |
Definition at line 104 of file usbstdreq.c.
Default EP0 handler
Handles IN/OUT transfers on EP0
[in] | bEP | Endpoint address |
[in] | bEPStat | Endpoint status |
Definition at line 145 of file usbcontrol.c.
BOOL USBHandleStandardRequest | ( | TSetupPacket * | pSetup, | |
int * | piLen, | |||
U8 ** | ppbData | |||
) |
Default standard request handler
Default handler for standard ('chapter 9') requests
If a custom request handler was installed, this handler is called first.
[in] | pSetup | The setup packet |
[in,out] | *piLen | Pointer to data length |
[in] | ppbData | Data buffer. |
Definition at line 400 of file usbstdreq.c.
void USBHwConnect | ( | BOOL | fConnect | ) |
Connects or disconnects from the USB bus
[in] | fConnect | If TRUE, connect, otherwise disconnect |
Definition at line 272 of file usbhw_lpc.c.
Reads data from an endpoint buffer
[in] | bEP | Endpoint number |
[in] | pbBuf | Endpoint data |
[in] | iMaxLen | Maximum number of bytes to read |
Definition at line 385 of file usbhw_lpc.c.
Sets the stalled property of an endpoint
[in] | bEP | Endpoint number |
[in] | fStall | TRUE to stall, FALSE to unstall |
Definition at line 330 of file usbhw_lpc.c.
Writes data to an endpoint buffer
[in] | bEP | Endpoint number |
[in] | pbBuf | Endpoint data |
[in] | iLen | Number of bytes to write |
Definition at line 347 of file usbhw_lpc.c.
void USBHwISR | ( | void | ) |
USB interrupt handler
Endpoint interrupts are mapped to the slow interrupt
Definition at line 510 of file usbhw_lpc.c.
void USBHwNakIntEnable | ( | U8 | bIntBits | ) |
Enables interrupt on NAK condition
For IN endpoints a NAK is generated when the host wants to read data from the device, but none is available in the endpoint buffer. For OUT endpoints a NAK is generated when the host wants to write data to the device, but the endpoint buffer is still full.
The endpoint interrupt handlers can distinguish regular (ACK) interrupts from NAK interrupt by checking the bits in their bEPStatus argument.
[in] | bIntBits | Bitmap indicating which NAK interrupts to enable |
Definition at line 304 of file usbhw_lpc.c.
void USBHwRegisterDevIntHandler | ( | TFnDevIntHandler * | pfnHandler | ) |
Registers an device status callback
[in] | pfnHandler | Callback function |
Definition at line 229 of file usbhw_lpc.c.
void USBHwRegisterEPIntHandler | ( | U8 | bEP, | |
TFnEPIntHandler * | pfnHandler | |||
) |
Registers an endpoint event callback
[in] | bEP | Endpoint number |
[in] | pfnHandler | Callback function |
Definition at line 205 of file usbhw_lpc.c.
void USBHwRegisterFrameHandler | ( | TFnFrameHandler * | pfnHandler | ) |
Registers the frame callback
[in] | pfnHandler | Callback function |
Definition at line 245 of file usbhw_lpc.c.
BOOL USBInit | ( | void | ) |
void USBInitializeISOCFrameArray | ( | U32 | isocFrameArr[], | |
const U32 | numElements, | |||
const U16 | startFrameNumber, | |||
const U16 | defaultFrameLength | |||
) |
This function is used to initialized an ISOC frame array
[in|out] | isocFrameArr The array of ISOC frame descriptors to be set, it should point to some place in DMA RAM. | |
[in] | numElements | The number of elements in the isocFrameArr array. |
[in] | startFrameNumber | Number to start at for numbering each frame. |
[in] | defaultFrameLength | The frame length to set all the frame descriptors to. |
Definition at line 773 of file usbhw_lpc.c.
void USBInitializeUSBDMA | ( | volatile U32 * | udcaHeadArray[32] | ) |
This function is used to initialize the USB DMA controller
[in|out] | udcaHeadArray This is a pointer to the array of DMA descriptor linked-list head pointers, it should point to some place in DMA RAM. |
Definition at line 803 of file usbhw_lpc.c.
void USBRegisterCustomReqHandler | ( | TFnHandleRequest * | pfnHandler | ) |
Registers a callback for custom device requests
In USBHandleStandardRequest, the custom request handler gets a first chance at handling the request before it is handed over to the 'chapter 9' request handler.
This can be used for example in HID devices, where a REQ_GET_DESCRIPTOR request is sent to an interface, which is not covered by the 'chapter 9' specification.
[in] | pfnHandler | Callback function pointer |
Definition at line 429 of file usbstdreq.c.
void USBRegisterDescriptors | ( | const U8 * | pabDescriptors | ) |
Descriptor handling
Registers a pointer to a descriptor block containing all descriptors for the device.
[in] | pabDescriptors | The descriptor byte array |
Definition at line 87 of file usbstdreq.c.
void USBRegisterRequestHandler | ( | int | iType, | |
TFnHandleRequest * | pfnHandler, | |||
U8 * | pbDataStore | |||
) |
Registers a callback for handling requests
[in] | iType | Type of request, e.g. REQTYPE_TYPE_STANDARD |
[in] | *pfnHandler | Callback function pointer |
[in] | *pbDataStore | Data storage area for this type of request |
Definition at line 224 of file usbcontrol.c.
void USBSetHeadDDForDMA | ( | const U8 | bEp, | |
volatile U32 * | udcaHeadArray[32], | |||
volatile const U32 * | dmaDescriptorPtr | |||
) |
This function is used to set the DMA descriptor head for the linked list of a particular endpoint.
[in] | bEp | The endpoint number to set the DMA linked list head for. |
[in|out] | udcaHeadArray The array of pointers that point to the head DD elements for each endpoint, it should point to some place in DMA RAM. | |
[in|out] | dmaDescriptorPtr The address of the DMA descriptor that is to be the new head, it should point to some place in DMA RAM. |
Definition at line 792 of file usbhw_lpc.c.
void USBSetupDMADescriptor | ( | volatile U32 | dmaDescriptor[], | |
volatile U32 | nextDdPtr[], | |||
const U8 | isIsocFlag, | |||
const U16 | maxPacketSize, | |||
const U16 | dmaLengthIsocNumFrames, | |||
void * | dmaBufferStartAddress, | |||
U32 * | isocPacketSizeMemoryAddress | |||
) |
DMA descriptor setup
This function is used to setup and populated the various elements of a LPC2148 DMA desccriptor such that after calling this function, the DMA descriptor could be used as part of a DMA tranfer.
[in] | dmaDescriptor | A pointer to a 4 or 5 element long array of U32's that the DMA descriptor data is to be stored into, it should point to some place in DMA RAM. |
[in] | nextDdPtr | The value to be placed in the "Next_DD_Pointer" value of the DMA desriptor, set to NULL if there is no next-pointer. |
[in] | isIsocFlag | Flag to indicate if this DMA descriptor is for an ISOC endpoint (with a 5 element dmaDescriptor array pointer), 1 indicates ISOC, 0 indicates non-ISOC. |
[in] | maxPacketSize | The maximum packet size that can be sent/received for the endpoint in question. |
[in] | dmaLengthIsocNumFrames | For non-ISOC endpoints, the number of bytes in the buffer to be transfered, for ISOC endpoints, the number of frames to be transfered. |
[in] | dmaBufferStartAddress | Start address for the dma transfer (location to store data for an OUT endpoint, location to pull data from for an IN endpoint), it should point to some place in DMA RAM. |
[in] | isocPacketSizeMemoryAddress | If a non-ISOC endpoint, set this to NULL, if an ISOC endpoint, then set this to a pointer to an array of U32's that represent how |
Definition at line 712 of file usbhw_lpc.c.