Instruction manual

Renesas USB MCU and USB ASSP USB Basic Host and Peripheral firmware
R01AN0512EJ0210 Rev.2.10 Page 124 of 157
Apr 1, 2013
2. The ‘Static State’
After initialization, the sample program calls usb_apl_task_switch and the device returns to the “static state”
(initialization done, but not enumeration ).
usb_apl_task_switch is a never ending loop which continuously does the following.
(1). Checks for processing requests with the scheduler.
(2). If processing requests are present, it selects the task with highest priority and sets the task processing request flag.
(3). If the task processing request flag is set, it runs each task to confirm and process any message.
Figure 5-2 shows the program flow of usb_apl_task_switch (the “static state”)
usb_apl_task_switch
R_usb_cstd_Scheduler
Yes
task processing
request flag set?
R_usb_hstd_HcdTask
R_usb_hvendor_task
usb_hvendor_apl_task
No
R_usb_hstd_MgrTask
R_usb_hhub_Task
Figure 5-2 Static State Program Flow
3. The sample application task - usb_hvendor_apl_task()
The sample application task performs open processing and data transmit/receive requests for the sample driver, as
described below.
(1). Using ANSI Interface
“Open” processing. Check if USB communication with USB peripheral is enabled. If so, obtain a file number. The
“vendor class” application task uses the file number obtained to transmit/receive demo data (using read and write).
In the demo “vendor class application”, data is transferred in both directions between host and peripheral.
The peripheral will send a byte which is incremented from 0x00 to 0xFF using EP1(Bulk) IN and EP3(Interrupt) IN. This
endpoint (EP1 IN, EP3 IN) is continuously read by the host demo application.
EP2(Bulk) OUT and EP4(Interrupt) OUT are continuously fed by the host demo with the data that was received via
EP1and EP3.
This is all continued indefinitely.
(2). Using ANSI Interface
The demo is the same, except the open processing is not used, but instead the legacy PCD/HCD API.
4. The sample driver task - usb_hvendor_task()
The sample driver task notifies the HCD of the data transmit/receive request from the vendor sample application task and
performs the data transmit/receive operation.