]> sigrok.org Git - sigrok-firmware-fx2lafw.git/commitdiff
Add and use macros to simplify USB descriptor files.
authorUwe Hermann <redacted>
Sat, 8 Oct 2016 14:41:10 +0000 (16:41 +0200)
committerUwe Hermann <redacted>
Sat, 8 Oct 2016 14:45:38 +0000 (16:45 +0200)
The macros in include/common.inc were provided by
Stefan Brüns <redacted>, thanks!

Makefile.am
include/common.inc [new file with mode: 0644]
include/dscr.inc
include/dscr_hantek_6022be.inc

index afafb2e56e757c8b6a036f66133c2175e99e9bab..38d2e1a8f248d6e54d9f0ab438df9777d239f140 100644 (file)
@@ -69,6 +69,7 @@ firmware_binaries = \
 fx2lafw_headers = \
        include/command.h \
        include/dscr.inc \
+       include/common.inc \
        include/fx2lafw.h \
        include/gpif-acquisition.h
 
@@ -81,7 +82,8 @@ fx2lafw_objects = \
        gpif-acquisition.rel
 
 hantek_6022be_headers = \
-       include/dscr_hantek_6022be.inc
+       include/dscr_hantek_6022be.inc \
+       include/common.inc
 
 hantek_6022be_sources = \
        hantek_6022be.c
@@ -90,7 +92,8 @@ hantek_6022be_objects = \
        hantek_6022be.rel
 
 sainsmart_dds120_headers = \
-       include/dscr_hantek_6022be.inc
+       include/dscr_hantek_6022be.inc \
+       include/common.inc
 
 sainsmart_dds120_sources = \
        sainsmart_dds120.c
diff --git a/include/common.inc b/include/common.inc
new file mode 100644 (file)
index 0000000..55520d1
--- /dev/null
@@ -0,0 +1,36 @@
+;;\r
+;; This file is part of the sigrok-firmware-fx2lafw project.\r
+;;\r
+;; Copyright (C) 2016 Stefan Brüns <stefan.bruens@rwth-aachen.de>\r
+;;\r
+;; This program is free software; you can redistribute it and/or modify\r
+;; it under the terms of the GNU General Public License as published by\r
+;; the Free Software Foundation; either version 2 of the License, or\r
+;; (at your option) any later version.\r
+;;\r
+;; This program is distributed in the hope that it will be useful,\r
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+;; GNU General Public License for more details.\r
+;;\r
+;; You should have received a copy of the GNU General Public License\r
+;; along with this program; if not, write to the Free Software\r
+;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\r
+;;\r
+\r
+.macro string_descriptor_a n,str\r
+_string'n:\r
+       .nchr   len,"'str"\r
+       .db     len * 2 + 2\r
+       .db     3\r
+       .irpc   i,^"'str"\r
+               .db     ''i, 0\r
+       .endm\r
+.endm\r
+\r
+.macro string_descriptor_lang n,l\r
+_string'n:\r
+       .db     4\r
+       .db     3\r
+       .dw     >l + (<l * 0x100)\r
+.endm\r
index 5384160a849f5b1dfa1655e6e0e62bcc7a3b2287..1d9888a057048f7670ca3d07bfcfb5c41cde4ad2 100644 (file)
@@ -19,6 +19,8 @@
 ;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 ;;
 
+.include "common.inc"
+
 .module DEV_DSCR
 
 ; Descriptor types
@@ -164,24 +166,10 @@ fullspd_dscr_realend:
 _dev_strings:
 
 ; See http://www.usb.org/developers/docs/USB_LANGIDs.pdf for the full list.
-_string0:
-       .db     string0end - _string0
-       .db     DSCR_STRING_TYPE
-       .db     0x09, 0x04              ; Language code 0x0409 (English, US)
-string0end:
-
-_string1:
-       .db     string1end - _string1
-       .db     DSCR_STRING_TYPE
-       .ascii  's\0i\0g\0r\0o\0k\0'
-string1end:
-
-_string2:
-       .db     string2end - _string2
-       .db     DSCR_STRING_TYPE
-       .ascii  'f\0x\0002\0l\0a\0f\0w\0'
-string2end:
+string_descriptor_lang 0 0x0409 ; Language code 0x0409 (English, US)
+
+string_descriptor_a 1,^"sigrok"
+string_descriptor_a 2,^"fx2lafw"
 
 _dev_strings_end:
        .dw     0x0000
-
index 0f8eb0084bb161287cd4629db944f61d45577047..696aa94bc2bbf286b1711b865e7f50fbf35e1160 100644 (file)
@@ -18,6 +18,8 @@
 ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 ;;
 
+.include "common.inc"
+
 .module DEV_DSCR
 
 ; Descriptor types
@@ -347,24 +349,10 @@ fullspd_dscr_realend:
 _dev_strings:
 
 ; See http://www.usb.org/developers/docs/USB_LANGIDs.pdf for the full list.
-_string0:
-       .db     string0end - _string0
-       .db     DSCR_STRING_TYPE
-       .db     0x09, 0x04              ; Language code 0x0409 (English, US)
-string0end:
-
-_string1:
-       .db     string1end - _string1
-       .db     DSCR_STRING_TYPE
-       .ascii  's\0i\0g\0r\0o\0k\0'
-string1end:
-
-_string2:
-       .db     string2end - _string2
-       .db     DSCR_STRING_TYPE
-       .ascii  'f\0x\0002\0l\0a\0f\0w\0'
-string2end:
+string_descriptor_lang 0 0x0409 ; Language code 0x0409 (English, US)
+
+string_descriptor_a 1,^"sigrok"
+string_descriptor_a 2,^"fx2lafw"
 
 _dev_strings_end:
        .dw     0x0000
-