Skip to content

Commit

Permalink
Merge pull request #14 from mossmann/bcddevice
Browse files Browse the repository at this point in the history
Set bcdDevice to 1.0
  • Loading branch information
mossmann authored May 16, 2024
2 parents 6948db4 + 2d8fb96 commit f01dd82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ BOARD ?= cynthion

# These should default to the latest hardware revision but can be set on the command line.
BOARD_REVISION_MAJOR ?= 1
BOARD_REVISION_MINOR ?= 3
BOARD_REVISION_MINOR ?= 4

VERSION_MAJOR = 1
VERSION_MINOR = 0

CROSS=arm-none-eabi-

Expand Down Expand Up @@ -44,7 +47,9 @@ CFLAGS += \
-D USB_MANUFACTURER_STR='"Saturn-V Project"' \
-D USB_PRODUCT_STR='$(PRODUCT_STRING)' \
-D_BOARD_REVISION_MAJOR_=$(BOARD_REVISION_MAJOR) \
-D_BOARD_REVISION_MINOR_=$(BOARD_REVISION_MINOR)
-D_BOARD_REVISION_MINOR_=$(BOARD_REVISION_MINOR) \
-D VERSION_MAJOR=$(VERSION_MAJOR) \
-D VERSION_MINOR=$(VERSION_MINOR)

# Header file search path
PRJ_PATH = deps
Expand Down
8 changes: 6 additions & 2 deletions usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ char* get_serial_number_string();

USB_ENDPOINTS(1);

#define BCD_ONES(x) (x % 10)
#define BCD_TENS(x) ((x / 10) % 10)
#define BCDDEVICE(x, y) (BCD_TENS(x)<<12 | BCD_ONES(x)<<8 | BCD_TENS(y)<<4 | BCD_ONES(y))

const USB_DeviceDescriptor device_descriptor = {
.bLength = sizeof(USB_DeviceDescriptor),
.bDescriptorType = USB_DTYPE_Device,
Expand All @@ -28,7 +32,7 @@ const USB_DeviceDescriptor device_descriptor = {
.bMaxPacketSize0 = 64,
.idVendor = 0x1d50,
.idProduct = 0x615c,
.bcdDevice = 0x0000,
.bcdDevice = BCDDEVICE(VERSION_MAJOR, VERSION_MINOR),

.iManufacturer = 0x01,
.iProduct = 0x02,
Expand Down Expand Up @@ -260,4 +264,4 @@ char *get_serial_number_string(void)

return buf;

}
}

0 comments on commit f01dd82

Please sign in to comment.