#include <libopencm3/usb/cdc.h> // USB CDC library
#include <libopencm3/cm3/sync.h> // synchronisation utilities
-#include "global.h"
+#include "global.h" // global utilities
#include "usb_cdcacm.h" // USB CDC ACM header and definitions
/** USB CDC ACM device descriptor
* @note starting with index 1
*/
static const char *usb_strings[] = {
- "BarBillards v1",
+ "CuVoodoo",
"CDC-ACM",
"STM32F1",
};
* @return 0 if succeeded, error else
* @note resets device when configured with 5 bits
*/
-static enum usbd_request_return_codes cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
+static int cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
{
(void)complete;
(void)buf;
reply[8] = req->wValue & 3;
reply[9] = 0;
usbd_ep_write_packet(usbd_dev, 0x83, reply, LENGTH(reply));
- return USBD_REQ_HANDLED;
break;
case USB_CDC_REQ_SET_LINE_CODING:
// ignore if length is wrong
if (*len < sizeof(struct usb_cdc_line_coding)) {
- return USBD_REQ_NOTSUPP;
+ return 0;
}
// get the line coding
struct usb_cdc_line_coding *coding = (struct usb_cdc_line_coding *)*buf;
scb_reset_system(); // reset device
while (true); // wait for the reset to happen
}
- return USBD_REQ_HANDLED;
break;
default:
- return USBD_REQ_HANDLED;
+ return 0;
}
- return USBD_REQ_NOTSUPP;
+ return 1;
}
/** USB CDC ACM data received callback
/* enable interrupts (to not have to poll all the time) */
nvic_enable_irq(NVIC_USB_LP_CAN_RX0_IRQ); // without this USB isn't detected by the host
-
+
/* reset buffer states */
rx_i = 0;
rx_used = 0;