User guide

36 CY3687 MoBL-USB FX2LP18 Development Kit User Guide, Doc. # 001-68582 Rev. *B
MoBL-USB FX2LP18 Firmware Frameworks
5.3 Function Hooks
The frameworks provides function hooks to simplify the addition of user code. The functions are
divided into three categories: those called by the task dispatcher, the standard device request
parser, and the USB interrupt handler. The following sections contain a complete list of functions and
their descriptions.
5.3.1 Task Dispatcher Functions
The following functions are called by the task dispatcher located in main().
5.3.1.1 TD_Init()
void TD_Init()
This function is called once during the initialization of the frameworks. It is called before ReNumera-
tion and the Task Dispatcher starts. It is intended for global state variable and device initialization.
5.3.1.2 TD_Poll()
void TD_Poll()
This function is called repeatedly during device operation. It should contain a state machine that
implements the user's peripheral function. High priority tasks can be completed before returning from
this function. However, failure to return from this function prevents frameworks from responding to
device requests and USB suspend events. If a large amount of processing time is required, it must
be split up to execute in multiple calls to TD_Poll().
5.3.1.3 TD_Suspend()
BOOL TD_Suspend()
This function is called before the frameworks enter suspend mode. This function contains code that
places the device in a low power state and returns TRUE. However, the user code can prevent the
frameworks from entering suspend mode by returning FALSE.
5.3.1.4 TD_Resume()
void TD_Resume()
This function is called after the frameworks has resumed the processor in response to an external
resume event. At this point, the device resumes full power operation.
5.3.2 Device Request Functions
These are helper functions that the device request handler (SetupCommand() in FW.C) calls. These
are mainly used to override or augment the default device request handler.
5.3.2.1 DR_GetDescriptor()
BOOL DR_GetDescriptor()
This function is called before the frameworks decode and implement the GetDescriptor device
request. The register array SETUPDAT contains the current eight byte setup command. It can be
parsed by the user's code to determine which Get Descriptor command is issued. If TRUE is
returned, the frameworks will parse and implement the command. If FALSE is returned, it will do
nothing.