lisa-m/usb_cdcacm: Coding-style/whitespace fixes.
This commit is contained in:
parent
f23d9d07b7
commit
b1819507b7
@ -24,25 +24,27 @@
|
||||
#include <libopencm3/usb/cdc.h>
|
||||
|
||||
static const struct usb_device_descriptor dev = {
|
||||
.bLength = USB_DT_DEVICE_SIZE,
|
||||
.bDescriptorType = USB_DT_DEVICE,
|
||||
.bcdUSB = 0x0200,
|
||||
.bDeviceClass = USB_CLASS_CDC,
|
||||
.bDeviceSubClass = 0,
|
||||
.bDeviceProtocol = 0,
|
||||
.bMaxPacketSize0 = 64,
|
||||
.idVendor = 0x0483,
|
||||
.idProduct = 0x5740,
|
||||
.bcdDevice = 0x0200,
|
||||
.iManufacturer = 1,
|
||||
.iProduct = 2,
|
||||
.iSerialNumber = 3,
|
||||
.bNumConfigurations = 1,
|
||||
.bLength = USB_DT_DEVICE_SIZE,
|
||||
.bDescriptorType = USB_DT_DEVICE,
|
||||
.bcdUSB = 0x0200,
|
||||
.bDeviceClass = USB_CLASS_CDC,
|
||||
.bDeviceSubClass = 0,
|
||||
.bDeviceProtocol = 0,
|
||||
.bMaxPacketSize0 = 64,
|
||||
.idVendor = 0x0483,
|
||||
.idProduct = 0x5740,
|
||||
.bcdDevice = 0x0200,
|
||||
.iManufacturer = 1,
|
||||
.iProduct = 2,
|
||||
.iSerialNumber = 3,
|
||||
.bNumConfigurations = 1,
|
||||
};
|
||||
|
||||
/* This notification endpoint isn't implemented. According to CDC spec its
|
||||
* optional, but its absence causes a NULL pointer dereference in Linux cdc_acm
|
||||
* driver. */
|
||||
/*
|
||||
* This notification endpoint isn't implemented. According to CDC spec it's
|
||||
* optional, but its absence causes a NULL pointer dereference in the
|
||||
* Linux cdc_acm driver.
|
||||
*/
|
||||
static const struct usb_endpoint_descriptor comm_endp[] = {{
|
||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
@ -159,7 +161,7 @@ static const char *usb_strings[] = {
|
||||
"x",
|
||||
"Black Sphere Technologies",
|
||||
"CDC-ACM Demo",
|
||||
"DEMO"
|
||||
"DEMO",
|
||||
};
|
||||
|
||||
static int cdcacm_control_request(struct usb_setup_data *req, u8 **buf,
|
||||
@ -170,13 +172,15 @@ static int cdcacm_control_request(struct usb_setup_data *req, u8 **buf,
|
||||
|
||||
switch(req->bRequest) {
|
||||
case USB_CDC_REQ_SET_CONTROL_LINE_STATE: {
|
||||
/* This Linux cdc_acm driver requires this to be implemented
|
||||
/*
|
||||
* This Linux cdc_acm driver requires this to be implemented
|
||||
* even though it's optional in the CDC spec, and we don't
|
||||
* advertise it in the ACM functional descriptor. */
|
||||
* advertise it in the ACM functional descriptor.
|
||||
*/
|
||||
char buf[10];
|
||||
struct usb_cdc_notification *notif = (void*)buf;
|
||||
|
||||
/* We echo signals back to host as notification */
|
||||
/* We echo signals back to host as notification. */
|
||||
notif->bmRequestType = 0xA1;
|
||||
notif->bNotification = USB_CDC_NOTIFY_SERIAL_STATE;
|
||||
notif->wValue = 0;
|
||||
@ -184,11 +188,11 @@ static int cdcacm_control_request(struct usb_setup_data *req, u8 **buf,
|
||||
notif->wLength = 2;
|
||||
buf[8] = req->wValue & 3;
|
||||
buf[9] = 0;
|
||||
//usbd_ep_write_packet(0x83, buf, 10);
|
||||
// usbd_ep_write_packet(0x83, buf, 10);
|
||||
return 1;
|
||||
}
|
||||
case USB_CDC_REQ_SET_LINE_CODING:
|
||||
if(*len < sizeof(struct usb_cdc_line_coding))
|
||||
if (*len < sizeof(struct usb_cdc_line_coding))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -202,8 +206,10 @@ static void cdcacm_data_rx_cb(u8 ep)
|
||||
|
||||
char buf[64];
|
||||
int len = usbd_ep_read_packet(0x01, buf, 64);
|
||||
if(len) {
|
||||
while(usbd_ep_write_packet(0x82, buf, len) == 0);
|
||||
|
||||
if (len) {
|
||||
while (usbd_ep_write_packet(0x82, buf, len) == 0)
|
||||
;
|
||||
buf[len] = 0;
|
||||
}
|
||||
|
||||
@ -228,7 +234,7 @@ int main(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
rcc_clock_setup_in_hsi_out_48mhz();
|
||||
rcc_clock_setup_in_hsi_out_48mhz();
|
||||
|
||||
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user