usbserial: Allow USB ids to be specified via Kconfig

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-01-25 19:02:01 -05:00
parent 1ad1ed573a
commit 932acd3048
2 changed files with 21 additions and 7 deletions

View File

@ -47,6 +47,22 @@ config SERIAL_BAUD
Specify the baud rate of the serial port. This should be set
to 250000. Read the FAQ before changing this value.
# Generic configuration options for USB
menu "USB ids"
depends on USBSERIAL
config USB_VENDOR_ID
hex "USB vendor ID"
default 0x2341
config USB_DEVICE_ID
hex "USB device ID"
default 0xabcd
config USB_SERIAL_NUMBER
string "USB serial number"
default "12345"
endmenu
# Step timing customization
config CUSTOM_STEP_DELAY
bool "Specify a custom step pulse duration"

View File

@ -5,6 +5,7 @@
// This file may be distributed under the terms of the GNU GPLv3 license.
#include <string.h> // memmove
#include "autoconf.h" // CONFIG_USB_VENDOR_ID
#include "board/pgm.h" // PROGMEM
#include "board/usb_cdc_ep.h" // USB_CDC_EP_BULK_IN
#include "byteorder.h" // cpu_to_le16
@ -14,10 +15,6 @@
#include "sched.h" // sched_wake_task
#include "usb_cdc.h" // usb_notify_ep0
// XXX - move to Kconfig
#define CONFIG_USB_VENDOR_ID 0x2341
#define CONFIG_USB_PRODUCT_ID 0xabcd
/****************************************************************
* Message block sending
@ -124,10 +121,11 @@ DECL_TASK(usb_bulk_out_task);
* USB descriptors
****************************************************************/
// XXX - move to Kconfig
#define CONCAT1(a, b) a ## b
#define CONCAT(a, b) CONCAT1(a, b)
#define USB_STR_MANUFACTURER u"Klipper"
#define USB_STR_PRODUCT u"Klipper firmware"
#define USB_STR_SERIAL u"12345"
#define USB_STR_SERIAL CONCAT(u,CONFIG_USB_SERIAL_NUMBER)
// String descriptors
enum {
@ -177,7 +175,7 @@ static const struct usb_device_descriptor cdc_device_descriptor PROGMEM = {
.bDeviceClass = USB_CLASS_COMM,
.bMaxPacketSize0 = USB_CDC_EP0_SIZE,
.idVendor = cpu_to_le16(CONFIG_USB_VENDOR_ID),
.idProduct = cpu_to_le16(CONFIG_USB_PRODUCT_ID),
.idProduct = cpu_to_le16(CONFIG_USB_DEVICE_ID),
.bcdDevice = cpu_to_le16(0x0100),
.iManufacturer = USB_STR_ID_MANUFACTURER,
.iProduct = USB_STR_ID_PRODUCT,