Specifications

V850E2/MN4 USB CDC (Communication Device Class) Driver
R01AN0010EJ0101 Rev.1.01 Page 114 of 117
Feb 01, 2012
7.3 Function Usage
Processing that is frequently used or is of high generality is provided as functions that can simplify application coding
and lead to reduced code size. See section 4.3, Function Specifications, for details on each of these functions.
The following sections of the sample application shown in the listing can be reused as an example of the application of
these predefined processing units.
(1)
User Data FIFO State Verification
The user data FIFO state reporting function (usbf850_get_bufinit_flg()) is called on line 24 in figure 7.1 to monitor the
usbf850_bufinit_flg user data FIFO initialization flag. This flag is defined independently by the sample driver and is set
to 1 when FIFO initialization is executed either in bus reset processing, which is notified by the sample driver
INTUSFA0I1 interrupt or in the class request SetLineCoding request processing. In the sample application, the user
send/receive processing error state is cleared to 0 on this FIFO initialization.
(2)
User Data Reception Processing
In the sample driver, receive data acquisition is divided into two stages, data size acquisition and data copying, and
functions for each of these operations are defined. When reception processing is performed based on the actually
received size, the size of the received data can be verified. However, note that the maximum data size that can be
processed in one reception operation is limited to being no larger than the size of the data that can be received in a
single packet. The sample application is a usage example for the case where the buffer size is determined in advance
and in the user data reception processing function (usbf850_recv_buf()), if there is receive data, that data is read from
the used endpoint.
(3)
User Data Transmission Processing
In the user data transmission processing function (usbf850_send_buf()) on line 29 of figure 7.1, if there is data to
transmit, it checks the state of the FIFO for the used endpoint and if the FIFO is empty, it writes the data. If the FIFO is
full, it terminates with an error. Also, if there is no transmit data, if the data size for the previously transmitted packet
was equal to MaxPacketSize, it performs a null packet transmission operation. This is because in the communication
device class specifications, if the data in the last packet is equal to MaxPacketSize, a null packet must be transmitted to
notify the host that it was the last data.
7.4 Notice
Since terminal connection cannot be recovered when the USB cable is disconnected in connection by terminal emulator
and it is connected again after that, it may be unable to reconnect or the COM port of sample driver is not displayed.
<Example of measures>
- When the USB cable is disconnected, the COM port currently used for CDC connection by application program is
closed, and connection processing is terminated.
- When developing an application program, the COM port is opened only when performing communication, and when
the communication is completed or terminates with an error, it is closed.