summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2016-11-23 21:16:22 +0000
committerTomasz Kramkowski <tk@the-tk.com>2016-11-23 21:27:11 +0000
commit5e7e81535fea702b9194795525453ac0b801ce94 (patch)
treeeab8d1d536f4c77cde2e5ea48d2bbcf49f259d38
parent426cb9bd4b5e9e73c074830f48f77977ebb53c98 (diff)
downloadfmk-5e7e81535fea702b9194795525453ac0b801ce94.tar.gz
fmk-5e7e81535fea702b9194795525453ac0b801ce94.tar.xz
fmk-5e7e81535fea702b9194795525453ac0b801ce94.zip
Got rid of silly xxd mess
-rw-r--r--.gitignore3
-rw-r--r--Makefile8
-rw-r--r--usb/descriptors.h86
-rw-r--r--usb/ds_conf.xxd34
-rw-r--r--usb/ds_dev.xxd18
-rw-r--r--usb/ds_lang.xxd4
-rw-r--r--usb/ds_str1.xxd22
-rw-r--r--usb/endpt0.c14
8 files changed, 93 insertions, 96 deletions
diff --git a/.gitignore b/.gitignore
index 98b3802..950512c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,9 +2,6 @@
*.bin
fmk
-*.xxo
-*.xxh
-
*.d
tags
diff --git a/Makefile b/Makefile
index 64ab87d..b4393dd 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,6 @@ TARGET_ARCH = -mcpu=$(CPU) -mthumb
AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
-XXD = xxd
HKTOOL = hktool $(MCU)
@@ -21,10 +20,6 @@ OBJ := crt0.o vectors.o flashconf.o setup.o fmk.o lib/string.o lib/le.o usb/usb.
%.bin: %
$(OBJCOPY) -O binary $< $@
-%.xxo: %.xxd
- awk '{print $$1}' $< | $(XXD) -r -p -c1 >$@
-%.xxh: %.xxo
- $(XXD) -i $< | sed -e 's/_xxo//' >$@
all: fmk.bin
fmk: $(OBJ)
@@ -34,9 +29,8 @@ flash: fmk.bin
hktool -r
clean:
- $(RM) $(OBJ) $(OBJ:.o=.d) $(wildcard usb/*.xxh) fmk fmk.bin
+ $(RM) $(OBJ) $(OBJ:.o=.d) fmk fmk.bin
-include $(OBJ:.o=.d)
-usb/endpt0.o: usb/ds_dev.xxh usb/ds_conf.xxh usb/ds_lang.xxh usb/ds_str1.xxh
.PHONY: all flash clean
diff --git a/usb/descriptors.h b/usb/descriptors.h
new file mode 100644
index 0000000..8ff539e
--- /dev/null
+++ b/usb/descriptors.h
@@ -0,0 +1,86 @@
+#ifndef USB_DESCRIPTORS_H
+#define USB_DESCRIPTORS_H
+
+/* Device descriptor */
+unsigned char ds_dev[] = {
+ 18, // Length
+ 1, // Descriptor type
+ 0x00, 0x02, // USB Release
+ 0xff, // Device class
+ 0x00, // Device sub class
+ 0x00, // Device protocol
+ 64, // Max packet size
+ 0xc0, 0x16, // VID
+ 0xdc, 0x05, // PID
+ 0x01, 0x00, // Device relase
+ 1, // Manufacturer string
+ 0, // Product string
+ 0, // Serial number string
+ 1, // Number of configurations
+};
+
+/* Configuration descriptor */
+unsigned char ds_conf[] = {
+ /* Configuration */
+ 9, // Length
+ 2, // Descriptor type
+ 0x22, 0x00, // Total length
+ 1, // Number of interfaces
+ 1, // Configuration value
+ 0, // Configuration string
+ 0xc0, // Attributes (1SR00000, S - Self powered, R - Remote wakeup)
+ 50, // Maximum current (multiples of 2mA)
+
+ /* Interface */
+ 9, // Length
+ 4, // Descriptor type
+ 0, // Interface number
+ 0, // Alternate setting
+ 1, // Number of endpoints
+ 3, // Interface class
+ 1, // Interface sub class
+ 2, // Interface protocol
+ 0, // Interface string
+
+ /* HID */
+ 9, // Length
+ 33, // Descriptor type
+ 0x11, 0x01, // HID Class spec version
+ 0, // Country code
+ 1, // Number of descriptors
+ 34, // Descriptor type
+ 0x34, 0x00, // Descriptor length
+
+ /* Endpoint */
+ 7, // Length
+ 5, // Descriptor type
+ 0x81, // Endpoint address (D000NNNN, D - Direction (0 OUT, 1 IN), N - Endpoint No.)
+ 0x03, // Attributes (00UUSSTT, U - Usage type, S - Synch type, T - Transfer type)
+ 0x08, 0x00, // Max packet size
+ 64, // Interval (1ms Frames)
+};
+
+/* Language descriptor */
+unsigned char ds_lang[] = {
+ 4, // Length
+ 3, // Descriptor type
+ 0x09, 0x04 // Language ID
+};
+
+/* String descriptor 1 */
+unsigned char ds_str1[] = {
+ 22, // Length
+ 3, // Descriptor type
+ 0x74, 0x00, // t
+ 0x68, 0x00, // h
+ 0x65, 0x00, // e
+ 0x2d, 0x00, // -
+ 0x74, 0x00, // t
+ 0x6b, 0x00, // k
+ 0x2e, 0x00, // .
+ 0x63, 0x00, // c
+ 0x6f, 0x00, // o
+ 0x6d, 0x00, // m
+};
+
+#endif /* USB_DESCRIPTORS_H */
diff --git a/usb/ds_conf.xxd b/usb/ds_conf.xxd
deleted file mode 100644
index 89c6e16..0000000
--- a/usb/ds_conf.xxd
+++ /dev/null
@@ -1,34 +0,0 @@
-09 1 Length - 9
-02 1 Descriptor Type - 2 (Configuration)
-22 2 Total Length - 32
-00
-01 1 Number of Interfaces - 1
-01 1 Configuration Value - 1
-00 1 Configuration String - 0
-c0 1 Attributes - none
-32 1 Maximum Current - 100mA
-09 1 Length - 9
-04 1 Descriptor Type - 4 (Interface)
-00 1 Interface Number - 0
-00 1 Alternate Setting - 0
-01 1 Number of Endpoints - 1
-03 1 Interface Class - 3 (HID)
-01 1 Interface Sub Class - 1 (Boot)
-02 1 Interface Protocol - 1 (Keyboard)
-00 1 Interface String - 0
-09 1 Length (HID Descriptor) - 9
-21 1 Descriptor Type - 33 (HID)
-11 2 HID Class Spec Version - 1.1
-01
-00 1 Country Code - N/A
-01 1 Number of Descriptors - 1
-22 1 Descriptor Type - 34 (REPORT)
-34 2 Descriptor Length - 52
-00
-07 1 Length - 7
-05 1 Descriptor Type - 5 (Endpoint)
-81 1 Endpoint Address - 1 IN
-03 1 Attributes - Interrupt; Data Endpoint
-08 2 Maximum packet size - 8
-00
-40 1 Interval - 60 Frames
diff --git a/usb/ds_dev.xxd b/usb/ds_dev.xxd
deleted file mode 100644
index 306da63..0000000
--- a/usb/ds_dev.xxd
+++ /dev/null
@@ -1,18 +0,0 @@
-12 1 Length - 18
-01 1 Descriptor type - 1
-00 2 USB Release - 2.0
-02
-ff 1 Device Class - Interface Specific
-00 1 Device Sub Class - Interface Specific
-00 1 Device Protocol - Interface Specific
-40 1 Max Packet Size - 64
-c0 2 VID (0x16c0)
-16
-dc 2 PID (0x047c)
-05
-01 2 Device Release BCD - 0.01
-00
-01 1 Manufacturer String - 1
-00 1 Product String - 0
-00 1 Serial Number String - 0
-01 1 Number of Configurations - 1
diff --git a/usb/ds_lang.xxd b/usb/ds_lang.xxd
deleted file mode 100644
index e6e334c..0000000
--- a/usb/ds_lang.xxd
+++ /dev/null
@@ -1,4 +0,0 @@
-04 1 Length - 4
-03 1 Type - 3 (Language)
-09 2 LANGID - EN US
-04
diff --git a/usb/ds_str1.xxd b/usb/ds_str1.xxd
deleted file mode 100644
index 1aea777..0000000
--- a/usb/ds_str1.xxd
+++ /dev/null
@@ -1,22 +0,0 @@
-16 1 Length - 22
-03 1 Type - 3 (String)
-74 20 - the-tk.com
-00
-68
-00
-65
-00
-2d
-00
-74
-00
-6b
-00
-2e
-00
-63
-00
-6f
-00
-6d
-00
diff --git a/usb/endpt0.c b/usb/endpt0.c
index a60e1a4..7791d38 100644
--- a/usb/endpt0.c
+++ b/usb/endpt0.c
@@ -1,3 +1,4 @@
+#include <arrlen.h>
#include <le.h>
#include <reg/usbotg.h>
#include <stdbool.h>
@@ -9,10 +10,7 @@
#include "bdt.h"
#include "endpt0.h"
-#include "ds_conf.xxh"
-#include "ds_dev.xxh"
-#include "ds_lang.xxh"
-#include "ds_str1.xxh"
+#include "descriptors.h"
#define MAX_PACKET 64
static unsigned char buf[2][MAX_PACKET];
@@ -142,16 +140,16 @@ static void tok_setup(struct tok_setup *setup)
case 0x8006: /* GET DESCRIPTOR */
switch (setup->value) {
case 0x0100: /* DEVICE */
- quetx(usb_ds_dev, trunc(usb_ds_dev_len, setup->length));
+ quetx(ds_dev, trunc(ARRLEN(ds_dev), setup->length));
return;
case 0x0200: /* CONFIGURATION */
- quetx(usb_ds_conf, trunc(usb_ds_conf_len, setup->length));
+ quetx(ds_conf, trunc(ARRLEN(ds_conf), setup->length));
return;
case 0x0300: /* STRING 0 */
- quetx(usb_ds_lang, trunc(usb_ds_lang_len, setup->length));
+ quetx(ds_lang, trunc(ARRLEN(ds_lang), setup->length));
return;
case 0x0301: /* STRING 1 */
- quetx(usb_ds_str1, trunc(usb_ds_str1_len, setup->length));
+ quetx(ds_str1, trunc(ARRLEN(ds_str1), setup->length));
return;
}
/* fall through */