From 70a69f3acdca27b80cdb2069de59bbc6dba83dbd Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 26 Apr 2009 15:05:29 -0700 Subject: [PATCH] Label binaries with product and serial info --- .gitignore | 12 ++-- Makefile | 111 +++++++++++++++++++++---------- ao-make-product.5c | 72 ++++++++++++++++++++ ao.h | 10 +++ ao_product.c | 151 ++++++++++++++++++++++++++++++++++++++++++ ao_telemetry.c | 3 - ao_usb.c | 159 --------------------------------------------- ao_usb.h | 34 ++++++++++ 8 files changed, 351 insertions(+), 201 deletions(-) create mode 100644 ao-make-product.5c create mode 100644 ao_product.c diff --git a/.gitignore b/.gitignore index 671623c7..36ddf343 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,12 @@ *.lnk *.map *.mem -telemetrum -teleterra -tidongle -teledongle +telemetrum-* +teleterra-* +tidongle-* +teledongle-* ao_flight_test +ao-telemetrum-*.h +ao-teleterra-*.h +ao-teledongle-*.h +ao-tidongle-*.h diff --git a/Makefile b/Makefile index a7cca869..d169faed 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ CFLAGS=--model-small --debug --opt-code-speed LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size 0x8000 \ --xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff +SERIAL=1 + INC = \ ao.h \ cc1111.h \ @@ -80,7 +82,9 @@ TM_TASK_SRC = \ ao_flight.c \ ao_log.c \ ao_report.c \ - ao_telemetry.c \ + ao_telemetry.c + +TM_MAIN_SRC = \ ao_telemetrum.c # @@ -93,9 +97,10 @@ TM_SRC = \ $(TELE_RECEIVER_SRC) \ $(TELE_COMMON_SRC) \ $(TM_DRIVER_SRC) \ - $(TM_TASK_SRC) + $(TM_TASK_SRC) \ + $(TM_MAIN_SRC) -TI_TASK_SRC = \ +TI_MAIN_SRC = \ ao_tidongle.c # @@ -107,9 +112,9 @@ TI_SRC = \ $(TELE_RECEIVER_SRC) \ $(TELE_COMMON_SRC) \ $(TELE_FAKE_SRC) \ - $(TI_TASK_SRC) + $(TI_MAIN_SRC) -TT_TASK_SRC = \ +TT_MAIN_SRC = \ ao_teleterra.c # # All sources for TeleTerra @@ -121,14 +126,14 @@ TT_SRC = \ $(TELE_DRIVER_SRC) \ $(TELE_COMMON_SRC) \ $(TELE_FAKE_SRC) \ - $(TT_TASK_SRC) + $(TT_MAIN_SRC) # # Sources for TeleDongle # -TD_TASK_SRC = \ +TD_MAIN_SRC = \ ao_teledongle.c TD_SRC = \ @@ -137,7 +142,7 @@ TD_SRC = \ $(TELE_RECEIVER_SRC) \ $(TELE_COMMON_SRC) \ $(TELE_FAKE_SRC) \ - $(TD_TASK_SRC) + $(TD_MAIN_SRC) SRC = \ $(ALTOS_SRC) \ @@ -147,25 +152,29 @@ SRC = \ $(TELE_COMMON_SRC) \ $(TELE_FAKE_SRC) \ $(TM_DRIVER_SRC) \ - $(TM_TASK_SRC) \ - $(TI_TASK_SRC) \ - $(TT_TASK_SRC) \ - $(TD_TASK_SRC) + $(TM_TASK_SRC) -TM_REL=$(TM_SRC:.c=.rel) -TI_REL=$(TI_SRC:.c=.rel) -TT_REL=$(TT_SRC:.c=.rel) -TD_REL=$(TD_SRC:.c=.rel) +TM_REL=$(TM_SRC:.c=.rel) ao_product-telemetrum-$(SERIAL).rel +TI_REL=$(TI_SRC:.c=.rel) ao_product-tidongle-$(SERIAL).rel +TT_REL=$(TT_SRC:.c=.rel) ao_product-teleterra-$(SERIAL).rel +TD_REL=$(TD_SRC:.c=.rel) ao_product-teledongle-$(SERIAL).rel -ADB=$(SRC:.c=.adb) -ASM=$(SRC:.c=.asm) -LNK=$(SRC:.c=.lnk) -LST=$(SRC:.c=.lst) -REL=$(SRC:.c=.rel) -RST=$(SRC:.c=.rst) -SYM=$(SRC:.c=.sym) +PROD_REL=\ + ao_product-telemetrum-$(SERIAL).rel \ + ao_product-tidongle-$(SERIAL).rel \ + ao_product-teleterra-$(SERIAL).rel \ + ao_product-teledongle-$(SERIAL).rel -PROGS=telemetrum.ihx tidongle.ihx teleterra.ihx teledongle.ihx +REL=$(SRC:.c=.rel) $(PROD_REL) +ADB=$(REL:.rel=.adb) +ASM=$(REL:.rel=.asm) +LNK=$(REL:.rel=.lnk) +LST=$(REL:.rel=.lst) +RST=$(REL:.rel=.rst) +SYM=$(REL:.rel=.sym) + +PROGS= telemetrum-$(SERIAL).ihx tidongle-$(SERIAL).ihx \ + teleterra-$(SERIAL).ihx teledongle-$(SERIAL).ihx HOST_PROGS=ao_flight_test @@ -180,34 +189,66 @@ PAOM=$(PROGS:.ihx=) all: $(PROGS) $(HOST_PROGS) -telemetrum.ihx: $(TM_REL) Makefile +telemetrum-$(SERIAL).ihx: $(TM_REL) Makefile $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_REL) - sh check-stack ao.h telemetrum.mem + sh check-stack ao.h telemetrum-$(SERIAL).mem -tidongle.ihx: $(TI_REL) Makefile +tidongle-$(SERIAL).ihx: $(TI_REL) Makefile $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TI_REL) - sh check-stack ao.h tidongle.mem + sh check-stack ao.h tidongle-$(SERIAL).mem -tidongle.ihx: telemetrum.ihx +tidongle-$(SERIAL).ihx: telemetrum-$(SERIAL).ihx -teleterra.ihx: $(TT_REL) Makefile +teleterra-$(SERIAL).ihx: $(TT_REL) Makefile $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TT_REL) - sh check-stack ao.h teleterra.mem + sh check-stack ao.h teleterra-$(SERIAL).mem -teleterra.ihx: tidongle.ihx +teleterra-$(SERIAL).ihx: tidongle-$(SERIAL).ihx -teledongle.ihx: $(TD_REL) Makefile +teledongle-$(SERIAL).ihx: $(TD_REL) Makefile $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TD_REL) - sh check-stack ao.h teledongle.mem + sh check-stack ao.h teledongle-$(SERIAL).mem -teledongle.ihx: teleterra.ihx +teledongle-$(SERIAL).ihx: teleterra-$(SERIAL).ihx altitude.h: make-altitude nickle make-altitude > altitude.h +TELEMETRUM_DEFS=ao-telemetrum-$(SERIAL).h +TELETERRA_DEFS=ao-teleterra-$(SERIAL).h +TELEDONGLE_DEFS=ao-teledongle-$(SERIAL).h +TIDONGLE_DEFS=ao-tidongle-$(SERIAL).h + +ALL_DEFS=$(TELEMETRUM_DEFS) $(TELETERRA_DEFS) \ + $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS) +ao_product-telemetrum-$(SERIAL).rel: ao_product.c $(TELEMETRUM_DEFS) + $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEMETRUM_DEFS)\"' -o$@ ao_product.c + +ao_product-teleterra-$(SERIAL).rel: ao_product.c $(TELETERRA_DEFS) + $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELETERRA_DEFS)\"' -o$@ ao_product.c + +ao_product-teledongle-$(SERIAL).rel: ao_product.c $(TELEDONGLE_DEFS) + $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEDONGLE_DEFS)\"' -o$@ ao_product.c + +ao_product-tidongle-$(SERIAL).rel: ao_product.c $(TIDONGLE_DEFS) + $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TIDONGLE_DEFS)\"' -o$@ ao_product.c + +$(TELEMETRUM_DEFS): ao-make-product.5c + nickle ao-make-product.5c -m altusmetrum.org -p TeleMetrum -s $(SERIAL) > $@ + +$(TELETERRA_DEFS): ao-make-product.5c + nickle ao-make-product.5c -m altusmetrum.org -p TeleTerra -s $(SERIAL) > $@ + +$(TELEDONGLE_DEFS): ao-make-product.5c + nickle ao-make-product.5c -m altusmetrum.org -p TeleDongle -s $(SERIAL) > $@ + +$(TIDONGLE_DEFS): ao-make-product.5c + nickle ao-make-product.5c -m altusmetrum.org -p TIDongle -s $(SERIAL) > $@ + clean: rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM) rm -f $(PROGS) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM) + rm -f $(ALL_DEFS) install: diff --git a/ao-make-product.5c b/ao-make-product.5c new file mode 100644 index 00000000..4f5bcba9 --- /dev/null +++ b/ao-make-product.5c @@ -0,0 +1,72 @@ +#!/bin/sh + +autoimport ParseArgs; + +void +write_string(string a, string description) +{ + int len = String::length(a); + + printf("/* %s */\n", description); + printf("#define AO_%s_LEN 0x%02x\n", description, len * 2 + 2); + printf("#define AO_%s_STRING", description); + for (int i = 0; i < len; i++) { + int c = a[i]; + if (i > 0) + printf(","); + if (0x20 <= c && c < 128) + printf(" '%c', 0", c); + else + printf(" LE_WORD(0x%04x),", c); + } + printf("\n\n"); +} + +void +write_int(int a, string description) +{ + printf ("/* %s */\n", description); + printf ("#define AO_%s_NUMBER %d\n\n", description, a); +} + +string manufacturer = "altusmetrum.org"; +string product = "TeleMetrum"; +int serial = 1; +int user_argind = 0; + +argdesc argd = { + .args = { + { + .var = { .arg_string = &manufacturer }, + .abbr = 'm', + .name = "manufacturer", + .expr_name = "manf", + .desc = "Manufacturer name." }, + { + .var = { .arg_string = &product }, + .abbr = 'p', + .name = "product", + .expr_name = "prod", + .desc = "Product name." }, + { + .var = { .arg_int = &serial }, + .abbr = 's', + .name = "serial", + .expr_name = "number", + .desc = "Serial number." }, + }, + .prog_name = "usb descriptors", +}; + +void +main() +{ + string[dim(argv)-1] nargv = {[n] = argv[n+1]}; + parseargs(&argd, &nargv); + write_string(manufacturer, "iManufacturer"); + write_string(product, "iProduct"); + write_string(sprintf("%06d", serial), "iSerial"); + write_int(serial, "iSerial"); +} + +main(); diff --git a/ao.h b/ao.h index 13497095..88bcc93a 100644 --- a/ao.h +++ b/ao.h @@ -832,4 +832,14 @@ ao_config_get(void); void ao_config_init(void); +/* + * ao_product.c + * + * values which need to be defined for + * each instance of a product + */ + +extern const uint8_t ao_usb_descriptors []; +extern const uint16_t ao_serial_number; + #endif /* _AO_H_ */ diff --git a/ao_product.c b/ao_product.c new file mode 100644 index 00000000..b743e9f0 --- /dev/null +++ b/ao_product.c @@ -0,0 +1,151 @@ +/* + * Copyright © 2009 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" +#include "ao_usb.h" +#include PRODUCT_DEFS + +/* Defines which mark this particular AltOS product */ + +const uint16_t ao_serial_number = AO_iSerial_NUMBER; + +#define LE_WORD(x) ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8)) + +/* USB descriptors in one giant block of bytes */ +const uint8_t ao_usb_descriptors [] = +{ + /* Device descriptor */ + 0x12, + AO_USB_DESC_DEVICE, + LE_WORD(0x0110), /* bcdUSB */ + 0x02, /* bDeviceClass */ + 0x00, /* bDeviceSubClass */ + 0x00, /* bDeviceProtocol */ + AO_USB_CONTROL_SIZE, /* bMaxPacketSize */ + LE_WORD(0xFFFE), /* idVendor */ + LE_WORD(0x000A), /* idProduct */ + LE_WORD(0x0100), /* bcdDevice */ + 0x01, /* iManufacturer */ + 0x02, /* iProduct */ + 0x03, /* iSerialNumber */ + 0x01, /* bNumConfigurations */ + + /* Configuration descriptor */ + 0x09, + AO_USB_DESC_CONFIGURATION, + LE_WORD(67), /* wTotalLength */ + 0x02, /* bNumInterfaces */ + 0x01, /* bConfigurationValue */ + 0x00, /* iConfiguration */ + 0xC0, /* bmAttributes */ + 0x32, /* bMaxPower */ + + /* Control class interface */ + 0x09, + AO_USB_DESC_INTERFACE, + 0x00, /* bInterfaceNumber */ + 0x00, /* bAlternateSetting */ + 0x01, /* bNumEndPoints */ + 0x02, /* bInterfaceClass */ + 0x02, /* bInterfaceSubClass */ + 0x01, /* bInterfaceProtocol, linux requires value of 1 for the cdc_acm module */ + 0x00, /* iInterface */ + + /* Header functional descriptor */ + 0x05, + CS_INTERFACE, + 0x00, /* bDescriptor SubType Header */ + LE_WORD(0x0110), /* CDC version 1.1 */ + + /* Call management functional descriptor */ + 0x05, + CS_INTERFACE, + 0x01, /* bDescriptor SubType Call Management */ + 0x01, /* bmCapabilities = device handles call management */ + 0x01, /* bDataInterface call management interface number */ + + /* ACM functional descriptor */ + 0x04, + CS_INTERFACE, + 0x02, /* bDescriptor SubType Abstract Control Management */ + 0x02, /* bmCapabilities = D1 (Set_line_Coding, Set_Control_Line_State, Get_Line_Coding and Serial_State) */ + + /* Union functional descriptor */ + 0x05, + CS_INTERFACE, + 0x06, /* bDescriptor SubType Union Functional descriptor */ + 0x00, /* bMasterInterface */ + 0x01, /* bSlaveInterface0 */ + + /* Notification EP */ + 0x07, + AO_USB_DESC_ENDPOINT, + AO_USB_INT_EP|0x80, /* bEndpointAddress */ + 0x03, /* bmAttributes = intr */ + LE_WORD(8), /* wMaxPacketSize */ + 0x0A, /* bInterval */ + + /* Data class interface descriptor */ + 0x09, + AO_USB_DESC_INTERFACE, + 0x01, /* bInterfaceNumber */ + 0x00, /* bAlternateSetting */ + 0x02, /* bNumEndPoints */ + 0x0A, /* bInterfaceClass = data */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ + 0x00, /* iInterface */ + + /* Data EP OUT */ + 0x07, + AO_USB_DESC_ENDPOINT, + AO_USB_OUT_EP, /* bEndpointAddress */ + 0x02, /* bmAttributes = bulk */ + LE_WORD(AO_USB_OUT_SIZE),/* wMaxPacketSize */ + 0x00, /* bInterval */ + + /* Data EP in */ + 0x07, + AO_USB_DESC_ENDPOINT, + AO_USB_IN_EP|0x80, /* bEndpointAddress */ + 0x02, /* bmAttributes = bulk */ + LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */ + 0x00, /* bInterval */ + + /* String descriptors */ + 0x04, + AO_USB_DESC_STRING, + LE_WORD(0x0409), + + /* iManufacturer */ + AO_iManufacturer_LEN, + AO_USB_DESC_STRING, + AO_iManufacturer_STRING, + + /* iProduct */ + AO_iProduct_LEN, + AO_USB_DESC_STRING, + AO_iProduct_STRING, + + /* iSerial */ + AO_iSerial_LEN, + AO_USB_DESC_STRING, + AO_iSerial_STRING, + + /* Terminating zero */ + 0 +}; diff --git a/ao_telemetry.c b/ao_telemetry.c index db2cfda0..5299b487 100644 --- a/ao_telemetry.c +++ b/ao_telemetry.c @@ -17,9 +17,6 @@ #include "ao.h" -/* XXX make serial numbers real */ -__xdata uint8_t ao_serial_number = 2; - __xdata uint16_t ao_telemetry_interval = 0; __xdata uint8_t ao_rdf = 0; __xdata uint16_t ao_rdf_time; diff --git a/ao_usb.c b/ao_usb.c index 1868ec3c..d02bfac8 100644 --- a/ao_usb.c +++ b/ao_usb.c @@ -20,18 +20,6 @@ struct ao_task __xdata ao_usb_task; -#define AO_USB_CONTROL_EP 0 -#define AO_USB_INT_EP 1 -#define AO_USB_OUT_EP 4 -#define AO_USB_IN_EP 5 -#define AO_USB_CONTROL_SIZE 32 -/* - * Double buffer IN and OUT EPs, so each - * gets half of the available space - */ -#define AO_USB_IN_SIZE 256 -#define AO_USB_OUT_SIZE 128 - static __xdata uint16_t ao_usb_in_bytes; static __xdata uint16_t ao_usb_out_bytes; static __xdata uint8_t ao_usb_iif; @@ -55,10 +43,6 @@ ao_usb_isr(void) interrupt 6 ao_wakeup(&ao_usb_out_bytes); } -#define AO_USB_EP0_IDLE 0 -#define AO_USB_EP0_DATA_IN 1 -#define AO_USB_EP0_DATA_OUT 2 - struct ao_usb_setup { uint8_t dir_type_recip; uint8_t request; @@ -102,151 +86,8 @@ ao_usb_ep0_flush(void) USBCS0 = cs0; } -#define LE_WORD(x) ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8)) - -/* CDC definitions */ -#define CS_INTERFACE 0x24 -#define CS_ENDPOINT 0x25 - -#define SET_LINE_CODING 0x20 -#define GET_LINE_CODING 0x21 -#define SET_CONTROL_LINE_STATE 0x22 - -/* Data structure for GET_LINE_CODING / SET_LINE_CODING class requests */ -struct ao_usb_line_coding { - uint32_t rate; - uint8_t char_format; - uint8_t parity; - uint8_t data_bits; -} ; - __xdata static struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; -/* USB descriptors in one giant block of bytes */ -static const uint8_t ao_usb_descriptors [] = -{ - /* Device descriptor */ - 0x12, - AO_USB_DESC_DEVICE, - LE_WORD(0x0110), /* bcdUSB */ - 0x02, /* bDeviceClass */ - 0x00, /* bDeviceSubClass */ - 0x00, /* bDeviceProtocol */ - AO_USB_CONTROL_SIZE, /* bMaxPacketSize */ - LE_WORD(0xFFFE), /* idVendor */ - LE_WORD(0x000A), /* idProduct */ - LE_WORD(0x0100), /* bcdDevice */ - 0x01, /* iManufacturer */ - 0x02, /* iProduct */ - 0x03, /* iSerialNumber */ - 0x01, /* bNumConfigurations */ - - /* Configuration descriptor */ - 0x09, - AO_USB_DESC_CONFIGURATION, - LE_WORD(67), /* wTotalLength */ - 0x02, /* bNumInterfaces */ - 0x01, /* bConfigurationValue */ - 0x00, /* iConfiguration */ - 0xC0, /* bmAttributes */ - 0x32, /* bMaxPower */ - - /* Control class interface */ - 0x09, - AO_USB_DESC_INTERFACE, - 0x00, /* bInterfaceNumber */ - 0x00, /* bAlternateSetting */ - 0x01, /* bNumEndPoints */ - 0x02, /* bInterfaceClass */ - 0x02, /* bInterfaceSubClass */ - 0x01, /* bInterfaceProtocol, linux requires value of 1 for the cdc_acm module */ - 0x00, /* iInterface */ - - /* Header functional descriptor */ - 0x05, - CS_INTERFACE, - 0x00, /* bDescriptor SubType Header */ - LE_WORD(0x0110), /* CDC version 1.1 */ - - /* Call management functional descriptor */ - 0x05, - CS_INTERFACE, - 0x01, /* bDescriptor SubType Call Management */ - 0x01, /* bmCapabilities = device handles call management */ - 0x01, /* bDataInterface call management interface number */ - - /* ACM functional descriptor */ - 0x04, - CS_INTERFACE, - 0x02, /* bDescriptor SubType Abstract Control Management */ - 0x02, /* bmCapabilities = D1 (Set_line_Coding, Set_Control_Line_State, Get_Line_Coding and Serial_State) */ - - /* Union functional descriptor */ - 0x05, - CS_INTERFACE, - 0x06, /* bDescriptor SubType Union Functional descriptor */ - 0x00, /* bMasterInterface */ - 0x01, /* bSlaveInterface0 */ - - /* Notification EP */ - 0x07, - AO_USB_DESC_ENDPOINT, - AO_USB_INT_EP|0x80, /* bEndpointAddress */ - 0x03, /* bmAttributes = intr */ - LE_WORD(8), /* wMaxPacketSize */ - 0x0A, /* bInterval */ - - /* Data class interface descriptor */ - 0x09, - AO_USB_DESC_INTERFACE, - 0x01, /* bInterfaceNumber */ - 0x00, /* bAlternateSetting */ - 0x02, /* bNumEndPoints */ - 0x0A, /* bInterfaceClass = data */ - 0x00, /* bInterfaceSubClass */ - 0x00, /* bInterfaceProtocol */ - 0x00, /* iInterface */ - - /* Data EP OUT */ - 0x07, - AO_USB_DESC_ENDPOINT, - AO_USB_OUT_EP, /* bEndpointAddress */ - 0x02, /* bmAttributes = bulk */ - LE_WORD(AO_USB_OUT_SIZE),/* wMaxPacketSize */ - 0x00, /* bInterval */ - - /* Data EP in */ - 0x07, - AO_USB_DESC_ENDPOINT, - AO_USB_IN_EP|0x80, /* bEndpointAddress */ - 0x02, /* bmAttributes = bulk */ - LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */ - 0x00, /* bInterval */ - - /* String descriptors */ - 0x04, - AO_USB_DESC_STRING, - LE_WORD(0x0409), - - /* iManufacturer */ - 0x20, - AO_USB_DESC_STRING, - 'a', 0, 'l', 0, 't', 0, 'u', 0, 's', 0, 'm', 0, 'e', 0, 't', 0, 'r', 0, 'u', 0, 'm', 0, '.', 0, 'o', 0, 'r', 0, 'g', 0, - - /* iProduct */ - 0x16, - AO_USB_DESC_STRING, - 'T', 0, 'e', 0, 'l', 0, 'e', 0, 'M', 0, 'e', 0, 't', 0, 'r', 0, 'u', 0, 'm', 0, - - /* iSerial */ - 0x0e, - AO_USB_DESC_STRING, - '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, - - /* Terminating zero */ - 0 -}; - /* Walk through the list of descriptors and find a match */ static void diff --git a/ao_usb.h b/ao_usb.h index 84f92877..9356c858 100644 --- a/ao_usb.h +++ b/ao_usb.h @@ -60,4 +60,38 @@ #define AO_USB_GET_DESC_TYPE(x) (((x)>>8)&0xFF) #define AO_USB_GET_DESC_INDEX(x) ((x)&0xFF) +#define AO_USB_CONTROL_EP 0 +#define AO_USB_INT_EP 1 +#define AO_USB_OUT_EP 4 +#define AO_USB_IN_EP 5 +#define AO_USB_CONTROL_SIZE 32 +/* + * Double buffer IN and OUT EPs, so each + * gets half of the available space + */ +#define AO_USB_IN_SIZE 256 +#define AO_USB_OUT_SIZE 128 + +#define AO_USB_EP0_IDLE 0 +#define AO_USB_EP0_DATA_IN 1 +#define AO_USB_EP0_DATA_OUT 2 + +#define LE_WORD(x) ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8)) + +/* CDC definitions */ +#define CS_INTERFACE 0x24 +#define CS_ENDPOINT 0x25 + +#define SET_LINE_CODING 0x20 +#define GET_LINE_CODING 0x21 +#define SET_CONTROL_LINE_STATE 0x22 + +/* Data structure for GET_LINE_CODING / SET_LINE_CODING class requests */ +struct ao_usb_line_coding { + uint32_t rate; + uint8_t char_format; + uint8_t parity; + uint8_t data_bits; +} ; + #endif /* _AO_USB_H_ */ -- 2.30.2