/
usb_comm.c
49 lines (42 loc) · 990 Bytes
/
usb_comm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <usb/usb.h>
#include <usb/usb_device_cdc.h>
#include "system.h"
#include "usb_comm.h"
/*********************************************************************
* Function: void APP_CustomHIDInitialize(void);
* (legacy USBCBInitEP();)
*
* Overview: Initializes the Custom HID demo code
*
* PreCondition: None
*
* Input: None
*
* Output: None
*
********************************************************************/
void APP_CustomCDCInitialize()
{
CDCInitEP();
}
void usb_send(const char *format, ...)
{
//char *usb_msg;
static unsigned char usb_msg[CDC_DATA_OUT_EP_SIZE];
va_list args;
va_start(args,__format);
sprintf(usb_msg,format,args);
if (( USBGetDeviceState() < CONFIGURED_STATE ) || ( USBIsDeviceSuspended() == true ))
{
return;
}
else
{
if (mUSBUSARTIsTxTrfReady())
{
putUSBUSART(usb_msg,strlen(usb_msg));
}
CDCTxService();
}
}