Specifications
V850E2/MN4 USB CDC (Communication Device Class) Driver
R01AN0010EJ0101 Rev.1.01 Page 60 of 117
Feb 01, 2012
5.3 Function Usage
In the source file main.c, which includes the sample application, use of the sample driver functions is coded as shown
below. For detailed information on these functions, see section 4.3, Function Specifications.
1 #pragma ioreg
2
3 #include "usbf850_types.h"
4 #include “main.h"
5 #include “usbf850_errno.h"
6 #include “usbf850.h"
7 #include “usbf850_communication.h"
8 #include "reg_v850e2mn4.h" ···(1)
9 :
10 omitted
11 :
12 #define USERBUF_SIZE (64) /* user buffer size */
13 static UINT8 UserBuf[USERBUF_SIZE]; /* user buffer */
14 extern UINT8 usbf850_rsuspd_flg; /* resume/suspend flag */
:
15 omitted
:
16 void main(void)
17 {
18 INT32 rcv_ret = 0;
19 INT32 snd_ret = 0;
20
21 cpu_init(); ···(2)
22
23 usbf850_init(); /* initial setting of the USB Function */ ···(3)
24
25 __EI();
26
27 while (1)
28 {
29 if (usbf850_get_bufinit_flg() != DEV_ERROR) ···(4)
30 {
31 if (snd_ret >= 0)
32 {
33 rcv_ret = usbf850_recv_buf(&UserBuf[0], USERBUF_SIZE); ···(5)
34 }
35 if (rcv_ret >= 0)
36 {
37 snd_ret = usbf850_send_buf(&UserBuf[0], rcv_ret); ···(6)
38 }
39 }
40 else
41 {
42 snd_ret = 0;
43 rcv_ret = 0; ···(7)
44 }
45
46 if (usbf850_rsuspd_flg == SUSPEND) ···(8)
47 {
48
49 __DI();
50
51 __halt();
52
53 usbf850_rsuspd_flg = RESUME;
54
55 __EI();
56 }
57 }
58 }
Figure 5.2 Sample Application Code (partial)