原创 EZ USB Controller Function Library

2008-8-1 16:49 3176 7 7 分类: 通信

Anchor EZ-USB Firmware Library
The EZ-USB Firmware Library is provided to accelerate USB peripheral development. The library provides constants, data structures, macros, and functions that simplify the use of common EZ-USB resources. The user simply includes the EZUSB.H and EZREGS.H header files in their source and links the EZUSB.LIB library file with the resulting binary.



The Files


The header file EZUSB.H is located in the ..\examples\inc directory. It contains constant definitions, macro definitions, data structures, global variable declarations, and function prototypes for the EZ-USB library.
The header file EZREGS.H is located in the ..\examples\inc directory. It contains bit mask definitions, and EZ-USB register variable declarations.
The library object file EZUSB.LIB is located in the ..\examples\lib directory. It contains the binary for the EZ-USB library functions. The source files for EZUSB.LIB are also located in ..\examples\lib.The object file USBJMPTB.OBJ is located in the ..\examples\lib directory. It contains the interrupt vector and the jump table for the EZ-USB USB interrupt. If this object file is linked with your project, enable autovectoring prior to enabling interrupts. The function names called by the jump table can be found in the source file USBJMPTB.A51.
Functions
void EZUSB_Discon(BOOL renum)
Description: This function performs a USB disconnect. It disconnects the device, delays for 500ms, and returns. The parameter renum determines if the EZ-USB re-numerate bit is set in the USB control register. If renum is TRUE, the re-numerate bit is set and following a return from this function the 8051 will be responsible for handling all USB device requests on endpoint 0. If renum is FALSE, the re-numerate bit is not modified. If the re-numerate bit is clear then the EZ-USB serial interface engine handles most of the USB device requests on endpoint 0.
void EZUSB_Susp(void)
Description: This function suspends the processor in response to a USB suspend event. This function will not return until the suspend has been cleared by a USB bus resume or a wake-up event on the EZ-USB wake-up pin. If a suspend event is not pending, this function will return immediately.
void EZUSB_Resume(void)
Description: This function generates the K-state on the USB bus required for a USB device remote wakeup.
This function should be called following a USB suspend. It automatically determines if
the wake-up was result of a USB resume or a remote wake-up, and generates the K-state
accordingly.
void EZUSB_Delay1ms(void)
Description: This function implements a busy loop that takes 1 millisecond to complete and then returns.
void EZUSB_Delay(WORD ms)
Description: This function performs a busy wait for a given number of milliseconds. The parameter ms determines the length of the busy wait. Upon completion of the delay the function returns.
CONFIGDSCR* EZUSB_GetConfigDscr(BYTE ConfigInst)
Description: This function returns a pointer to the nth instance of a configuration descriptor in the descriptor table. The instance is determined by the ConfigInst parameter. If the
descriptor table does not contain the given number of instances then the function returns a
NULL pointer.
INTRFCDSCR* EZUSB_GetIntrfcDscr(BYTE ConfigIdx, BYTE IntrfcIdx, BYTE
AltSetting)
Description: This function returns a pointer to a given interface descriptor found in the given
configuration/alternate setting. The parameters ConfigIdx, IntrfcIdx, and AltSetting specify the interface. If the descriptor table does not contain the given interface then the function returns a NULL pointer.
STRINGDSCR* EZUSB_GetStringDscr(BYTE StrInst)
Description: This function returns a pointer to the nth instance of a string descriptor in the descriptor table.The instance is determined by the StrInst parameter. If the descriptor table does not contain the given number of instances then the function returns a NULL pointer.
void EZUSB_InitI2C(void)
Description: This function initializes the EZ-USB i2c interface. It must be called once before calling EZUSB_WriteI2C() or EZUSB_ReadI2C().
BOOL EZUSB_WriteI2C(BYTE addr, BYTE length, BYTE xdata *dat)
Description: This function writes a string of data to the EZ-USB i2c interface. The parameter addr specifies the i2c device address. The parameters length and *dat specify the data to be
sent and its length. This function returns immediately before all of the provided data is sent
(the i2c library code is interrupt driven). If data is currently being sent or received at the time
of this function call it will return FALSE, and the data will not be sent. Else if the i2c port is
not busy then the data is queued up and the function returns TRUE.
BOOL EZUSB_ReadI2C(BYTE addr, BYTE length, BYTE xdata *dat)
Description: This function read a string of data from the EZ-USB i2c interface. The parameter addr specifies the i2c device address. The parameters length and *dat specify the buffer into
which the data will be copied and its length. This function returns immediately, before all of
the requested data is read into the buffer. The user must poll the i2c status to determine when
the data is available. If data is currently being sent or received at the time of this function call
it will return FALSE, and the data will not be read. Else if the i2c port is not busy then the
read is queued up and the function returns TRUE.
Global Variables
code DEVICEDSCR DeviceDscr
Description: This global is used by the descriptor table parsing functions. It points to the head of the device descriptor table. For a complete description of the descriptor table, see the
FrameWorks documentation.
code CONFIGDSCR ConfigDscr
Description: This global is used by the descriptor table parsing functions. It points to the first
configuration descriptor. For a complete description of the descriptor table, see the
FrameWorks documentation.
code STRINGDSCR StringDscr
Description: This global is used by the descriptor table parsing functions. It points to the first string descriptor. For a complete description of the descriptor table, see the FrameWorks
documentation.
code DSCR UserDscr
Description: This global is used by the descriptor table parsing functions. It points to the first user descriptor. For a complete description of the descriptor table, see the FrameWorks
documentation.
struct I2CPCKT I2CPckt
Description: This global is used by the i2c interface functions. It stores the current status of the i2c interface.

文章评论0条评论)

登录后参与讨论
我要评论
0
7
关闭 站长推荐上一条 /2 下一条