Skip to content

Commit

Permalink
serial number etc. now configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
zpincus committed Apr 1, 2016
1 parent 0df81fc commit 2b53104
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 37 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ LUFA_PATH = ../lufa-LUFA-140928/LUFA
# that appears when the device is attached and the reset button is pressed.
AVRDUDE_PORT = /dev/tty.usbmodem1411

# Variables that control how the USB serial device enumerates to the host.
# These are especially useful with linux udev rules.
# Note that "SERIAL_NUMBER" is not actually treated as a hex constant --
# these are all pasted into unicode strings by macros.
MANUFACTURER = zplab.wustl.edu
PRODUCT_NAME = IOTool
SERIAL_NUMBER = 0xFFFF

#############################
# IOTool Internal Variables #
#############################
Expand All @@ -22,7 +30,8 @@ F_USB = $(F_CPU)
OPTIMIZATION = 3
TARGET = IOTool
SRC = $(wildcard src/*.c) $(LUFA_SRC_USB_DEVICE) $(LUFA_PATH)/Drivers/USB/Class/Device/CDCClassDevice.c
CC_FLAGS = $(ARD_PINS) -DUSE_LUFA_CONFIG_HEADER -Isrc -Wall -Werror
USB_DEFS = -DMANUFACTURER=$(MANUFACTURER) -DPRODUCT_NAME=$(PRODUCT_NAME) -DSERIAL_NUMBER=$(SERIAL_NUMBER)
CC_FLAGS = $(ARD_PINS) $(USB_DEFS) -DUSE_LUFA_CONFIG_HEADER -Isrc -Wall -Werror
LD_FLAGS =
OBJDIR = build

Expand Down
40 changes: 8 additions & 32 deletions src/usb_serial_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* LUFA Library Copyright (C) Dean Camera, 2014.
* dean [at] fourwalledcubicle [dot] com www.lufa-lib.org
* See License.txt in the LUFA distribution for LUFA license details.
*
*
* Based in part on code copyright 2014 Alan Burlison, [email protected].
* Use is subject to license terms. See LICENSE.txt for details.
*/
Expand Down Expand Up @@ -174,39 +174,15 @@ static const USB_Descriptor_Configuration_t PROGMEM configurationDescriptor = {
};

// Language descriptor.
static const USB_Descriptor_String_t PROGMEM languageString = {
.Header = {
.Size = USB_STRING_LEN(1),
.Type = DTYPE_String
},
.UnicodeString = { LANGUAGE_ID_ENG }
};
const USB_Descriptor_String_t PROGMEM languageString = USB_STRING_DESCRIPTOR_ARRAY(LANGUAGE_ID_ENG);

// Manufacturer descriptor.
static const USB_Descriptor_String_t PROGMEM manufacturerString = {
.Header = {
.Size = USB_STRING_LEN(15),
.Type = DTYPE_String
},
.UnicodeString = L"zplab.wustl.edu"
};
// Manufacturer, product, and serial descriptor.
#define WIDEN(x) L ## #x
#define USB_STRING_DESCRIPTOR_W(x) USB_STRING_DESCRIPTOR(WIDEN(x))

// Product descriptor.
static const USB_Descriptor_String_t PROGMEM productString = {
.Header = {
.Size = USB_STRING_LEN(11),
.Type = DTYPE_String
},
.UnicodeString = L"IOTool"
};

static const USB_Descriptor_String_t PROGMEM serialString = {
.Header = {
.Size = USB_STRING_LEN(6),
.Type = DTYPE_String
},
.UnicodeString = SERIAL_NUMBER
};
const USB_Descriptor_String_t PROGMEM manufacturerString = USB_STRING_DESCRIPTOR_W(MANUFACTURER);
const USB_Descriptor_String_t PROGMEM productString = USB_STRING_DESCRIPTOR_W(PRODUCT_NAME);
const USB_Descriptor_String_t PROGMEM serialString = USB_STRING_DESCRIPTOR_W(SERIAL_NUMBER);


// LUFA CDC Class driver interface configuration and state information.
Expand Down
4 changes: 0 additions & 4 deletions src/usb_serial_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@ extern USB_ClassInfo_CDC_Device_t serialDevice;

extern uint8_t state;

// Serial Number for Device
#define SERIAL_NUMBER L"0xFFFF"


#endif /* usb_serial_base_h */

0 comments on commit 2b53104

Please sign in to comment.