├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── doc
└── Maix-GO_原理图.pdf
├── libopencm3.rules.mk
└── src
├── Makefile
├── ec.c
├── ft2232d.dmp
├── itdf.h
├── itdf_protocol.c
├── jtag_handler.c
├── stm32f103x8.ld
├── uart_handler.c
├── usb_private.c
└── usb_private.h
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.bin
3 | *.hex
4 | *~
5 | *.map
6 | *.d
7 | *.elf
8 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "libopencm3"]
2 | path = libopencm3
3 | url = https://github.com/libopencm3/libopencm3
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Description
2 | ======
3 |
4 | Open source embedded controller to provide communication and peripheral features to embedded systems.
5 |
6 | Requirements
7 | --------------
8 |
9 | LibOpenCM3 library is needed, GD32F150G6 currently depends on nasty-gd32f150 branch.
10 |
11 | Planned for STM32F103C8 and GD32F150G6 two platforms.
12 |
13 | Maybe CH552 support will be included in future.
14 |
15 | Support Platforms
16 | --------------
17 |
18 | Sipeed Tang series Anlogic FPGA boards. (Prime)
19 |
20 | Sipeed MaiX series Kendryte K210 boards. (Go)
21 |
22 | Build
23 | --------------
24 |
25 | Enter the src directory, and type "make"
26 |
27 | Flash
28 | --------------
29 |
30 | TBD
31 |
32 | License
33 | --------------
34 |
35 | LGPLv3
36 |
37 | Authors
38 | --------------
39 |
40 | Zhiyuan Wan
41 |
--------------------------------------------------------------------------------
/doc/Maix-GO_原理图.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipeed/open-ec/b6dee9b65ecbcf2b201490a45fc629aaa537e9c8/doc/Maix-GO_原理图.pdf
--------------------------------------------------------------------------------
/libopencm3.rules.mk:
--------------------------------------------------------------------------------
1 | ##
2 | ## This file is part of the libopencm3 project.
3 | ##
4 | ## Copyright (C) 2009 Uwe Hermann
5 | ## Copyright (C) 2010 Piotr Esden-Tempski
6 | ## Copyright (C) 2013 Frantisek Burian
7 | ##
8 | ## This library is free software: you can redistribute it and/or modify
9 | ## it under the terms of the GNU Lesser General Public License as published by
10 | ## the Free Software Foundation, either version 3 of the License, or
11 | ## (at your option) any later version.
12 | ##
13 | ## This library is distributed in the hope that it will be useful,
14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | ## GNU Lesser General Public License for more details.
17 | ##
18 | ## You should have received a copy of the GNU Lesser General Public License
19 | ## along with this library. If not, see .
20 | ##
21 |
22 | # Be silent per default, but 'make V=1' will show all compiler calls.
23 | ifneq ($(V),1)
24 | Q := @
25 | NULL := 2>/dev/null
26 | endif
27 |
28 | ###############################################################################
29 | # Executables
30 |
31 | PREFIX ?= arm-none-eabi
32 |
33 | CC := $(PREFIX)-gcc
34 | CXX := $(PREFIX)-g++
35 | LD := $(PREFIX)-gcc
36 | AR := $(PREFIX)-ar
37 | AS := $(PREFIX)-as
38 | OBJCOPY := $(PREFIX)-objcopy
39 | OBJDUMP := $(PREFIX)-objdump
40 | GDB := $(PREFIX)-gdb
41 | STFLASH = $(shell which st-flash)
42 | STYLECHECK := /checkpatch.pl
43 | STYLECHECKFLAGS := --no-tree -f --terse --mailback
44 | STYLECHECKFILES := $(shell find . -name '*.[ch]')
45 |
46 |
47 | ###############################################################################
48 | # Source files
49 |
50 | LDSCRIPT ?= $(BINARY).ld
51 |
52 | OBJS += $(BINARY).o
53 |
54 |
55 | ifeq ($(strip $(OPENCM3_DIR)),)
56 | # user has not specified the library path, so we try to detect it
57 |
58 | # where we search for the library
59 | LIBPATHS := ./libopencm3 ../libopencm3 ../../libopencm3 ../../../../../libopencm3
60 |
61 | OPENCM3_DIR := $(wildcard $(LIBPATHS:=/locm3.sublime-project))
62 | OPENCM3_DIR := $(firstword $(dir $(OPENCM3_DIR)))
63 |
64 | ifeq ($(strip $(OPENCM3_DIR)),)
65 | $(warning Cannot find libopencm3 library in the standard search paths.)
66 | $(error Please specify it through OPENCM3_DIR variable!)
67 | endif
68 | endif
69 |
70 | ifeq ($(V),1)
71 | $(info Using $(OPENCM3_DIR) path to library)
72 | endif
73 |
74 | INCLUDE_DIR = $(OPENCM3_DIR)/include
75 | LIB_DIR = $(OPENCM3_DIR)/lib
76 | SCRIPT_DIR = $(OPENCM3_DIR)/scripts
77 |
78 | ###############################################################################
79 | # C flags
80 |
81 | CFLAGS += -Os -g
82 | CFLAGS += -Wextra -Wshadow -Wimplicit-function-declaration
83 | CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
84 | CFLAGS += -fno-common -ffunction-sections -fdata-sections
85 |
86 | ###############################################################################
87 | # C++ flags
88 |
89 | CXXFLAGS += -Os -g
90 | CXXFLAGS += -Wextra -Wshadow -Wredundant-decls -Weffc++
91 | CXXFLAGS += -fno-common -ffunction-sections -fdata-sections
92 |
93 | ###############################################################################
94 | # C & C++ preprocessor common flags
95 |
96 | CPPFLAGS += -MD
97 | CPPFLAGS += -Wall -Wundef
98 | CPPFLAGS += -I$(INCLUDE_DIR) $(DEFS)
99 |
100 | ###############################################################################
101 | # Linker flags
102 |
103 | LDFLAGS += --static -nostartfiles
104 | LDFLAGS += -L$(LIB_DIR)
105 | LDFLAGS += -T$(LDSCRIPT)
106 | LDFLAGS += -Wl,-Map=$(*).map
107 | LDFLAGS += -Wl,--gc-sections
108 | ifeq ($(V),99)
109 | LDFLAGS += -Wl,--print-gc-sections
110 | endif
111 |
112 | ###############################################################################
113 | # Used libraries
114 |
115 | LDLIBS += -l$(LIBNAME)
116 | LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
117 |
118 | ###############################################################################
119 | ###############################################################################
120 | ###############################################################################
121 |
122 | .SUFFIXES: .elf .bin .hex .srec .list .map .images
123 | .SECONDEXPANSION:
124 | .SECONDARY:
125 |
126 | all: elf
127 |
128 | elf: $(BINARY).elf
129 | bin: $(BINARY).bin
130 | hex: $(BINARY).hex
131 | srec: $(BINARY).srec
132 | list: $(BINARY).list
133 |
134 | images: $(BINARY).images
135 | flash: $(BINARY).flash
136 |
137 | $(LDSCRIPT):
138 | ifeq (,$(wildcard $(LDSCRIPT)))
139 | $(error Unable to find specified linker script: $(LDSCRIPT))
140 | endif
141 |
142 | %.images: %.bin %.hex %.srec %.list %.map
143 | @#printf "*** $* images generated ***\n"
144 |
145 | %.bin: %.elf
146 | @printf " OBJCOPY $(*).bin\n"
147 | $(Q)$(OBJCOPY) -Obinary $(*).elf $(*).bin
148 |
149 | %.hex: %.elf
150 | @printf " OBJCOPY $(*).hex\n"
151 | $(Q)$(OBJCOPY) -Oihex $(*).elf $(*).hex
152 |
153 | %.srec: %.elf
154 | @printf " OBJCOPY $(*).srec\n"
155 | $(Q)$(OBJCOPY) -Osrec $(*).elf $(*).srec
156 |
157 | %.list: %.elf
158 | @printf " OBJDUMP $(*).list\n"
159 | $(Q)$(OBJDUMP) -S $(*).elf > $(*).list
160 |
161 | %.elf %.map: $(OBJS) $(LDSCRIPT) $(LIB_DIR)/lib$(LIBNAME).a
162 | @printf " LD $(*).elf\n"
163 | $(Q)$(LD) $(LDFLAGS) $(ARCH_FLAGS) $(OBJS) $(LDLIBS) -o $(*).elf
164 |
165 | %.o: %.c
166 | @printf " CC $(*).c\n"
167 | $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o $(*).o -c $(*).c
168 |
169 | %.o: %.cxx
170 | @printf " CXX $(*).cxx\n"
171 | $(Q)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o $(*).o -c $(*).cxx
172 |
173 | %.o: %.cpp
174 | @printf " CXX $(*).cpp\n"
175 | $(Q)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o $(*).o -c $(*).cpp
176 |
177 | $(LIB_DIR)/lib$(LIBNAME).a: $(OPENCM3_DIR)
178 | @printf " BUILD LIBOPENCM3\n"
179 | $(Q)make -C $(OPENCM3_DIR)
180 |
181 | clean::
182 | @printf " CLEAN .\n"
183 | $(Q)$(RM) *.o *.d *.elf *.bin *.hex *.srec *.list *.map
184 | distclean:
185 | @printf " CLEAN ALL\n"
186 | $(Q)$(RM) *.o *.d *.elf *.bin *.hex *.srec *.list *.map
187 | $(Q)make -C $(OPENCM3_DIR) clean
188 |
189 | stylecheck: $(STYLECHECKFILES:=.stylecheck)
190 | styleclean: $(STYLECHECKFILES:=.styleclean)
191 |
192 | # the cat is due to multithreaded nature - we like to have consistent chunks of text on the output
193 | %.stylecheck: %
194 | $(Q)$(SCRIPT_DIR)$(STYLECHECK) $(STYLECHECKFLAGS) $* > $*.stylecheck; \
195 | if [ -s $*.stylecheck ]; then \
196 | cat $*.stylecheck; \
197 | else \
198 | rm -f $*.stylecheck; \
199 | fi;
200 |
201 | %.styleclean:
202 | $(Q)rm -f $*.stylecheck;
203 |
204 |
205 | %.stlink-flash: %.bin
206 | @printf " FLASH $<\n"
207 | $(Q)$(STFLASH) write $(*).bin 0x8000000
208 |
209 | %.flash: %.hex
210 | @printf " FLASH $<\n"
211 | @# IMPORTANT: Don't use "resume", only "reset" will work correctly!
212 | $(Q)$(OOCD) -f $(OOCD_INTERFACE) \
213 | -f $(OOCD_BOARD) \
214 | -c "init" -c "reset init" \
215 | -c "flash write_image erase $(*).hex" \
216 | -c "reset" \
217 | -c "shutdown" $(NULL)
218 |
219 | .PHONY: images clean stylecheck styleclean elf bin hex srec list
220 |
221 | -include $(OBJS:.o=.d)
222 |
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | ##
2 | ## This file is part of anlogic-usbjtag project
3 | ##
4 | ## Copyright (C) 2009 Uwe Hermann
5 | ## Copyright (C) 2017 Zhiyuan Wan
6 | ##
7 | ## This library is free software: you can redistribute it and/or modify
8 | ## it under the terms of the GNU Lesser General Public License as published by
9 | ## the Free Software Foundation, either version 3 of the License, or
10 | ## (at your option) any later version.
11 | ##
12 | ## This library is distributed in the hope that it will be useful,
13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | ## GNU Lesser General Public License for more details.
16 | ##
17 | ## You should have received a copy of the GNU Lesser General Public License
18 | ## along with this library. If not, see .
19 | ##
20 |
21 | BINARY = ec
22 |
23 | OBJS = usb_private.o
24 |
25 | LDSCRIPT = stm32f103x8.ld
26 |
27 | DFU_UTIL = dfu-util
28 | ST_FLASH = st-flash
29 |
30 | USB_ID = 1d50:6017
31 |
32 | LIBNAME ?= opencm3_stm32f1
33 | DEFS ?= -DSTM32F1 -O3
34 | FP_FLAGS ?= -msoft-float
35 | ARCH_FLAGS ?= -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd
36 |
37 | include ../libopencm3.rules.mk
38 |
39 |
40 | size: $(OBJS) $(BINARY).elf
41 | @$(PREFIX)-size $(OBJS) $(BINARY).elf
42 |
43 | dfu: $(BINARY).bin
44 | @printf " FLASH $<\n"
45 | @$(DFU_UTIL) -d $(USB_ID) -D $(BINARY).bin -s 0x08002000
46 | stlink: $(BINARY).bin
47 | @printf " FLASH $<\n"
48 | @$(ST_FLASH) write $(BINARY).bin 0x08002000
49 |
--------------------------------------------------------------------------------
/src/ec.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the open-ec (Embedded controller) project.
3 | *
4 | * Copyright (C) 2019 Zhiyuan Wan
5 | *
6 | * This library is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with this library. If not, see .
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include "itdf.h"
29 |
30 |
31 | //TODO: Move platform specific code out from main.c
32 | /* Here it starts */
33 | static void rcc_clock_setup_in_hse_24mhz_out_72mhz(void)
34 | {
35 | /* Set system clock to 72 MHz, base frequency = 24MHz */
36 | /* Enable internal high-speed oscillator. */
37 | rcc_osc_on(RCC_HSI);
38 | rcc_wait_for_osc_ready(RCC_HSI);
39 |
40 | /* Select HSI as SYSCLK source. */
41 | rcc_set_sysclk_source(RCC_CFGR_SW_SYSCLKSEL_HSICLK);
42 |
43 | /* Enable external high-speed oscillator 24MHz. */
44 | rcc_osc_on(RCC_HSE);
45 | rcc_wait_for_osc_ready(RCC_HSE);
46 | rcc_set_sysclk_source(RCC_CFGR_SW_SYSCLKSEL_HSECLK);
47 |
48 | /*
49 | * Set prescalers for AHB, ADC, ABP1, ABP2.
50 | * Do this before touching the PLL (TODO: why?).
51 | */
52 | rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 72MHz Max. 72MHz */
53 | rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV8); /* Set. 9MHz Max. 14MHz */
54 | rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 36MHz Max. 36MHz */
55 | rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 72MHz Max. 72MHz */
56 |
57 | /*
58 | * Sysclk runs with 72MHz -> 2 waitstates. (STM32 only)
59 | * 0WS from 0-24MHz
60 | * 1WS from 24-48MHz
61 | * 2WS from 48-72MHz
62 | */
63 | flash_set_ws(FLASH_ACR_LATENCY_2WS);
64 |
65 | /*
66 | * Set the PLL multiplication factor to 6.
67 | * 12MHz (external) * 6 (multiplier) = 72MHz
68 | */
69 | rcc_set_pll_multiplication_factor(RCC_CFGR_PLLMUL_PLL_CLK_MUL6);
70 |
71 | /* Select HSE as PLL source. */
72 | rcc_set_pll_source(RCC_CFGR_PLLSRC_HSE_CLK);
73 |
74 | /* Some board will have issues in high external clock input > 16MHz
75 | * Set prescaler to 2 to avoid this issue and make system more stable
76 | */
77 | rcc_set_pllxtpre(RCC_CFGR_PLLXTPRE_HSE_CLK_DIV2);
78 |
79 | /* Enable PLL oscillator and wait for it to stabilize. */
80 | rcc_osc_on(RCC_PLL);
81 | rcc_wait_for_osc_ready(RCC_PLL);
82 |
83 | /* Select PLL as SYSCLK source. */
84 | rcc_set_sysclk_source(RCC_CFGR_SW_SYSCLKSEL_PLLCLK);
85 |
86 | /* Set the peripheral clock frequencies used */
87 | rcc_ahb_frequency = 72000000;
88 | rcc_apb1_frequency = 36000000;
89 | rcc_apb2_frequency = 72000000;
90 |
91 | }
92 |
93 |
94 | static void clock_setup(void)
95 | {
96 | rcc_clock_setup_in_hse_24mhz_out_72mhz();
97 | //rcc_clock_setup_in_hsi_out_48mhz();
98 |
99 | /* Enable clocks. */
100 | rcc_periph_clock_enable(RCC_GPIOB);
101 | rcc_periph_clock_enable(RCC_GPIOA);
102 | //rcc_periph_clock_enable(RCC_AFIO);
103 | rcc_periph_clock_enable(RCC_USART1);
104 |
105 | SCB_VTOR = 0x08002000;
106 | }
107 |
108 |
109 | #define dtr_set() gpio_set(GPIOB, GPIO15); gpio_set(GPIOB, GPIO10)
110 | #define dtr_clr() gpio_clear(GPIOB, GPIO15); gpio_clear(GPIOB, GPIO10)
111 |
112 | #define rts_set() gpio_set(GPIOA, GPIO2); gpio_set(GPIOB, GPIO11)
113 | #define rts_clr() gpio_clear(GPIOA, GPIO2); gpio_clear(GPIOB, GPIO11)
114 |
115 | static void gpio_setup(void)
116 | {
117 | dtr_set();
118 | rts_set();
119 | /* LED 引脚 */
120 | gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
121 | GPIO_CNF_OUTPUT_PUSHPULL, GPIO2 | GPIO10 | GPIO11);
122 | /* USB 上拉 */
123 | gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
124 | GPIO_CNF_OUTPUT_PUSHPULL, GPIO8);
125 |
126 | gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ,
127 | GPIO_CNF_OUTPUT_OPENDRAIN, GPIO15); //1.8V IO BOOT脚(DTR)
128 |
129 | gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
130 | GPIO_CNF_OUTPUT_OPENDRAIN, GPIO2); //1.8V IO RST脚(RTS)
131 |
132 | gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
133 | GPIO_CNF_OUTPUT_PUSHPULL, GPIO5 | GPIO7); //TCK TDI
134 | gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
135 | GPIO_CNF_OUTPUT_PUSHPULL, GPIO14); //TMS
136 | gpio_set_mode(GPIOA, GPIO_MODE_INPUT,
137 | GPIO_CNF_INPUT_FLOAT, GPIO6); //TDO
138 |
139 | gpio_set(GPIOA, GPIO5 | GPIO6 | GPIO7);
140 | gpio_set(GPIOB, GPIO14);
141 |
142 | /* 防止电源短路 */
143 | gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
144 | GPIO_CNF_INPUT_FLOAT, GPIO0 | GPIO1);
145 | //暂且用Bitbang模拟SESPM
146 | }
147 |
148 | /* Here it ends */
149 |
150 | /* USB process */
151 |
152 | #include
153 | #include "usb_private.h"
154 |
155 | usbd_device *usbd_dev_handler;
156 |
157 | static const struct usb_device_descriptor dev = {
158 | .bLength = USB_DT_DEVICE_SIZE,
159 | .bDescriptorType = USB_DT_DEVICE,
160 | .bcdUSB = 0x0200,
161 | .bDeviceClass = 0,
162 | .bDeviceSubClass = 0,
163 | .bDeviceProtocol = 0,
164 | .bMaxPacketSize0 = 32,
165 | .idVendor = 0x0403,
166 | .idProduct = 0x6010, /* Specific VID/PID to make debugger happy */
167 | .bcdDevice = 0x0500,
168 | .iManufacturer = 1,
169 | .iProduct = 2,
170 | .iSerialNumber = 0,
171 | .bNumConfigurations = 1,
172 | };
173 |
174 | static const struct usb_endpoint_descriptor jtag_endp[] = {{
175 | .bLength = USB_DT_ENDPOINT_SIZE,
176 | .bDescriptorType = USB_DT_ENDPOINT,
177 | .bEndpointAddress = 0x81,
178 | .bmAttributes = USB_ENDPOINT_ATTR_BULK,
179 | .wMaxPacketSize = 64,
180 | .bInterval = 1,
181 | }, {
182 | .bLength = USB_DT_ENDPOINT_SIZE,
183 | .bDescriptorType = USB_DT_ENDPOINT,
184 | .bEndpointAddress = 0x02,
185 | .bmAttributes = USB_ENDPOINT_ATTR_BULK,
186 | .wMaxPacketSize = 64,
187 | .bInterval = 1,
188 | }};
189 |
190 |
191 | static const struct usb_interface_descriptor jtag_iface[] = {{
192 | .bLength = USB_DT_INTERFACE_SIZE,
193 | .bDescriptorType = USB_DT_INTERFACE,
194 | .bInterfaceNumber = 0,
195 | .bAlternateSetting = 0,
196 | .bNumEndpoints = 2,
197 | .bInterfaceClass = USB_CLASS_VENDOR,
198 | .bInterfaceSubClass = USB_CLASS_VENDOR,
199 | .bInterfaceProtocol = USB_CLASS_VENDOR,
200 | .iInterface = 2,
201 |
202 | .endpoint = jtag_endp,
203 | }};
204 |
205 | static const struct usb_endpoint_descriptor serial_endp[] = {{
206 | .bLength = USB_DT_ENDPOINT_SIZE,
207 | .bDescriptorType = USB_DT_ENDPOINT,
208 | .bEndpointAddress = 0x83,
209 | .bmAttributes = USB_ENDPOINT_ATTR_BULK,
210 | .wMaxPacketSize = 64,
211 | .bInterval = 1,
212 | }, {
213 | .bLength = USB_DT_ENDPOINT_SIZE,
214 | .bDescriptorType = USB_DT_ENDPOINT,
215 | .bEndpointAddress = 0x04,
216 | .bmAttributes = USB_ENDPOINT_ATTR_BULK,
217 | .wMaxPacketSize = 64,
218 | .bInterval = 1,
219 | }};
220 |
221 |
222 | static const struct usb_interface_descriptor serial_iface[] = {{
223 | .bLength = USB_DT_INTERFACE_SIZE,
224 | .bDescriptorType = USB_DT_INTERFACE,
225 | .bInterfaceNumber = 1,
226 | .bAlternateSetting = 0,
227 | .bNumEndpoints = 2,
228 | .bInterfaceClass = USB_CLASS_VENDOR,
229 | .bInterfaceSubClass = USB_CLASS_VENDOR,
230 | .bInterfaceProtocol = USB_CLASS_VENDOR,
231 | .iInterface = 2,
232 |
233 | .endpoint = serial_endp,
234 | }};
235 |
236 | static const struct usb_interface ifaces[] = {{
237 | .num_altsetting = 1,
238 | .altsetting = jtag_iface,
239 | }, {
240 | .num_altsetting = 1,
241 | .altsetting = serial_iface,
242 | }};
243 |
244 | static const struct usb_config_descriptor config = {
245 | .bLength = USB_DT_CONFIGURATION_SIZE,
246 | .bDescriptorType = USB_DT_CONFIGURATION,
247 | .wTotalLength = 0,
248 | .bNumInterfaces = 2,
249 | .bConfigurationValue = 1,
250 | .iConfiguration = 0,
251 | .bmAttributes = 0x80,
252 | .bMaxPower = 0x32,
253 |
254 | .interface = ifaces,
255 | };
256 |
257 | static const char *usb_strings[] = {
258 | "Open-EC",
259 | "USB Debugger"
260 | };
261 |
262 | /* Buffer to be used for control requests. */
263 | uint8_t usbd_control_buffer[64];
264 |
265 | /* USB interrupt handler */
266 | void usb_wakeup_isr(void)
267 | __attribute__ ((alias ("usb_int_relay")));
268 |
269 | void usb_hp_can_tx_isr(void)
270 | __attribute__ ((alias ("usb_int_relay")));
271 |
272 | void usb_lp_can_rx0_isr(void)
273 | __attribute__ ((alias ("usb_int_relay")));
274 |
275 |
276 | static void usb_int_relay(void)
277 | {
278 | usbd_poll(usbd_dev_handler);
279 | }
280 |
281 |
282 | /* Control request handler */
283 |
284 |
285 | uint8_t bulkout_buf[2][64] = {{0x01, 0x60}, {0x01, 0x60}};
286 | volatile uint8_t latency_timer[2] = {3, 3};
287 |
288 | uint8_t dtr = 1, rts = 1;
289 |
290 | uint8_t handler_buf[8];
291 | /* 尴尬的双串口,虽然有一个根本没用 */
292 |
293 | /* SESPM处理变量 */
294 | volatile uint8_t sespm_enable = 0;
295 |
296 | enum sespm_state_t sespm_state = IDLE;
297 | uint8_t sespm_bypass = 0;
298 |
299 |
300 | #define C_CLK 48000000
301 | static void uart_set_baudrate(int itdf_divisor)
302 | {
303 | uint8_t frac[] = {0, 8, 4, 2, 6, 10, 12, 14};
304 | int divisor = itdf_divisor & 0x3fff;
305 | divisor <<= 4;
306 | divisor |= frac[(itdf_divisor >> 14) & 0x07];
307 | int baudrate;
308 | /* 驱动的workaround */
309 | if(itdf_divisor == 0x01)
310 | { //2Mbps
311 | baudrate = 2000000;
312 | }
313 | else if(itdf_divisor == 0x00)
314 | {
315 | baudrate = 3000000;
316 | }
317 | else
318 | {
319 | baudrate = C_CLK / divisor;
320 | }
321 | if(baudrate < 120 || baudrate > 3000000)
322 | {
323 | baudrate = 115200;
324 | }
325 | if(itdf_divisor == 0x2710) //300bps转义为4.5Mbps
326 | {
327 | baudrate = 4500000;
328 | }
329 | usart_set_baudrate(USART1, baudrate);
330 | }
331 |
332 |
333 | static int ec_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf,
334 | uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
335 | {
336 | (void)complete;
337 | (void)buf;
338 | (void)usbd_dev;
339 | (void)len;
340 |
341 | int port = req->wIndex & 0x03;
342 |
343 | *len = 0;
344 |
345 | if(req->bmRequestType == ITDF_SET_REQUEST_TYPE)
346 | {
347 | switch (req->bRequest)
348 | {
349 | case ITDF_SIO_RESET:
350 | case ITDF_SIO_SET_FLOW_CTRL: //TODO: 实现流控
351 | case ITDF_SIO_SET_DATA: //TODO: 实现校验位,停止位,数据位
352 | case ITDF_SIO_SET_EVENT_CHAR:
353 | case ITDF_SIO_SET_ERROR_CHAR:
354 | case ITDF_SIO_WRITE_EEPROM:
355 | case ITDF_SIO_TEST_EEPROM:
356 | {
357 | return 1; //这个时候只要微笑就好了
358 | }
359 | case ITDF_SIO_SET_LATENCY_TIMER:
360 | {
361 | latency_timer[port] = req->wValue & 0xff;
362 | return 1;
363 | }
364 | case ITDF_SIO_SET_BAUD_RATE:
365 | {
366 | if(port == 2)
367 | {//设置波特率
368 | uint8_t Baudrate_High = (req->wIndex >> 8);
369 | uart_set_baudrate(req->wValue | (Baudrate_High << 16));
370 | }
371 | return 1;
372 | }
373 | case ITDF_SIO_MODEM_CTRL:
374 | {
375 | if(port == 2) /* 忽略掉 SESPM口 */
376 | {
377 | #if 1
378 | uint8_t wValueH = req->wValue >> 8;
379 | if(wValueH & ITDF_SIO_SET_DTR_MASK)
380 | {
381 | if(req->wValue & ITDF_SIO_SET_DTR_MASK)
382 | {
383 | dtr = 1;
384 | }
385 | else
386 | {
387 | dtr = 0;
388 | }
389 | }
390 | if(wValueH & ITDF_SIO_SET_RTS_MASK)
391 | {
392 | if(req->wValue & ITDF_SIO_SET_RTS_MASK)
393 | {
394 | rts = 1;
395 | }
396 | else
397 | {
398 | rts = 0;
399 | }
400 | }
401 | if(dtr == rts)
402 | {
403 | dtr_set();
404 | rts_set();
405 | }
406 | if(dtr == 1 && rts == 0)
407 | {
408 | rts_clr();
409 | dtr_clr();
410 | }
411 | if(dtr == 0 && rts == 1)
412 | {
413 | rts_set();
414 | dtr_clr();
415 | }
416 | #endif
417 | }
418 | return 1;
419 | }
420 | case ITDF_SIO_SET_BITMODE:
421 | {
422 | if(port == 1) /* SESPM口 */
423 | {
424 | enum itdf_sespm_mode mode = req->wValue >> 8;
425 | //uint8_t bitmask = req->wValue & 0xff;
426 | if(mode == BITMODE_RESET)
427 | {//BITMODE复位
428 | sespm_enable = 0;
429 | sespm_bypass = 0;
430 | sespm_state = IDLE;
431 | }
432 | else if(mode == BITMODE_SESPM)
433 | {//TODO: 仅支持SESPM
434 | sespm_enable = 1;
435 | sespm_bypass = 0;
436 | sespm_state = IDLE;
437 | }
438 | }
439 | return 1;
440 | } //TODO: bootloader reset support
441 | }
442 | }
443 | else
444 | {
445 | switch (req->bRequest)
446 | {
447 | case ITDF_SIO_GET_LATENCY_TIMER:
448 | {
449 | handler_buf[0] = latency_timer[port];
450 | *buf = handler_buf;
451 | *len = 1; /* 送回latency_timer */
452 | return 1;
453 | }
454 | case ITDF_SIO_GET_MODEM_STATUS:
455 | {
456 | handler_buf[0] = 0x01;
457 | handler_buf[1] = 0x60;
458 | *buf = handler_buf;
459 | *len = 2; /* Modem status */
460 | return 1;
461 | }
462 | case ITDF_SIO_READ_EEPROM: /* 直接全部返回FF */
463 | {
464 | int eeprom_ar = req->wIndex & 0x3f;
465 | handler_buf[0] = itdf_eeprom[eeprom_ar];
466 | handler_buf[1] = itdf_eeprom[eeprom_ar] >> 8;
467 | *len = 2;
468 | *buf = handler_buf;
469 | return 1;
470 | }
471 | }
472 | }
473 | return 0; //TODO: 实现所有ITDF功能
474 | }
475 |
476 | /* USB数据处理开始 */
477 |
478 | typedef int32_t ring_size_t;
479 |
480 | struct ring {
481 | uint8_t *data;
482 | ring_size_t size;
483 | volatile uint32_t begin;
484 | volatile uint32_t end;
485 | };
486 |
487 | #define RING_SIZE(RING) ((RING)->size - 1)
488 | #define RING_DATA(RING) (RING)->data
489 | #define RING_EMPTY(RING) ((RING)->begin == (RING)->end)
490 |
491 | static void ring_init(volatile struct ring *ring, uint8_t *buf, ring_size_t size)
492 | {
493 | ring->data = buf;
494 | ring->size = size;
495 | ring->begin = 0;
496 | ring->end = 0;
497 | }
498 |
499 | static inline int32_t ring_write_ch(volatile struct ring *ring, uint8_t ch)
500 | {
501 | ring->end %= ring-> size;
502 | if (((ring->end + 1) % ring->size) != ring->begin) {
503 | ring->data[ring->end++] = ch;
504 | ring->end %= ring->size;
505 | return (uint32_t)ch;
506 | }
507 |
508 | return -1;
509 | }
510 |
511 | static inline int32_t ring_write(volatile struct ring *ring, uint8_t *data, ring_size_t size)
512 | {
513 | int32_t i;
514 |
515 | for (i = 0; i < size; i++) {
516 | if (ring_write_ch(ring, data[i]) < 0)
517 | return -i;
518 | }
519 |
520 | return i;
521 | }
522 |
523 | static inline int32_t ring_read_ch(volatile struct ring *ring, uint8_t *ch)
524 | {
525 | int32_t ret = -1;
526 |
527 | if (ring->begin != ring->end) {
528 | ret = ring->data[ring->begin++];
529 | ring->begin %= ring->size;
530 | if (ch)
531 | *ch = ret;
532 | }
533 |
534 | return ret;
535 | }
536 |
537 | static inline int32_t ring_read(volatile struct ring *ring, uint8_t *data, ring_size_t size)
538 | {
539 | int32_t i;
540 |
541 | for (i = 0; i < size; i++) {
542 | if (ring_read_ch(ring, data + i) < 0)
543 | return i;
544 | }
545 |
546 | return 0;
547 | }
548 |
549 |
550 | static inline uint32_t ring_size(volatile struct ring *ring)
551 | {
552 | int size = (ring->end - ring->begin);
553 | if (size < 0) size = size + ring->size;
554 | return size;
555 | }
556 |
557 | static inline uint32_t ring_remain(volatile struct ring *ring)
558 | {
559 | return ring->size - ring_size(ring);
560 | }
561 |
562 |
563 | #define BUFFER_SIZE_IN 256
564 | #define BUFFER_SIZE_OUT 256
565 |
566 | #define SERIAL_IN_SINGLEBUF 1
567 | #define UART_SEND_BLOCKING
568 |
569 | #if (!SERIAL_IN_SINGLEBUF)
570 | volatile struct ring serial_in_ring;
571 | volatile struct ring jtag_in_ring;
572 | #endif
573 |
574 | volatile struct ring serial_out_ring;
575 | volatile struct ring jtag_out_ring;
576 | /* 256 byte的 收发缓冲区 */
577 | #if (!SERIAL_IN_SINGLEBUF)
578 | uint8_t ringbuf_jtag_in_buffer[BUFFER_SIZE_IN];
579 | uint8_t ringbuf_serial_in_buffer[BUFFER_SIZE_IN];
580 | #endif
581 |
582 | uint8_t ringbuf_jtag_out_buffer[BUFFER_SIZE_OUT];
583 | uint8_t ringbuf_serial_out_buffer[BUFFER_SIZE_OUT];
584 |
585 | static void ring_init_all(void)
586 | {
587 | #if (!SERIAL_IN_SINGLEBUF)
588 | ring_init(&serial_in_ring, ringbuf_serial_in_buffer, BUFFER_SIZE_IN);
589 | ring_init(&jtag_in_ring, ringbuf_jtag_in_buffer, BUFFER_SIZE_IN);
590 | #endif
591 | ring_init(&serial_out_ring, ringbuf_serial_out_buffer, BUFFER_SIZE_OUT);
592 | ring_init(&jtag_out_ring, ringbuf_jtag_out_buffer, BUFFER_SIZE_OUT);
593 | }
594 |
595 | /* 环形缓冲区结束 */
596 |
597 | #if SERIAL_IN_SINGLEBUF
598 | uint8_t serial_recv_buf[64];
599 | uint8_t serial_recv_len;
600 | uint8_t serial_recv_i;
601 |
602 | uint8_t jtag_recv_buf[64];
603 | uint8_t jtag_recv_len;
604 | uint8_t jtag_recv_i;
605 | #endif
606 |
607 |
608 | static void jtag_data_rx_cb(usbd_device *usbd_dev, uint8_t ep)
609 | {
610 | (void)ep;
611 | #if (!SERIAL_IN_SINGLEBUF)
612 | uint8_t buf[64];
613 | int len = usbd_ep_read_packet(usbd_dev, 0x02, buf, 64);
614 |
615 | if(len)
616 | {
617 | ring_write(&jtag_in_ring, buf, len);
618 | }
619 |
620 | if(ring_remain(&jtag_in_ring) < 128) //缓冲区满
621 | {
622 | usbd_ep_nak_set(usbd_dev, 0x02, 1); //阻塞
623 | }
624 | #else
625 | #if 0
626 | jtag_recv_len = usbd_ep_read_packet(usbd_dev, 0x02, jtag_recv_buf, 64);
627 | if (jtag_recv_len)
628 | {
629 | ring_write(&jtag_out_ring, jtag_recv_buf, jtag_recv_len);
630 |
631 | }
632 | #else
633 | uint8_t buf[64];
634 | static uint8_t sespm_cmd = 0;
635 | static uint16_t sespm_length = 0;
636 | static uint8_t sespm_read = 0;
637 |
638 | int len = usbd_ep_read_packet(usbd_dev, 0x02, buf, 64);
639 | int i;
640 | gpio_set(GPIOB, GPIO2);
641 | for(i = 0; i < len; i++)
642 | {
643 | uint8_t jtag_data = buf[i];
644 | switch(sespm_state)
645 | {
646 | case IDLE:
647 | {
648 | sespm_cmd = jtag_data;
649 | if(sespm_cmd & ITDF_SIE_SPECIAL)
650 | { //特殊命令
651 | switch(sespm_cmd)
652 | {
653 | case 0x80:
654 | { /* 设置IO 状态 */
655 | sespm_state = BUS_DATA;
656 | break;
657 | }
658 | case 0x81:
659 | { /* 读取 */
660 | uint8_t report = 0;
661 | if(GPIOA_IDR & GPIO5)
662 | report |= 0x01;
663 | if(GPIOA_IDR & GPIO6)
664 | report |= 0x04;
665 | if(GPIOA_IDR & GPIO7)
666 | report |= 0x02;
667 | if(GPIOB_IDR & GPIO14)
668 | report |= 0x08;
669 | ring_write_ch(&jtag_out_ring, report);
670 | break;
671 | }
672 | case 0x84:
673 | { /* Bypass On */
674 | sespm_bypass = 1;
675 | break;
676 | }
677 | case 0x85:
678 | { /* Bypass Off */
679 | sespm_bypass = 0;
680 | break;
681 | }
682 | case 0x86:
683 | { //TODO: Divisor support
684 | break;
685 | }
686 | default:
687 | { /* 错误命令 */
688 | bad_cmd:
689 | ring_write_ch(&jtag_out_ring, 0xfa);
690 | ring_write_ch(&jtag_out_ring, sespm_cmd);
691 | break;
692 | }
693 | }
694 | }
695 | else
696 | { //TODO: 常规命令,必须LSB first,负写正读
697 | if (!(sespm_cmd & ITDF_SIE_WRITE_MCE))
698 | goto bad_cmd;
699 | if (sespm_cmd & ITDF_SIE_READ_MCE)
700 | goto bad_cmd;
701 | if (!(sespm_cmd & ITDF_SIE_LSB_FIRST))
702 | goto bad_cmd;
703 | // 只允许TDI/TMS 二选一
704 | if ((sespm_cmd & ITDF_SIE_WRITE_TDI) &&
705 | (sespm_cmd & ITDF_SIE_WRITE_TMS))
706 | goto bad_cmd;
707 | /* 是否需要读取 */
708 | sespm_read = sespm_cmd & ITDF_SIE_READ_TDO;
709 | /* 写 TDI */
710 | if (sespm_cmd & ITDF_SIE_WRITE_TDI)
711 | {
712 | if (sespm_cmd & ITDF_SIE_BIT_MODE)
713 | sespm_state = TDI_RECV_LENG_BIT;
714 | else
715 | sespm_state = TDI_RECV_LENGL_BYTE;
716 | }
717 |
718 | if (sespm_cmd & ITDF_SIE_WRITE_TMS)
719 | {
720 | if (sespm_cmd & ITDF_SIE_BIT_MODE)
721 | sespm_state = TMS_RECV_LENG_BIT;
722 | else
723 | { // We should never reached here
724 | goto bad_cmd;
725 | }
726 | }
727 | }
728 |
729 | break;
730 | } //IDLE
731 | case BUS_DATA: /* TCK TDI TDO TMS */
732 | {
733 | if(jtag_data & 0x02)
734 | gpio_set(GPIOA, GPIO7); //TDI
735 | else
736 | gpio_clear(GPIOA, GPIO7);
737 | if(jtag_data & 0x04)
738 | gpio_set(GPIOA, GPIO6);
739 | else
740 | gpio_clear(GPIOA, GPIO6); //TDO
741 | if(jtag_data & 0x08)
742 | gpio_set(GPIOB, GPIO14); //TMS
743 | else
744 | gpio_clear(GPIOB, GPIO14);
745 |
746 | if(jtag_data & 0x01)
747 | gpio_set(GPIOA, GPIO5);
748 | else
749 | gpio_clear(GPIOA, GPIO5); //TCK
750 | sespm_state = BUS_DIR;
751 | break;
752 | }
753 | case BUS_DIR:
754 | {
755 | sespm_state = IDLE;
756 | break;
757 | }
758 | case TDI_RECV_LENGL_BYTE:
759 | case TDI_RECV_LENG_BIT:
760 | case TMS_RECV_LENG_BIT:
761 | {
762 | sespm_length = jtag_data;
763 | sespm_state ++;
764 | break;
765 | }
766 | case TDI_RECV_LENGH_BYTE:
767 | {
768 | sespm_length |= (jtag_data << 8);
769 | sespm_state ++;
770 | break;
771 | }
772 | case TDI_DATA_BYTE:
773 | {
774 | uint8_t recv_data = 0;
775 | uint8_t send_data = jtag_data;
776 | int j;
777 | for(j = 0; j < 8; j++)
778 | { // TCK 1 - 0 - 1
779 | if(send_data & 0x01)
780 | gpio_set(GPIOA, GPIO7); //TDI
781 | else
782 | gpio_clear(GPIOA, GPIO7);
783 |
784 | gpio_clear(GPIOA, GPIO5); //TCK
785 | DELAY();
786 | gpio_set(GPIOA, GPIO5);
787 |
788 | recv_data >>= 1;
789 | send_data >>= 1;
790 | if(GPIOA_IDR & GPIO6) //TDO
791 | recv_data |= 0x80;
792 | }
793 | if(sespm_read)
794 | {
795 | if(sespm_bypass)
796 | ring_write_ch(&jtag_out_ring, jtag_data);
797 | else
798 | ring_write_ch(&jtag_out_ring, recv_data);
799 | }
800 |
801 | if (sespm_length == 0)
802 | sespm_state = IDLE;
803 | else
804 | sespm_length --;
805 | break;
806 | }
807 | case TDI_DATA_BIT:
808 | {
809 | uint8_t recv_data = 0;
810 | uint8_t send_data = jtag_data;
811 | int j;
812 | for(j = 0; j <= sespm_length; j++)
813 | {
814 | if(send_data & 0x01)
815 | gpio_set(GPIOA, GPIO7); //TDI
816 | else
817 | gpio_clear(GPIOA, GPIO7);
818 |
819 | gpio_clear(GPIOA, GPIO5); //TCK
820 | DELAY();
821 | gpio_set(GPIOA, GPIO5);
822 |
823 | send_data >>= 1;
824 |
825 | if(GPIOA_IDR & GPIO6) //TDO
826 | recv_data |= (1 << j);
827 | }
828 | if(sespm_read)
829 | {
830 | if(sespm_bypass)
831 | ring_write_ch(&jtag_out_ring, jtag_data);
832 | else
833 | ring_write_ch(&jtag_out_ring, recv_data);
834 | }
835 |
836 | sespm_state = IDLE;
837 | break;
838 | }
839 | case TMS_DATA_BIT:
840 | {
841 | uint8_t recv_data = 0;
842 | uint8_t send_data = jtag_data;
843 | int j;
844 | if(send_data & 0x80)
845 | gpio_set(GPIOA, GPIO7); //TDI
846 | else
847 | gpio_clear(GPIOA, GPIO7);
848 | for(j = 0; j <= sespm_length; j++)
849 | {
850 | if(send_data & 0x01)
851 | gpio_set(GPIOB, GPIO14); //TMS
852 | else
853 | gpio_clear(GPIOB, GPIO14);
854 |
855 | gpio_clear(GPIOA, GPIO5); //TCK
856 | DELAY();
857 | gpio_set(GPIOA, GPIO5);
858 |
859 | send_data >>= 1;
860 |
861 | if(GPIOA_IDR & GPIO6)
862 | recv_data |= (1 << j); //TDO
863 | }
864 | if(sespm_read)
865 | {
866 | if(sespm_bypass)
867 | ring_write_ch(&jtag_out_ring, jtag_data);
868 | else
869 | ring_write_ch(&jtag_out_ring, recv_data);
870 | }
871 |
872 | sespm_state = IDLE;
873 | break;
874 | }
875 | }
876 | }
877 | #endif
878 | #endif
879 | }
880 |
881 |
882 | static void serial_data_rx_cb(usbd_device *usbd_dev, uint8_t ep)
883 | {
884 | (void)ep;
885 | #if SERIAL_IN_SINGLEBUF
886 | serial_recv_len = usbd_ep_read_packet(usbd_dev, 0x04, serial_recv_buf, 64);
887 | if (serial_recv_len)
888 | {
889 | #ifdef UART_SEND_BLOCKING
890 | int i;
891 | for(i = 0; i < serial_recv_len; i++)
892 | usart_send_blocking(USART1, serial_recv_buf[i]);
893 | gpio_set(GPIOB, GPIO2);
894 | #else
895 | usbd_ep_nak_set(usbd_dev, 0x04, 1); //阻塞
896 | serial_recv_i = 0;
897 | //USART_CR1(USART1) |= USART_CR1_TXEIE;//开USART1空发送中断
898 | #endif
899 | }
900 | #else
901 | uint8_t buf[64];
902 | int len = usbd_ep_read_packet(usbd_dev, 0x04, buf, 64);
903 | int remains = ring_remain(&serial_in_ring);
904 |
905 | if(remains - len < 64)
906 | {
907 | usbd_ep_nak_set(usbd_dev, 0x04, 1); //阻塞
908 | }
909 |
910 | if(len)
911 | {
912 | ring_write(&serial_in_ring, buf, len);
913 | //USART_CR1(USART1) |= USART_CR1_TXEIE;//开USART1空发送中断
914 | }
915 | #endif
916 | }
917 |
918 | /* 数据处理结束 */
919 | volatile uint8_t attached = 0;
920 |
921 | static void ec_set_config(usbd_device *usbd_dev, uint16_t wValue)
922 | {
923 | (void)wValue;
924 |
925 |
926 | usbd_register_control_callback(
927 | usbd_dev,
928 | ITDF_SET_REQUEST_TYPE,
929 | ITDF_SET_REQUEST_TYPE,
930 | ec_control_request);
931 |
932 | usbd_ep_setup(usbd_dev, 0x81, USB_ENDPOINT_ATTR_BULK, 64,
933 | NULL);
934 | usbd_ep_setup(usbd_dev, 0x02, USB_ENDPOINT_ATTR_BULK, 64, jtag_data_rx_cb); //JTAG
935 |
936 | usbd_ep_setup(usbd_dev, 0x83, USB_ENDPOINT_ATTR_BULK, 64,
937 | NULL);
938 | usbd_ep_setup(usbd_dev, 0x04, USB_ENDPOINT_ATTR_BULK, 64, serial_data_rx_cb); //Serial
939 |
940 | attached = 1;
941 | }
942 |
943 | static void interrupt_setup(void)
944 | {
945 | asm("cpsid i");
946 | /* 开一个 1ms 的定时器 */
947 | systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8); /* 72MHz / 8 = 9MHz */
948 | /* 定时器每N次中断一次 */
949 | systick_set_reload(8999); /* 9000 / 9000 = 1kHz */
950 | systick_interrupt_enable();
951 | systick_counter_enable();
952 |
953 | nvic_set_priority(NVIC_USART1_IRQ, 0);//串口最高优先级
954 | nvic_set_priority(NVIC_USB_WAKEUP_IRQ, 1 << 4);
955 | nvic_set_priority(NVIC_USB_LP_CAN_RX0_IRQ, 1 << 4);
956 | nvic_set_priority(NVIC_USB_HP_CAN_TX_IRQ, 1 << 4);
957 | nvic_set_priority(NVIC_SYSTICK_IRQ, 2 << 4);//systick最低优先级
958 |
959 | nvic_enable_irq(NVIC_USB_HP_CAN_TX_IRQ);
960 | nvic_enable_irq(NVIC_USB_LP_CAN_RX0_IRQ);
961 | nvic_enable_irq(NVIC_USB_WAKEUP_IRQ);
962 | nvic_enable_irq(NVIC_USART1_IRQ);
963 |
964 |
965 | /* 开接收中断 */
966 | USART_CR1(USART1) |= USART_CR1_RXNEIE;
967 | USART_CR1(USART1) &= ~USART_CR1_TXEIE;
968 |
969 | __asm__("cpsie i");
970 | }
971 |
972 | volatile uint16_t timer_count = 0;
973 | volatile uint16_t last_send = 0;
974 |
975 | void sys_tick_handler(void)
976 | {
977 | timer_count ++;
978 | if(timer_count % 16 == 0)
979 | gpio_clear(GPIOB, GPIO2);
980 | }
981 |
982 |
983 | static void usb_packet_handler(void)
984 | { //防止被USB中断抢占
985 | if(ring_size(&serial_out_ring) > 62 && st_usbfs_ep_in_ready(usbd_dev_handler, 0x83)) //需要接收 (串口)
986 | {
987 | ring_read(&serial_out_ring, bulkout_buf[1] + 2, 62);//读62个byte
988 | //timeout = 0;while(usbd_ep_write_packet(usbd_dev_handler, 0x83, bulkout_buf[1], 64) == 0) {timeout++; if (timeout > 16) break;} //发SESPM
989 | //asm("cpsid i");
990 | usbd_ep_write_packet(usbd_dev_handler, 0x83, bulkout_buf[1], 64);
991 | //asm("cpsie i");
992 | }
993 |
994 | if(ring_size(&jtag_out_ring) > 62 && st_usbfs_ep_in_ready(usbd_dev_handler, 0x81)) //需要接收 (SESPM)
995 | {
996 | ring_read(&jtag_out_ring, bulkout_buf[0] + 2, 62);//读62个byte
997 | //timeout = 0;while(usbd_ep_write_packet(usbd_dev_handler, 0x81, bulkout_buf[1], 64) == 0) {timeout++; if (timeout > 16) break;} //发出去
998 | //asm("cpsid i");
999 | usbd_ep_write_packet(usbd_dev_handler, 0x81, bulkout_buf[0], 64);
1000 | //asm("cpsie i");
1001 | }
1002 |
1003 | if((unsigned)(timer_count - last_send) > latency_timer[0]) //超时
1004 | {
1005 | last_send = timer_count;
1006 | int len;
1007 | if(st_usbfs_ep_in_ready(usbd_dev_handler, 0x81))
1008 | {
1009 | len = ring_read(&jtag_out_ring, bulkout_buf[0] + 2, 62);//读N个byte
1010 | //timeout = 0;while(usbd_ep_write_packet(usbd_dev_handler, 0x81, bulkout_buf[0], 2 + len) == 0) {timeout++; if (timeout > 16) break;} //发SESPM
1011 | //asm("cpsid i");
1012 | usbd_ep_write_packet(usbd_dev_handler, 0x81, bulkout_buf[0], 2 + len);
1013 | //asm("cpsie i");
1014 | }
1015 | if(st_usbfs_ep_in_ready(usbd_dev_handler, 0x83))
1016 | {
1017 | len = ring_read(&serial_out_ring, bulkout_buf[1] + 2, 62);//读N个byte
1018 | //timeout = 0;while(usbd_ep_write_packet(usbd_dev_handler, 0x83, bulkout_buf[1], 2 + len) == 0) {timeout++; if (timeout > 16) break;} //发串口
1019 | //asm("cpsid i");
1020 | usbd_ep_write_packet(usbd_dev_handler, 0x83, bulkout_buf[1], 2 + len);
1021 | //asm("cpsie i");
1022 | }
1023 | }
1024 | }
1025 | /* 串口开始 */
1026 | static void uart_setup(void)
1027 | {
1028 | //启动IO口
1029 | gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
1030 | GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART1_TX);
1031 | gpio_set_mode(GPIOA, GPIO_MODE_INPUT,
1032 | GPIO_CNF_INPUT_FLOAT, GPIO_USART1_RX);
1033 |
1034 | usart_set_baudrate(USART1, 115200);
1035 | usart_set_databits(USART1, 8);
1036 | usart_set_stopbits(USART1, USART_STOPBITS_1);
1037 | usart_set_parity(USART1, USART_PARITY_NONE);
1038 | usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE);
1039 | usart_set_mode(USART1, USART_MODE_TX_RX); //TODO:奇偶校验,stop bit
1040 |
1041 | usart_enable(USART1);
1042 | }
1043 |
1044 | void usart1_isr(void) //串口中断
1045 | {
1046 | if (((USART_SR(USART1) & USART_SR_RXNE) != 0) ||
1047 | ((USART_SR(USART1) & USART_SR_ORE) != 0) ||
1048 | ((USART_SR(USART1) & USART_SR_NE) != 0) ||
1049 | ((USART_SR(USART1) & USART_SR_FE) != 0)) {
1050 | ring_write_ch(&serial_out_ring, USART_DR(USART1) & USART_DR_MASK); //接收
1051 | }
1052 | /* 发送完成中断 */
1053 | #ifndef UART_SEND_BLOCKING
1054 | if (((USART_SR(USART1) & USART_SR_TXE) != 0) && ((USART_CR1(USART1) & USART_CR1_TXEIE) != 0))
1055 | {
1056 | #if SERIAL_IN_SINGLEBUF
1057 | USART_DR(USART1) = serial_recv_buf[serial_recv_i] & USART_DR_MASK;
1058 | serial_recv_i ++;
1059 | if(serial_recv_i >= serial_recv_len)
1060 | {
1061 | usbd_ep_nak_set(usbd_dev_handler, 0x04, 0); //开放USB接收
1062 | USART_CR1(USART1) &= ~USART_CR1_TXEIE;
1063 | }
1064 | #else
1065 | volatile int32_t data = ring_read_ch(&serial_in_ring, NULL);
1066 |
1067 | if (data == -1) { //没有即停止
1068 | USART_CR1(USART1) &= ~USART_CR1_TXEIE;
1069 | usbd_ep_nak_set(usbd_dev_handler, 0x04, 0); //开放USB接收
1070 | } else {
1071 | USART_DR(USART1) = data & USART_DR_MASK; //发送数据
1072 | }
1073 | #endif
1074 | }
1075 | #endif
1076 | gpio_set(GPIOB, GPIO2);
1077 | }
1078 |
1079 | /* 串口结束 */
1080 |
1081 |
1082 | int main(void)
1083 | {
1084 | volatile int i;
1085 |
1086 | clock_setup();
1087 | gpio_setup();
1088 |
1089 | gpio_clear(GPIOA, GPIO8); //关USB上拉
1090 |
1091 | usbd_dev_handler = usbd_init(&st_usbfs_v1_usb_driver, &dev, &config, usb_strings, 2, usbd_control_buffer, sizeof(usbd_control_buffer));
1092 | usbd_register_set_config_callback(usbd_dev_handler, ec_set_config);
1093 |
1094 | ring_init_all(); //开环形缓冲区
1095 | uart_setup();
1096 |
1097 | interrupt_setup();/* 开中断 */
1098 |
1099 | for (i = 0; i < 0x80000; i++)
1100 | __asm__("nop");
1101 | gpio_set(GPIOA, GPIO8);//开USB上拉
1102 |
1103 |
1104 | while(1)
1105 | {
1106 | //usbd_poll(usbd_dev_handler);
1107 | if(attached)
1108 | usb_packet_handler();
1109 | //sespm_process();
1110 | }
1111 |
1112 | return 0;
1113 | }
1114 |
--------------------------------------------------------------------------------
/src/ft2232d.dmp:
--------------------------------------------------------------------------------
1 |
2 | Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
3 | Device Descriptor:
4 | bLength 18
5 | bDescriptorType 1
6 | bcdUSB 2.00
7 | bDeviceClass 9 Hub
8 | bDeviceSubClass 0 Unused
9 | bDeviceProtocol 1 Single TT
10 | bMaxPacketSize0 64
11 | idVendor 0x8087 Intel Corp.
12 | idProduct 0x0024 Integrated Rate Matching Hub
13 | bcdDevice 0.00
14 | iManufacturer 0
15 | iProduct 0
16 | iSerial 0
17 | bNumConfigurations 1
18 | Configuration Descriptor:
19 | bLength 9
20 | bDescriptorType 2
21 | wTotalLength 25
22 | bNumInterfaces 1
23 | bConfigurationValue 1
24 | iConfiguration 0
25 | bmAttributes 0xe0
26 | Self Powered
27 | Remote Wakeup
28 | MaxPower 0mA
29 | Interface Descriptor:
30 | bLength 9
31 | bDescriptorType 4
32 | bInterfaceNumber 0
33 | bAlternateSetting 0
34 | bNumEndpoints 1
35 | bInterfaceClass 9 Hub
36 | bInterfaceSubClass 0 Unused
37 | bInterfaceProtocol 0 Full speed (or root) hub
38 | iInterface 0
39 | Endpoint Descriptor:
40 | bLength 7
41 | bDescriptorType 5
42 | bEndpointAddress 0x81 EP 1 IN
43 | bmAttributes 3
44 | Transfer Type Interrupt
45 | Synch Type None
46 | Usage Type Data
47 | wMaxPacketSize 0x0002 1x 2 bytes
48 | bInterval 12
49 | Hub Descriptor:
50 | bLength 11
51 | bDescriptorType 41
52 | nNbrPorts 8
53 | wHubCharacteristic 0x0009
54 | Per-port power switching
55 | Per-port overcurrent protection
56 | TT think time 8 FS bits
57 | bPwrOn2PwrGood 50 * 2 milli seconds
58 | bHubContrCurrent 0 milli Ampere
59 | DeviceRemovable 0x00 0x00
60 | PortPwrCtrlMask 0xff 0xff
61 | Hub Port Status:
62 | Port 1: 0000.0100 power
63 | Port 2: 0000.0100 power
64 | Port 3: 0000.0100 power
65 | Port 4: 0000.0100 power
66 | Port 5: 0000.0100 power
67 | Port 6: 0000.0100 power
68 | Port 7: 0000.0100 power
69 | Port 8: 0000.0100 power
70 | Device Qualifier (for other device speed):
71 | bLength 10
72 | bDescriptorType 6
73 | bcdUSB 2.00
74 | bDeviceClass 9 Hub
75 | bDeviceSubClass 0 Unused
76 | bDeviceProtocol 0 Full speed (or root) hub
77 | bMaxPacketSize0 64
78 | bNumConfigurations 1
79 | Device Status: 0x0001
80 | Self Powered
81 |
82 | Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
83 | Device Descriptor:
84 | bLength 18
85 | bDescriptorType 1
86 | bcdUSB 2.00
87 | bDeviceClass 9 Hub
88 | bDeviceSubClass 0 Unused
89 | bDeviceProtocol 0 Full speed (or root) hub
90 | bMaxPacketSize0 64
91 | idVendor 0x1d6b Linux Foundation
92 | idProduct 0x0002 2.0 root hub
93 | bcdDevice 4.02
94 | iManufacturer 3 Linux 4.2.0-16-generic ehci_hcd
95 | iProduct 2 EHCI Host Controller
96 | iSerial 1 0000:00:1d.0
97 | bNumConfigurations 1
98 | Configuration Descriptor:
99 | bLength 9
100 | bDescriptorType 2
101 | wTotalLength 25
102 | bNumInterfaces 1
103 | bConfigurationValue 1
104 | iConfiguration 0
105 | bmAttributes 0xe0
106 | Self Powered
107 | Remote Wakeup
108 | MaxPower 0mA
109 | Interface Descriptor:
110 | bLength 9
111 | bDescriptorType 4
112 | bInterfaceNumber 0
113 | bAlternateSetting 0
114 | bNumEndpoints 1
115 | bInterfaceClass 9 Hub
116 | bInterfaceSubClass 0 Unused
117 | bInterfaceProtocol 0 Full speed (or root) hub
118 | iInterface 0
119 | Endpoint Descriptor:
120 | bLength 7
121 | bDescriptorType 5
122 | bEndpointAddress 0x81 EP 1 IN
123 | bmAttributes 3
124 | Transfer Type Interrupt
125 | Synch Type None
126 | Usage Type Data
127 | wMaxPacketSize 0x0004 1x 4 bytes
128 | bInterval 12
129 | Hub Descriptor:
130 | bLength 9
131 | bDescriptorType 41
132 | nNbrPorts 3
133 | wHubCharacteristic 0x000a
134 | No power switching (usb 1.0)
135 | Per-port overcurrent protection
136 | bPwrOn2PwrGood 10 * 2 milli seconds
137 | bHubContrCurrent 0 milli Ampere
138 | DeviceRemovable 0x02
139 | PortPwrCtrlMask 0xff
140 | Hub Port Status:
141 | Port 1: 0000.0507 highspeed power suspend enable connect
142 | Port 2: 0000.0100 power
143 | Port 3: 0000.0100 power
144 | Device Status: 0x0001
145 | Self Powered
146 |
147 | Bus 003 Device 006: ID 04f2:b2ea Chicony Electronics Co., Ltd Integrated Camera [ThinkPad]
148 | Device Descriptor:
149 | bLength 18
150 | bDescriptorType 1
151 | bcdUSB 2.00
152 | bDeviceClass 239 Miscellaneous Device
153 | bDeviceSubClass 2 ?
154 | bDeviceProtocol 1 Interface Association
155 | bMaxPacketSize0 64
156 | idVendor 0x04f2 Chicony Electronics Co., Ltd
157 | idProduct 0xb2ea Integrated Camera [ThinkPad]
158 | bcdDevice 5.18
159 | iManufacturer 1 Chicony Electronics Co., Ltd.
160 | iProduct 2 Integrated Camera
161 | iSerial 0
162 | bNumConfigurations 1
163 | Configuration Descriptor:
164 | bLength 9
165 | bDescriptorType 2
166 | wTotalLength 794
167 | bNumInterfaces 2
168 | bConfigurationValue 1
169 | iConfiguration 0
170 | bmAttributes 0x80
171 | (Bus Powered)
172 | MaxPower 200mA
173 | Interface Association:
174 | bLength 8
175 | bDescriptorType 11
176 | bFirstInterface 0
177 | bInterfaceCount 2
178 | bFunctionClass 14 Video
179 | bFunctionSubClass 3 Video Interface Collection
180 | bFunctionProtocol 0
181 | iFunction 4 Integrated Camera
182 | Interface Descriptor:
183 | bLength 9
184 | bDescriptorType 4
185 | bInterfaceNumber 0
186 | bAlternateSetting 0
187 | bNumEndpoints 1
188 | bInterfaceClass 14 Video
189 | bInterfaceSubClass 1 Video Control
190 | bInterfaceProtocol 0
191 | iInterface 4 Integrated Camera
192 | VideoControl Interface Descriptor:
193 | bLength 13
194 | bDescriptorType 36
195 | bDescriptorSubtype 1 (HEADER)
196 | bcdUVC 1.00
197 | wTotalLength 104
198 | dwClockFrequency 30.000000MHz
199 | bInCollection 1
200 | baInterfaceNr( 0) 1
201 | VideoControl Interface Descriptor:
202 | bLength 18
203 | bDescriptorType 36
204 | bDescriptorSubtype 2 (INPUT_TERMINAL)
205 | bTerminalID 1
206 | wTerminalType 0x0201 Camera Sensor
207 | bAssocTerminal 5
208 | iTerminal 0
209 | wObjectiveFocalLengthMin 0
210 | wObjectiveFocalLengthMax 0
211 | wOcularFocalLength 0
212 | bControlSize 3
213 | bmControls 0x00040a0e
214 | Auto-Exposure Mode
215 | Auto-Exposure Priority
216 | Exposure Time (Absolute)
217 | Zoom (Absolute)
218 | PanTilt (Absolute)
219 | Privacy
220 | VideoControl Interface Descriptor:
221 | bLength 11
222 | bDescriptorType 36
223 | bDescriptorSubtype 5 (PROCESSING_UNIT)
224 | Warning: Descriptor too short
225 | bUnitID 2
226 | bSourceID 1
227 | wMaxMultiplier 0
228 | bControlSize 2
229 | bmControls 0x0000157f
230 | Brightness
231 | Contrast
232 | Hue
233 | Saturation
234 | Sharpness
235 | Gamma
236 | White Balance Temperature
237 | Backlight Compensation
238 | Power Line Frequency
239 | White Balance Temperature, Auto
240 | iProcessing 0
241 | bmVideoStandards 0x1b
242 | None
243 | NTSC - 525/60
244 | SECAM - 625/50
245 | NTSC - 625/50
246 | VideoControl Interface Descriptor:
247 | bLength 27
248 | bDescriptorType 36
249 | bDescriptorSubtype 6 (EXTENSION_UNIT)
250 | bUnitID 3
251 | guidExtensionCode {0a3e1874-8254-1a48-b402-48b8b8c49cc8}
252 | bNumControl 12
253 | bNrPins 1
254 | baSourceID( 0) 2
255 | bControlSize 2
256 | bmControls( 0) 0xff
257 | bmControls( 1) 0x0f
258 | iExtension 0
259 | VideoControl Interface Descriptor:
260 | bLength 26
261 | bDescriptorType 36
262 | bDescriptorSubtype 6 (EXTENSION_UNIT)
263 | bUnitID 4
264 | guidExtensionCode {ed2a1c0b-f739-d145-8100-fbcfac7ace06}
265 | bNumControl 6
266 | bNrPins 1
267 | baSourceID( 0) 3
268 | bControlSize 1
269 | bmControls( 0) 0x3f
270 | iExtension 0
271 | VideoControl Interface Descriptor:
272 | bLength 9
273 | bDescriptorType 36
274 | bDescriptorSubtype 3 (OUTPUT_TERMINAL)
275 | bTerminalID 5
276 | wTerminalType 0x0101 USB Streaming
277 | bAssocTerminal 0
278 | bSourceID 4
279 | iTerminal 0
280 | Endpoint Descriptor:
281 | bLength 7
282 | bDescriptorType 5
283 | bEndpointAddress 0x81 EP 1 IN
284 | bmAttributes 3
285 | Transfer Type Interrupt
286 | Synch Type None
287 | Usage Type Data
288 | wMaxPacketSize 0x0010 1x 16 bytes
289 | bInterval 8
290 | Interface Descriptor:
291 | bLength 9
292 | bDescriptorType 4
293 | bInterfaceNumber 1
294 | bAlternateSetting 0
295 | bNumEndpoints 0
296 | bInterfaceClass 14 Video
297 | bInterfaceSubClass 2 Video Streaming
298 | bInterfaceProtocol 0
299 | iInterface 0
300 | VideoStreaming Interface Descriptor:
301 | bLength 15
302 | bDescriptorType 36
303 | bDescriptorSubtype 1 (INPUT_HEADER)
304 | bNumFormats 2
305 | wTotalLength 563
306 | bEndPointAddress 130
307 | bmInfo 1
308 | bTerminalLink 5
309 | bStillCaptureMethod 1
310 | bTriggerSupport 0
311 | bTriggerUsage 0
312 | bControlSize 1
313 | bmaControls( 0) 27
314 | bmaControls( 1) 27
315 | VideoStreaming Interface Descriptor:
316 | bLength 27
317 | bDescriptorType 36
318 | bDescriptorSubtype 4 (FORMAT_UNCOMPRESSED)
319 | bFormatIndex 1
320 | bNumFrameDescriptors 8
321 | guidFormat {59555932-0000-1000-8000-00aa00389b71}
322 | bBitsPerPixel 16
323 | bDefaultFrameIndex 1
324 | bAspectRatioX 0
325 | bAspectRatioY 0
326 | bmInterlaceFlags 0x02
327 | Interlaced stream or variable: No
328 | Fields per frame: 1 fields
329 | Field 1 first: No
330 | Field pattern: Field 1 only
331 | bCopyProtect 0
332 | VideoStreaming Interface Descriptor:
333 | bLength 34
334 | bDescriptorType 36
335 | bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
336 | bFrameIndex 1
337 | bmCapabilities 0x01
338 | Still image supported
339 | wWidth 640
340 | wHeight 480
341 | dwMinBitRate 73728000
342 | dwMaxBitRate 147456000
343 | dwMaxVideoFrameBufferSize 614400
344 | dwDefaultFrameInterval 333333
345 | bFrameIntervalType 2
346 | dwFrameInterval( 0) 333333
347 | dwFrameInterval( 1) 666666
348 | VideoStreaming Interface Descriptor:
349 | bLength 34
350 | bDescriptorType 36
351 | bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
352 | bFrameIndex 2
353 | bmCapabilities 0x01
354 | Still image supported
355 | wWidth 640
356 | wHeight 360
357 | dwMinBitRate 55296000
358 | dwMaxBitRate 110592000
359 | dwMaxVideoFrameBufferSize 460800
360 | dwDefaultFrameInterval 333333
361 | bFrameIntervalType 2
362 | dwFrameInterval( 0) 333333
363 | dwFrameInterval( 1) 666666
364 | VideoStreaming Interface Descriptor:
365 | bLength 34
366 | bDescriptorType 36
367 | bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
368 | bFrameIndex 3
369 | bmCapabilities 0x01
370 | Still image supported
371 | wWidth 352
372 | wHeight 288
373 | dwMinBitRate 24330240
374 | dwMaxBitRate 48660480
375 | dwMaxVideoFrameBufferSize 202752
376 | dwDefaultFrameInterval 333333
377 | bFrameIntervalType 2
378 | dwFrameInterval( 0) 333333
379 | dwFrameInterval( 1) 666666
380 | VideoStreaming Interface Descriptor:
381 | bLength 34
382 | bDescriptorType 36
383 | bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
384 | bFrameIndex 4
385 | bmCapabilities 0x01
386 | Still image supported
387 | wWidth 320
388 | wHeight 240
389 | dwMinBitRate 18432000
390 | dwMaxBitRate 36864000
391 | dwMaxVideoFrameBufferSize 153600
392 | dwDefaultFrameInterval 333333
393 | bFrameIntervalType 2
394 | dwFrameInterval( 0) 333333
395 | dwFrameInterval( 1) 666666
396 | VideoStreaming Interface Descriptor:
397 | bLength 30
398 | bDescriptorType 36
399 | bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
400 | bFrameIndex 5
401 | bmCapabilities 0x01
402 | Still image supported
403 | wWidth 800
404 | wHeight 448
405 | dwMinBitRate 86016000
406 | dwMaxBitRate 86016000
407 | dwMaxVideoFrameBufferSize 716800
408 | dwDefaultFrameInterval 666666
409 | bFrameIntervalType 1
410 | dwFrameInterval( 0) 666666
411 | VideoStreaming Interface Descriptor:
412 | bLength 30
413 | bDescriptorType 36
414 | bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
415 | bFrameIndex 6
416 | bmCapabilities 0x01
417 | Still image supported
418 | wWidth 960
419 | wHeight 540
420 | dwMinBitRate 82944000
421 | dwMaxBitRate 82944000
422 | dwMaxVideoFrameBufferSize 1036800
423 | dwDefaultFrameInterval 1000000
424 | bFrameIntervalType 1
425 | dwFrameInterval( 0) 1000000
426 | VideoStreaming Interface Descriptor:
427 | bLength 30
428 | bDescriptorType 36
429 | bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
430 | bFrameIndex 7
431 | bmCapabilities 0x01
432 | Still image supported
433 | wWidth 1280
434 | wHeight 720
435 | dwMinBitRate 147456000
436 | dwMaxBitRate 147456000
437 | dwMaxVideoFrameBufferSize 1843200
438 | dwDefaultFrameInterval 1000000
439 | bFrameIntervalType 1
440 | dwFrameInterval( 0) 1000000
441 | VideoStreaming Interface Descriptor:
442 | bLength 34
443 | bDescriptorType 36
444 | bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
445 | bFrameIndex 8
446 | bmCapabilities 0x01
447 | Still image supported
448 | wWidth 424
449 | wHeight 240
450 | dwMinBitRate 24422400
451 | dwMaxBitRate 48844800
452 | dwMaxVideoFrameBufferSize 203520
453 | dwDefaultFrameInterval 333333
454 | bFrameIntervalType 2
455 | dwFrameInterval( 0) 333333
456 | dwFrameInterval( 1) 666666
457 | VideoStreaming Interface Descriptor:
458 | bLength 6
459 | bDescriptorType 36
460 | bDescriptorSubtype 13 (COLORFORMAT)
461 | bColorPrimaries 1 (BT.709,sRGB)
462 | bTransferCharacteristics 1 (BT.709)
463 | bMatrixCoefficients 4 (SMPTE 170M (BT.601))
464 | VideoStreaming Interface Descriptor:
465 | bLength 11
466 | bDescriptorType 36
467 | bDescriptorSubtype 6 (FORMAT_MJPEG)
468 | bFormatIndex 2
469 | bNumFrameDescriptors 7
470 | bFlags 0
471 | Fixed-size samples: No
472 | bDefaultFrameIndex 1
473 | bAspectRatioX 0
474 | bAspectRatioY 0
475 | bmInterlaceFlags 0x02
476 | Interlaced stream or variable: No
477 | Fields per frame: 2 fields
478 | Field 1 first: No
479 | Field pattern: Field 1 only
480 | bCopyProtect 0
481 | VideoStreaming Interface Descriptor:
482 | bLength 34
483 | bDescriptorType 36
484 | bDescriptorSubtype 7 (FRAME_MJPEG)
485 | bFrameIndex 1
486 | bmCapabilities 0x01
487 | Still image supported
488 | wWidth 640
489 | wHeight 480
490 | dwMinBitRate 110592000
491 | dwMaxBitRate 221184000
492 | dwMaxVideoFrameBufferSize 921600
493 | dwDefaultFrameInterval 333333
494 | bFrameIntervalType 2
495 | dwFrameInterval( 0) 333333
496 | dwFrameInterval( 1) 666666
497 | VideoStreaming Interface Descriptor:
498 | bLength 34
499 | bDescriptorType 36
500 | bDescriptorSubtype 7 (FRAME_MJPEG)
501 | bFrameIndex 2
502 | bmCapabilities 0x01
503 | Still image supported
504 | wWidth 640
505 | wHeight 360
506 | dwMinBitRate 82944000
507 | dwMaxBitRate 165888000
508 | dwMaxVideoFrameBufferSize 691200
509 | dwDefaultFrameInterval 333333
510 | bFrameIntervalType 2
511 | dwFrameInterval( 0) 333333
512 | dwFrameInterval( 1) 666666
513 | VideoStreaming Interface Descriptor:
514 | bLength 34
515 | bDescriptorType 36
516 | bDescriptorSubtype 7 (FRAME_MJPEG)
517 | bFrameIndex 3
518 | bmCapabilities 0x01
519 | Still image supported
520 | wWidth 352
521 | wHeight 288
522 | dwMinBitRate 36495360
523 | dwMaxBitRate 72990720
524 | dwMaxVideoFrameBufferSize 304128
525 | dwDefaultFrameInterval 333333
526 | bFrameIntervalType 2
527 | dwFrameInterval( 0) 333333
528 | dwFrameInterval( 1) 666666
529 | VideoStreaming Interface Descriptor:
530 | bLength 34
531 | bDescriptorType 36
532 | bDescriptorSubtype 7 (FRAME_MJPEG)
533 | bFrameIndex 4
534 | bmCapabilities 0x01
535 | Still image supported
536 | wWidth 320
537 | wHeight 240
538 | dwMinBitRate 27648000
539 | dwMaxBitRate 55296000
540 | dwMaxVideoFrameBufferSize 230400
541 | dwDefaultFrameInterval 333333
542 | bFrameIntervalType 2
543 | dwFrameInterval( 0) 333333
544 | dwFrameInterval( 1) 666666
545 | VideoStreaming Interface Descriptor:
546 | bLength 34
547 | bDescriptorType 36
548 | bDescriptorSubtype 7 (FRAME_MJPEG)
549 | bFrameIndex 5
550 | bmCapabilities 0x01
551 | Still image supported
552 | wWidth 800
553 | wHeight 448
554 | dwMinBitRate 129024000
555 | dwMaxBitRate 258048000
556 | dwMaxVideoFrameBufferSize 1075200
557 | dwDefaultFrameInterval 333333
558 | bFrameIntervalType 2
559 | dwFrameInterval( 0) 333333
560 | dwFrameInterval( 1) 666666
561 | VideoStreaming Interface Descriptor:
562 | bLength 34
563 | bDescriptorType 36
564 | bDescriptorSubtype 7 (FRAME_MJPEG)
565 | bFrameIndex 6
566 | bmCapabilities 0x01
567 | Still image supported
568 | wWidth 960
569 | wHeight 540
570 | dwMinBitRate 186624000
571 | dwMaxBitRate 373248000
572 | dwMaxVideoFrameBufferSize 1555200
573 | dwDefaultFrameInterval 333333
574 | bFrameIntervalType 2
575 | dwFrameInterval( 0) 333333
576 | dwFrameInterval( 1) 666666
577 | VideoStreaming Interface Descriptor:
578 | bLength 34
579 | bDescriptorType 36
580 | bDescriptorSubtype 7 (FRAME_MJPEG)
581 | bFrameIndex 7
582 | bmCapabilities 0x01
583 | Still image supported
584 | wWidth 1280
585 | wHeight 720
586 | dwMinBitRate 331776000
587 | dwMaxBitRate 663552000
588 | dwMaxVideoFrameBufferSize 2764800
589 | dwDefaultFrameInterval 333333
590 | bFrameIntervalType 2
591 | dwFrameInterval( 0) 333333
592 | dwFrameInterval( 1) 666666
593 | VideoStreaming Interface Descriptor:
594 | bLength 6
595 | bDescriptorType 36
596 | bDescriptorSubtype 13 (COLORFORMAT)
597 | bColorPrimaries 1 (BT.709,sRGB)
598 | bTransferCharacteristics 1 (BT.709)
599 | bMatrixCoefficients 4 (SMPTE 170M (BT.601))
600 | Interface Descriptor:
601 | bLength 9
602 | bDescriptorType 4
603 | bInterfaceNumber 1
604 | bAlternateSetting 1
605 | bNumEndpoints 1
606 | bInterfaceClass 14 Video
607 | bInterfaceSubClass 2 Video Streaming
608 | bInterfaceProtocol 0
609 | iInterface 0
610 | Endpoint Descriptor:
611 | bLength 7
612 | bDescriptorType 5
613 | bEndpointAddress 0x82 EP 2 IN
614 | bmAttributes 5
615 | Transfer Type Isochronous
616 | Synch Type Asynchronous
617 | Usage Type Data
618 | wMaxPacketSize 0x0b5c 2x 860 bytes
619 | bInterval 1
620 | Interface Descriptor:
621 | bLength 9
622 | bDescriptorType 4
623 | bInterfaceNumber 1
624 | bAlternateSetting 2
625 | bNumEndpoints 1
626 | bInterfaceClass 14 Video
627 | bInterfaceSubClass 2 Video Streaming
628 | bInterfaceProtocol 0
629 | iInterface 0
630 | Endpoint Descriptor:
631 | bLength 7
632 | bDescriptorType 5
633 | bEndpointAddress 0x82 EP 2 IN
634 | bmAttributes 5
635 | Transfer Type Isochronous
636 | Synch Type Asynchronous
637 | Usage Type Data
638 | wMaxPacketSize 0x135c 3x 860 bytes
639 | bInterval 1
640 | Interface Descriptor:
641 | bLength 9
642 | bDescriptorType 4
643 | bInterfaceNumber 1
644 | bAlternateSetting 3
645 | bNumEndpoints 1
646 | bInterfaceClass 14 Video
647 | bInterfaceSubClass 2 Video Streaming
648 | bInterfaceProtocol 0
649 | iInterface 0
650 | Endpoint Descriptor:
651 | bLength 7
652 | bDescriptorType 5
653 | bEndpointAddress 0x82 EP 2 IN
654 | bmAttributes 5
655 | Transfer Type Isochronous
656 | Synch Type Asynchronous
657 | Usage Type Data
658 | wMaxPacketSize 0x13c0 3x 960 bytes
659 | bInterval 1
660 | Interface Descriptor:
661 | bLength 9
662 | bDescriptorType 4
663 | bInterfaceNumber 1
664 | bAlternateSetting 4
665 | bNumEndpoints 1
666 | bInterfaceClass 14 Video
667 | bInterfaceSubClass 2 Video Streaming
668 | bInterfaceProtocol 0
669 | iInterface 0
670 | Endpoint Descriptor:
671 | bLength 7
672 | bDescriptorType 5
673 | bEndpointAddress 0x82 EP 2 IN
674 | bmAttributes 5
675 | Transfer Type Isochronous
676 | Synch Type Asynchronous
677 | Usage Type Data
678 | wMaxPacketSize 0x13fc 3x 1020 bytes
679 | bInterval 1
680 | Interface Descriptor:
681 | bLength 9
682 | bDescriptorType 4
683 | bInterfaceNumber 1
684 | bAlternateSetting 5
685 | bNumEndpoints 1
686 | bInterfaceClass 14 Video
687 | bInterfaceSubClass 2 Video Streaming
688 | bInterfaceProtocol 0
689 | iInterface 0
690 | Endpoint Descriptor:
691 | bLength 7
692 | bDescriptorType 5
693 | bEndpointAddress 0x82 EP 2 IN
694 | bmAttributes 5
695 | Transfer Type Isochronous
696 | Synch Type Asynchronous
697 | Usage Type Data
698 | wMaxPacketSize 0x1400 3x 1024 bytes
699 | bInterval 1
700 | Device Qualifier (for other device speed):
701 | bLength 10
702 | bDescriptorType 6
703 | bcdUSB 2.00
704 | bDeviceClass 239 Miscellaneous Device
705 | bDeviceSubClass 2 ?
706 | bDeviceProtocol 1 Interface Association
707 | bMaxPacketSize0 64
708 | bNumConfigurations 1
709 | Device Status: 0x0000
710 | (Bus Powered)
711 |
712 | Bus 003 Device 005: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad]
713 | Device Descriptor:
714 | bLength 18
715 | bDescriptorType 1
716 | bcdUSB 2.00
717 | bDeviceClass 255 Vendor Specific Class
718 | bDeviceSubClass 1
719 | bDeviceProtocol 1
720 | bMaxPacketSize0 64
721 | idVendor 0x0a5c Broadcom Corp.
722 | idProduct 0x21e6 BCM20702 Bluetooth 4.0 [ThinkPad]
723 | bcdDevice 1.12
724 | iManufacturer 1 Broadcom Corp
725 | iProduct 2 BCM20702A0
726 | iSerial 3 083E8EE33412
727 | bNumConfigurations 1
728 | Configuration Descriptor:
729 | bLength 9
730 | bDescriptorType 2
731 | wTotalLength 218
732 | bNumInterfaces 4
733 | bConfigurationValue 1
734 | iConfiguration 0
735 | bmAttributes 0xe0
736 | Self Powered
737 | Remote Wakeup
738 | MaxPower 0mA
739 | Interface Descriptor:
740 | bLength 9
741 | bDescriptorType 4
742 | bInterfaceNumber 0
743 | bAlternateSetting 0
744 | bNumEndpoints 3
745 | bInterfaceClass 255 Vendor Specific Class
746 | bInterfaceSubClass 1
747 | bInterfaceProtocol 1
748 | iInterface 0
749 | Endpoint Descriptor:
750 | bLength 7
751 | bDescriptorType 5
752 | bEndpointAddress 0x81 EP 1 IN
753 | bmAttributes 3
754 | Transfer Type Interrupt
755 | Synch Type None
756 | Usage Type Data
757 | wMaxPacketSize 0x0010 1x 16 bytes
758 | bInterval 1
759 | Endpoint Descriptor:
760 | bLength 7
761 | bDescriptorType 5
762 | bEndpointAddress 0x82 EP 2 IN
763 | bmAttributes 2
764 | Transfer Type Bulk
765 | Synch Type None
766 | Usage Type Data
767 | wMaxPacketSize 0x0040 1x 64 bytes
768 | bInterval 1
769 | Endpoint Descriptor:
770 | bLength 7
771 | bDescriptorType 5
772 | bEndpointAddress 0x02 EP 2 OUT
773 | bmAttributes 2
774 | Transfer Type Bulk
775 | Synch Type None
776 | Usage Type Data
777 | wMaxPacketSize 0x0040 1x 64 bytes
778 | bInterval 1
779 | Interface Descriptor:
780 | bLength 9
781 | bDescriptorType 4
782 | bInterfaceNumber 1
783 | bAlternateSetting 0
784 | bNumEndpoints 2
785 | bInterfaceClass 255 Vendor Specific Class
786 | bInterfaceSubClass 1
787 | bInterfaceProtocol 1
788 | iInterface 0
789 | Endpoint Descriptor:
790 | bLength 7
791 | bDescriptorType 5
792 | bEndpointAddress 0x83 EP 3 IN
793 | bmAttributes 1
794 | Transfer Type Isochronous
795 | Synch Type None
796 | Usage Type Data
797 | wMaxPacketSize 0x0000 1x 0 bytes
798 | bInterval 1
799 | Endpoint Descriptor:
800 | bLength 7
801 | bDescriptorType 5
802 | bEndpointAddress 0x03 EP 3 OUT
803 | bmAttributes 1
804 | Transfer Type Isochronous
805 | Synch Type None
806 | Usage Type Data
807 | wMaxPacketSize 0x0000 1x 0 bytes
808 | bInterval 1
809 | Interface Descriptor:
810 | bLength 9
811 | bDescriptorType 4
812 | bInterfaceNumber 1
813 | bAlternateSetting 1
814 | bNumEndpoints 2
815 | bInterfaceClass 255 Vendor Specific Class
816 | bInterfaceSubClass 1
817 | bInterfaceProtocol 1
818 | iInterface 0
819 | Endpoint Descriptor:
820 | bLength 7
821 | bDescriptorType 5
822 | bEndpointAddress 0x83 EP 3 IN
823 | bmAttributes 1
824 | Transfer Type Isochronous
825 | Synch Type None
826 | Usage Type Data
827 | wMaxPacketSize 0x0009 1x 9 bytes
828 | bInterval 1
829 | Endpoint Descriptor:
830 | bLength 7
831 | bDescriptorType 5
832 | bEndpointAddress 0x03 EP 3 OUT
833 | bmAttributes 1
834 | Transfer Type Isochronous
835 | Synch Type None
836 | Usage Type Data
837 | wMaxPacketSize 0x0009 1x 9 bytes
838 | bInterval 1
839 | Interface Descriptor:
840 | bLength 9
841 | bDescriptorType 4
842 | bInterfaceNumber 1
843 | bAlternateSetting 2
844 | bNumEndpoints 2
845 | bInterfaceClass 255 Vendor Specific Class
846 | bInterfaceSubClass 1
847 | bInterfaceProtocol 1
848 | iInterface 0
849 | Endpoint Descriptor:
850 | bLength 7
851 | bDescriptorType 5
852 | bEndpointAddress 0x83 EP 3 IN
853 | bmAttributes 1
854 | Transfer Type Isochronous
855 | Synch Type None
856 | Usage Type Data
857 | wMaxPacketSize 0x0011 1x 17 bytes
858 | bInterval 1
859 | Endpoint Descriptor:
860 | bLength 7
861 | bDescriptorType 5
862 | bEndpointAddress 0x03 EP 3 OUT
863 | bmAttributes 1
864 | Transfer Type Isochronous
865 | Synch Type None
866 | Usage Type Data
867 | wMaxPacketSize 0x0011 1x 17 bytes
868 | bInterval 1
869 | Interface Descriptor:
870 | bLength 9
871 | bDescriptorType 4
872 | bInterfaceNumber 1
873 | bAlternateSetting 3
874 | bNumEndpoints 2
875 | bInterfaceClass 255 Vendor Specific Class
876 | bInterfaceSubClass 1
877 | bInterfaceProtocol 1
878 | iInterface 0
879 | Endpoint Descriptor:
880 | bLength 7
881 | bDescriptorType 5
882 | bEndpointAddress 0x83 EP 3 IN
883 | bmAttributes 1
884 | Transfer Type Isochronous
885 | Synch Type None
886 | Usage Type Data
887 | wMaxPacketSize 0x0019 1x 25 bytes
888 | bInterval 1
889 | Endpoint Descriptor:
890 | bLength 7
891 | bDescriptorType 5
892 | bEndpointAddress 0x03 EP 3 OUT
893 | bmAttributes 1
894 | Transfer Type Isochronous
895 | Synch Type None
896 | Usage Type Data
897 | wMaxPacketSize 0x0019 1x 25 bytes
898 | bInterval 1
899 | Interface Descriptor:
900 | bLength 9
901 | bDescriptorType 4
902 | bInterfaceNumber 1
903 | bAlternateSetting 4
904 | bNumEndpoints 2
905 | bInterfaceClass 255 Vendor Specific Class
906 | bInterfaceSubClass 1
907 | bInterfaceProtocol 1
908 | iInterface 0
909 | Endpoint Descriptor:
910 | bLength 7
911 | bDescriptorType 5
912 | bEndpointAddress 0x83 EP 3 IN
913 | bmAttributes 1
914 | Transfer Type Isochronous
915 | Synch Type None
916 | Usage Type Data
917 | wMaxPacketSize 0x0021 1x 33 bytes
918 | bInterval 1
919 | Endpoint Descriptor:
920 | bLength 7
921 | bDescriptorType 5
922 | bEndpointAddress 0x03 EP 3 OUT
923 | bmAttributes 1
924 | Transfer Type Isochronous
925 | Synch Type None
926 | Usage Type Data
927 | wMaxPacketSize 0x0021 1x 33 bytes
928 | bInterval 1
929 | Interface Descriptor:
930 | bLength 9
931 | bDescriptorType 4
932 | bInterfaceNumber 1
933 | bAlternateSetting 5
934 | bNumEndpoints 2
935 | bInterfaceClass 255 Vendor Specific Class
936 | bInterfaceSubClass 1
937 | bInterfaceProtocol 1
938 | iInterface 0
939 | Endpoint Descriptor:
940 | bLength 7
941 | bDescriptorType 5
942 | bEndpointAddress 0x83 EP 3 IN
943 | bmAttributes 1
944 | Transfer Type Isochronous
945 | Synch Type None
946 | Usage Type Data
947 | wMaxPacketSize 0x0031 1x 49 bytes
948 | bInterval 1
949 | Endpoint Descriptor:
950 | bLength 7
951 | bDescriptorType 5
952 | bEndpointAddress 0x03 EP 3 OUT
953 | bmAttributes 1
954 | Transfer Type Isochronous
955 | Synch Type None
956 | Usage Type Data
957 | wMaxPacketSize 0x0031 1x 49 bytes
958 | bInterval 1
959 | Interface Descriptor:
960 | bLength 9
961 | bDescriptorType 4
962 | bInterfaceNumber 2
963 | bAlternateSetting 0
964 | bNumEndpoints 2
965 | bInterfaceClass 255 Vendor Specific Class
966 | bInterfaceSubClass 255 Vendor Specific Subclass
967 | bInterfaceProtocol 255 Vendor Specific Protocol
968 | iInterface 0
969 | Endpoint Descriptor:
970 | bLength 7
971 | bDescriptorType 5
972 | bEndpointAddress 0x84 EP 4 IN
973 | bmAttributes 2
974 | Transfer Type Bulk
975 | Synch Type None
976 | Usage Type Data
977 | wMaxPacketSize 0x0020 1x 32 bytes
978 | bInterval 1
979 | Endpoint Descriptor:
980 | bLength 7
981 | bDescriptorType 5
982 | bEndpointAddress 0x04 EP 4 OUT
983 | bmAttributes 2
984 | Transfer Type Bulk
985 | Synch Type None
986 | Usage Type Data
987 | wMaxPacketSize 0x0020 1x 32 bytes
988 | bInterval 1
989 | Interface Descriptor:
990 | bLength 9
991 | bDescriptorType 4
992 | bInterfaceNumber 3
993 | bAlternateSetting 0
994 | bNumEndpoints 0
995 | bInterfaceClass 254 Application Specific Interface
996 | bInterfaceSubClass 1 Device Firmware Update
997 | bInterfaceProtocol 1
998 | iInterface 0
999 | Device Firmware Upgrade Interface Descriptor:
1000 | bLength 9
1001 | bDescriptorType 33
1002 | bmAttributes 5
1003 | Will Not Detach
1004 | Manifestation Tolerant
1005 | Upload Unsupported
1006 | Download Supported
1007 | wDetachTimeout 5000 milliseconds
1008 | wTransferSize 64 bytes
1009 | bcdDFUVersion 1.10
1010 | Device Status: 0x0001
1011 | Self Powered
1012 |
1013 | Bus 003 Device 004: ID 147e:2020 Upek TouchChip Fingerprint Coprocessor (WBF advanced mode)
1014 | Device Descriptor:
1015 | bLength 18
1016 | bDescriptorType 1
1017 | bcdUSB 1.10
1018 | bDeviceClass 0 (Defined at Interface level)
1019 | bDeviceSubClass 0
1020 | bDeviceProtocol 0
1021 | bMaxPacketSize0 8
1022 | idVendor 0x147e Upek
1023 | idProduct 0x2020 TouchChip Fingerprint Coprocessor (WBF advanced mode)
1024 | bcdDevice 0.01
1025 | iManufacturer 1 Auth
1026 | iProduct 2 Biometric Coprocessor
1027 | iSerial 0
1028 | bNumConfigurations 1
1029 | Configuration Descriptor:
1030 | bLength 9
1031 | bDescriptorType 2
1032 | wTotalLength 39
1033 | bNumInterfaces 1
1034 | bConfigurationValue 1
1035 | iConfiguration 0
1036 | bmAttributes 0xa0
1037 | (Bus Powered)
1038 | Remote Wakeup
1039 | MaxPower 100mA
1040 | Interface Descriptor:
1041 | bLength 9
1042 | bDescriptorType 4
1043 | bInterfaceNumber 0
1044 | bAlternateSetting 0
1045 | bNumEndpoints 3
1046 | bInterfaceClass 255 Vendor Specific Class
1047 | bInterfaceSubClass 0
1048 | bInterfaceProtocol 0
1049 | iInterface 0
1050 | Endpoint Descriptor:
1051 | bLength 7
1052 | bDescriptorType 5
1053 | bEndpointAddress 0x81 EP 1 IN
1054 | bmAttributes 2
1055 | Transfer Type Bulk
1056 | Synch Type None
1057 | Usage Type Data
1058 | wMaxPacketSize 0x0040 1x 64 bytes
1059 | bInterval 0
1060 | Endpoint Descriptor:
1061 | bLength 7
1062 | bDescriptorType 5
1063 | bEndpointAddress 0x02 EP 2 OUT
1064 | bmAttributes 2
1065 | Transfer Type Bulk
1066 | Synch Type None
1067 | Usage Type Data
1068 | wMaxPacketSize 0x0040 1x 64 bytes
1069 | bInterval 0
1070 | Endpoint Descriptor:
1071 | bLength 7
1072 | bDescriptorType 5
1073 | bEndpointAddress 0x83 EP 3 IN
1074 | bmAttributes 3
1075 | Transfer Type Interrupt
1076 | Synch Type None
1077 | Usage Type Data
1078 | wMaxPacketSize 0x0004 1x 4 bytes
1079 | bInterval 20
1080 | Device Status: 0x0000
1081 | (Bus Powered)
1082 |
1083 | Bus 003 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
1084 | Device Descriptor:
1085 | bLength 18
1086 | bDescriptorType 1
1087 | bcdUSB 2.00
1088 | bDeviceClass 9 Hub
1089 | bDeviceSubClass 0 Unused
1090 | bDeviceProtocol 1 Single TT
1091 | bMaxPacketSize0 64
1092 | idVendor 0x8087 Intel Corp.
1093 | idProduct 0x0024 Integrated Rate Matching Hub
1094 | bcdDevice 0.00
1095 | iManufacturer 0
1096 | iProduct 0
1097 | iSerial 0
1098 | bNumConfigurations 1
1099 | Configuration Descriptor:
1100 | bLength 9
1101 | bDescriptorType 2
1102 | wTotalLength 25
1103 | bNumInterfaces 1
1104 | bConfigurationValue 1
1105 | iConfiguration 0
1106 | bmAttributes 0xe0
1107 | Self Powered
1108 | Remote Wakeup
1109 | MaxPower 0mA
1110 | Interface Descriptor:
1111 | bLength 9
1112 | bDescriptorType 4
1113 | bInterfaceNumber 0
1114 | bAlternateSetting 0
1115 | bNumEndpoints 1
1116 | bInterfaceClass 9 Hub
1117 | bInterfaceSubClass 0 Unused
1118 | bInterfaceProtocol 0 Full speed (or root) hub
1119 | iInterface 0
1120 | Endpoint Descriptor:
1121 | bLength 7
1122 | bDescriptorType 5
1123 | bEndpointAddress 0x81 EP 1 IN
1124 | bmAttributes 3
1125 | Transfer Type Interrupt
1126 | Synch Type None
1127 | Usage Type Data
1128 | wMaxPacketSize 0x0001 1x 1 bytes
1129 | bInterval 12
1130 | Hub Descriptor:
1131 | bLength 9
1132 | bDescriptorType 41
1133 | nNbrPorts 6
1134 | wHubCharacteristic 0x0009
1135 | Per-port power switching
1136 | Per-port overcurrent protection
1137 | TT think time 8 FS bits
1138 | bPwrOn2PwrGood 50 * 2 milli seconds
1139 | bHubContrCurrent 0 milli Ampere
1140 | DeviceRemovable 0x00
1141 | PortPwrCtrlMask 0xff
1142 | Hub Port Status:
1143 | Port 1: 0000.0100 power
1144 | Port 2: 0000.0100 power
1145 | Port 3: 0000.0103 power enable connect
1146 | Port 4: 0000.0103 power enable connect
1147 | Port 5: 0000.0100 power
1148 | Port 6: 0000.0503 highspeed power enable connect
1149 | Device Qualifier (for other device speed):
1150 | bLength 10
1151 | bDescriptorType 6
1152 | bcdUSB 2.00
1153 | bDeviceClass 9 Hub
1154 | bDeviceSubClass 0 Unused
1155 | bDeviceProtocol 0 Full speed (or root) hub
1156 | bMaxPacketSize0 64
1157 | bNumConfigurations 1
1158 | Device Status: 0x0001
1159 | Self Powered
1160 |
1161 | Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
1162 | Device Descriptor:
1163 | bLength 18
1164 | bDescriptorType 1
1165 | bcdUSB 2.00
1166 | bDeviceClass 9 Hub
1167 | bDeviceSubClass 0 Unused
1168 | bDeviceProtocol 0 Full speed (or root) hub
1169 | bMaxPacketSize0 64
1170 | idVendor 0x1d6b Linux Foundation
1171 | idProduct 0x0002 2.0 root hub
1172 | bcdDevice 4.02
1173 | iManufacturer 3 Linux 4.2.0-16-generic ehci_hcd
1174 | iProduct 2 EHCI Host Controller
1175 | iSerial 1 0000:00:1a.0
1176 | bNumConfigurations 1
1177 | Configuration Descriptor:
1178 | bLength 9
1179 | bDescriptorType 2
1180 | wTotalLength 25
1181 | bNumInterfaces 1
1182 | bConfigurationValue 1
1183 | iConfiguration 0
1184 | bmAttributes 0xe0
1185 | Self Powered
1186 | Remote Wakeup
1187 | MaxPower 0mA
1188 | Interface Descriptor:
1189 | bLength 9
1190 | bDescriptorType 4
1191 | bInterfaceNumber 0
1192 | bAlternateSetting 0
1193 | bNumEndpoints 1
1194 | bInterfaceClass 9 Hub
1195 | bInterfaceSubClass 0 Unused
1196 | bInterfaceProtocol 0 Full speed (or root) hub
1197 | iInterface 0
1198 | Endpoint Descriptor:
1199 | bLength 7
1200 | bDescriptorType 5
1201 | bEndpointAddress 0x81 EP 1 IN
1202 | bmAttributes 3
1203 | Transfer Type Interrupt
1204 | Synch Type None
1205 | Usage Type Data
1206 | wMaxPacketSize 0x0004 1x 4 bytes
1207 | bInterval 12
1208 | Hub Descriptor:
1209 | bLength 9
1210 | bDescriptorType 41
1211 | nNbrPorts 3
1212 | wHubCharacteristic 0x000a
1213 | No power switching (usb 1.0)
1214 | Per-port overcurrent protection
1215 | bPwrOn2PwrGood 10 * 2 milli seconds
1216 | bHubContrCurrent 0 milli Ampere
1217 | DeviceRemovable 0x02
1218 | PortPwrCtrlMask 0xff
1219 | Hub Port Status:
1220 | Port 1: 0000.0503 highspeed power enable connect
1221 | Port 2: 0000.0100 power
1222 | Port 3: 0000.0100 power
1223 | Device Status: 0x0001
1224 | Self Powered
1225 |
1226 | Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
1227 | Device Descriptor:
1228 | bLength 18
1229 | bDescriptorType 1
1230 | bcdUSB 3.00
1231 | bDeviceClass 9 Hub
1232 | bDeviceSubClass 0 Unused
1233 | bDeviceProtocol 3
1234 | bMaxPacketSize0 9
1235 | idVendor 0x1d6b Linux Foundation
1236 | idProduct 0x0003 3.0 root hub
1237 | bcdDevice 4.02
1238 | iManufacturer 3 Linux 4.2.0-16-generic xhci-hcd
1239 | iProduct 2 xHCI Host Controller
1240 | iSerial 1 0000:00:14.0
1241 | bNumConfigurations 1
1242 | Configuration Descriptor:
1243 | bLength 9
1244 | bDescriptorType 2
1245 | wTotalLength 31
1246 | bNumInterfaces 1
1247 | bConfigurationValue 1
1248 | iConfiguration 0
1249 | bmAttributes 0xe0
1250 | Self Powered
1251 | Remote Wakeup
1252 | MaxPower 0mA
1253 | Interface Descriptor:
1254 | bLength 9
1255 | bDescriptorType 4
1256 | bInterfaceNumber 0
1257 | bAlternateSetting 0
1258 | bNumEndpoints 1
1259 | bInterfaceClass 9 Hub
1260 | bInterfaceSubClass 0 Unused
1261 | bInterfaceProtocol 0 Full speed (or root) hub
1262 | iInterface 0
1263 | Endpoint Descriptor:
1264 | bLength 7
1265 | bDescriptorType 5
1266 | bEndpointAddress 0x81 EP 1 IN
1267 | bmAttributes 3
1268 | Transfer Type Interrupt
1269 | Synch Type None
1270 | Usage Type Data
1271 | wMaxPacketSize 0x0004 1x 4 bytes
1272 | bInterval 12
1273 | bMaxBurst 0
1274 | Hub Descriptor:
1275 | bLength 12
1276 | bDescriptorType 42
1277 | nNbrPorts 4
1278 | wHubCharacteristic 0x000a
1279 | No power switching (usb 1.0)
1280 | Per-port overcurrent protection
1281 | bPwrOn2PwrGood 10 * 2 milli seconds
1282 | bHubContrCurrent 0 milli Ampere
1283 | bHubDecLat 0.0 micro seconds
1284 | wHubDelay 0 nano seconds
1285 | DeviceRemovable 0x10
1286 | Hub Port Status:
1287 | Port 1: 0000.02a0 5Gbps power Rx.Detect
1288 | Port 2: 0000.02a0 5Gbps power Rx.Detect
1289 | Port 3: 0000.02a0 5Gbps power Rx.Detect
1290 | Port 4: 0000.02a0 5Gbps power Rx.Detect
1291 | Binary Object Store Descriptor:
1292 | bLength 5
1293 | bDescriptorType 15
1294 | wTotalLength 15
1295 | bNumDeviceCaps 1
1296 | SuperSpeed USB Device Capability:
1297 | bLength 10
1298 | bDescriptorType 16
1299 | bDevCapabilityType 3
1300 | bmAttributes 0x00
1301 | wSpeedsSupported 0x0008
1302 | Device can operate at SuperSpeed (5Gbps)
1303 | bFunctionalitySupport 3
1304 | Lowest fully-functional device speed is SuperSpeed (5Gbps)
1305 | bU1DevExitLat 10 micro seconds
1306 | bU2DevExitLat 512 micro seconds
1307 | Device Status: 0x0001
1308 | Self Powered
1309 |
1310 | Bus 001 Device 037: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
1311 | Device Descriptor:
1312 | bLength 18
1313 | bDescriptorType 1
1314 | bcdUSB 2.00
1315 | bDeviceClass 0 (Defined at Interface level)
1316 | bDeviceSubClass 0
1317 | bDeviceProtocol 0
1318 | bMaxPacketSize0 8
1319 | idVendor 0x0403 Future Technology Devices International, Ltd
1320 | idProduct 0x6010 FT2232C Dual USB-UART/FIFO IC
1321 | bcdDevice 5.00
1322 | iManufacturer 1 FTDI
1323 | iProduct 2 Dual RS232
1324 | iSerial 0
1325 | bNumConfigurations 1
1326 | Configuration Descriptor:
1327 | bLength 9
1328 | bDescriptorType 2
1329 | wTotalLength 55
1330 | bNumInterfaces 2
1331 | bConfigurationValue 1
1332 | iConfiguration 0
1333 | bmAttributes 0x80
1334 | (Bus Powered)
1335 | MaxPower 90mA
1336 | Interface Descriptor:
1337 | bLength 9
1338 | bDescriptorType 4
1339 | bInterfaceNumber 0
1340 | bAlternateSetting 0
1341 | bNumEndpoints 2
1342 | bInterfaceClass 255 Vendor Specific Class
1343 | bInterfaceSubClass 255 Vendor Specific Subclass
1344 | bInterfaceProtocol 255 Vendor Specific Protocol
1345 | iInterface 2 Dual RS232
1346 | Endpoint Descriptor:
1347 | bLength 7
1348 | bDescriptorType 5
1349 | bEndpointAddress 0x81 EP 1 IN
1350 | bmAttributes 2
1351 | Transfer Type Bulk
1352 | Synch Type None
1353 | Usage Type Data
1354 | wMaxPacketSize 0x0040 1x 64 bytes
1355 | bInterval 0
1356 | Endpoint Descriptor:
1357 | bLength 7
1358 | bDescriptorType 5
1359 | bEndpointAddress 0x02 EP 2 OUT
1360 | bmAttributes 2
1361 | Transfer Type Bulk
1362 | Synch Type None
1363 | Usage Type Data
1364 | wMaxPacketSize 0x0040 1x 64 bytes
1365 | bInterval 0
1366 | Interface Descriptor:
1367 | bLength 9
1368 | bDescriptorType 4
1369 | bInterfaceNumber 1
1370 | bAlternateSetting 0
1371 | bNumEndpoints 2
1372 | bInterfaceClass 255 Vendor Specific Class
1373 | bInterfaceSubClass 255 Vendor Specific Subclass
1374 | bInterfaceProtocol 255 Vendor Specific Protocol
1375 | iInterface 2 Dual RS232
1376 | Endpoint Descriptor:
1377 | bLength 7
1378 | bDescriptorType 5
1379 | bEndpointAddress 0x83 EP 3 IN
1380 | bmAttributes 2
1381 | Transfer Type Bulk
1382 | Synch Type None
1383 | Usage Type Data
1384 | wMaxPacketSize 0x0040 1x 64 bytes
1385 | bInterval 0
1386 | Endpoint Descriptor:
1387 | bLength 7
1388 | bDescriptorType 5
1389 | bEndpointAddress 0x04 EP 4 OUT
1390 | bmAttributes 2
1391 | Transfer Type Bulk
1392 | Synch Type None
1393 | Usage Type Data
1394 | wMaxPacketSize 0x0040 1x 64 bytes
1395 | bInterval 0
1396 | Device Status: 0x0000
1397 | (Bus Powered)
1398 |
1399 | Bus 001 Device 030: ID 17ef:6025 Lenovo ThinkPad Travel Mouse
1400 | Device Descriptor:
1401 | bLength 18
1402 | bDescriptorType 1
1403 | bcdUSB 2.00
1404 | bDeviceClass 0 (Defined at Interface level)
1405 | bDeviceSubClass 0
1406 | bDeviceProtocol 0
1407 | bMaxPacketSize0 8
1408 | idVendor 0x17ef Lenovo
1409 | idProduct 0x6025 ThinkPad Travel Mouse
1410 | bcdDevice 1.10
1411 | iManufacturer 0
1412 | iProduct 2 ThinkPad USB Travel Mouse
1413 | iSerial 0
1414 | bNumConfigurations 1
1415 | Configuration Descriptor:
1416 | bLength 9
1417 | bDescriptorType 2
1418 | wTotalLength 34
1419 | bNumInterfaces 1
1420 | bConfigurationValue 1
1421 | iConfiguration 0
1422 | bmAttributes 0xa0
1423 | (Bus Powered)
1424 | Remote Wakeup
1425 | MaxPower 100mA
1426 | Interface Descriptor:
1427 | bLength 9
1428 | bDescriptorType 4
1429 | bInterfaceNumber 0
1430 | bAlternateSetting 0
1431 | bNumEndpoints 1
1432 | bInterfaceClass 3 Human Interface Device
1433 | bInterfaceSubClass 1 Boot Interface Subclass
1434 | bInterfaceProtocol 2 Mouse
1435 | iInterface 0
1436 | HID Device Descriptor:
1437 | bLength 9
1438 | bDescriptorType 33
1439 | bcdHID 11.10
1440 | bCountryCode 0 Not supported
1441 | bNumDescriptors 1
1442 | bDescriptorType 34 Report
1443 | wDescriptorLength 52
1444 | Report Descriptors:
1445 | ** UNAVAILABLE **
1446 | Endpoint Descriptor:
1447 | bLength 7
1448 | bDescriptorType 5
1449 | bEndpointAddress 0x81 EP 1 IN
1450 | bmAttributes 3
1451 | Transfer Type Interrupt
1452 | Synch Type None
1453 | Usage Type Data
1454 | wMaxPacketSize 0x0006 1x 6 bytes
1455 | bInterval 10
1456 | Device Status: 0x0000
1457 | (Bus Powered)
1458 |
1459 | Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
1460 | Device Descriptor:
1461 | bLength 18
1462 | bDescriptorType 1
1463 | bcdUSB 2.00
1464 | bDeviceClass 9 Hub
1465 | bDeviceSubClass 0 Unused
1466 | bDeviceProtocol 1 Single TT
1467 | bMaxPacketSize0 64
1468 | idVendor 0x1d6b Linux Foundation
1469 | idProduct 0x0002 2.0 root hub
1470 | bcdDevice 4.02
1471 | iManufacturer 3 Linux 4.2.0-16-generic xhci-hcd
1472 | iProduct 2 xHCI Host Controller
1473 | iSerial 1 0000:00:14.0
1474 | bNumConfigurations 1
1475 | Configuration Descriptor:
1476 | bLength 9
1477 | bDescriptorType 2
1478 | wTotalLength 25
1479 | bNumInterfaces 1
1480 | bConfigurationValue 1
1481 | iConfiguration 0
1482 | bmAttributes 0xe0
1483 | Self Powered
1484 | Remote Wakeup
1485 | MaxPower 0mA
1486 | Interface Descriptor:
1487 | bLength 9
1488 | bDescriptorType 4
1489 | bInterfaceNumber 0
1490 | bAlternateSetting 0
1491 | bNumEndpoints 1
1492 | bInterfaceClass 9 Hub
1493 | bInterfaceSubClass 0 Unused
1494 | bInterfaceProtocol 0 Full speed (or root) hub
1495 | iInterface 0
1496 | Endpoint Descriptor:
1497 | bLength 7
1498 | bDescriptorType 5
1499 | bEndpointAddress 0x81 EP 1 IN
1500 | bmAttributes 3
1501 | Transfer Type Interrupt
1502 | Synch Type None
1503 | Usage Type Data
1504 | wMaxPacketSize 0x0004 1x 4 bytes
1505 | bInterval 12
1506 | Hub Descriptor:
1507 | bLength 9
1508 | bDescriptorType 41
1509 | nNbrPorts 4
1510 | wHubCharacteristic 0x000a
1511 | No power switching (usb 1.0)
1512 | Per-port overcurrent protection
1513 | TT think time 8 FS bits
1514 | bPwrOn2PwrGood 10 * 2 milli seconds
1515 | bHubContrCurrent 0 milli Ampere
1516 | DeviceRemovable 0x10
1517 | PortPwrCtrlMask 0xff
1518 | Hub Port Status:
1519 | Port 1: 0000.0303 lowspeed power enable connect
1520 | Port 2: 0000.0103 power enable connect
1521 | Port 3: 0000.0100 power
1522 | Port 4: 0000.0100 power
1523 | Device Status: 0x0001
1524 | Self Powered
1525 |
--------------------------------------------------------------------------------
/src/itdf.h:
--------------------------------------------------------------------------------
1 | #define ITDF_SET_REQUEST_TYPE 0x40
2 | #define ITDF_GET_REQUEST_TYPE 0xC0
3 |
4 | #define ITDF_SIO_RESET 0 /* Reset the port */
5 | #define ITDF_SIO_MODEM_CTRL 1 /* Set the modem control register */
6 | #define ITDF_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
7 | #define ITDF_SIO_SET_BAUD_RATE 3 /* Set baud rate */
8 | #define ITDF_SIO_SET_DATA 4 /* Set the data characteristics of
9 | the port */
10 | #define ITDF_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem
11 | status register */
12 | #define ITDF_SIO_SET_EVENT_CHAR 6 /* Set the event character */
13 | #define ITDF_SIO_SET_ERROR_CHAR 7 /* Set the error character */
14 | #define ITDF_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
15 | #define ITDF_SIO_GET_LATENCY_TIMER 0x0a /* Get the latency timer */
16 | #define ITDF_SIO_SET_BITMODE 0x0b /* Set bitbang mode */
17 | #define ITDF_SIO_READ_PINS 0x0c /* Read immediate value of pins */
18 | #define ITDF_SIO_READ_EEPROM 0x90 /* Read EEPROM */
19 |
20 | #define ITDF_SIO_WRITE_EEPROM 0x91
21 | #define ITDF_SIO_TEST_EEPROM 0x92
22 |
23 | #define ITDF_SIO_SET_DTR_MASK 0x1
24 | #define ITDF_SIO_SET_RTS_MASK 0x2
25 |
26 | /** SESPM bitbang modes */
27 | enum itdf_sespm_mode
28 | {
29 | BITMODE_RESET = 0x00, /**< switch off bitbang mode, back to regular serial/FIFO */
30 | BITMODE_BITBANG= 0x01, /**< classical asynchronous bitbang mode, introduced with B-type chips */
31 | BITMODE_SESPM = 0x02, /**< SESPM mode, available on 2232x chips */
32 | BITMODE_SYNCBB = 0x04, /**< synchronous bitbang mode, available on 2232x and R-type chips */
33 | BITMODE_MCU = 0x08, /**< MCU Host Bus Emulation mode, available on 2232x chips */
34 | /* CPU-style fifo mode gets set via EEPROM */
35 | BITMODE_OPTO = 0x10, /**< Fast Opto-Isolated Serial Interface Mode, available on 2232x chips */
36 | BITMODE_CBUS = 0x20, /**< Bitbang on CBUS pins of R-type chips, configure in EEPROM before */
37 | BITMODE_SYNCFF = 0x40, /**< Single Channel Synchronous FIFO mode, available on 2232H chips */
38 | BITMODE_FT1284 = 0x80, /**< FT1284 mode, available on 232H chips */
39 | };
40 |
41 | const uint16_t itdf_eeprom [] =
42 | {
43 | 0x0800, 0x0403, 0x6010, 0x0500, 0x3280, 0x0000, 0x0200, 0x1096,
44 | 0x1aa6, 0x0000, 0x0046, 0x0310, 0x004f, 0x0070, 0x0065, 0x006e,
45 | 0x002d, 0x0045, 0x0043, 0x031a, 0x0055, 0x0053, 0x0042, 0x0020,
46 | 0x0044, 0x0065, 0x0062, 0x0075, 0x0067, 0x0067, 0x0065, 0x0072,
47 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
48 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
49 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
50 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1027
51 | };
52 |
53 | #define ITDF_SIE_WRITE_MCE (1 << 0)
54 | #define ITDF_SIE_BIT_MODE (1 << 1)
55 | #define ITDF_SIE_READ_MCE (1 << 2)
56 | #define ITDF_SIE_LSB_FIRST (1 << 3)
57 | #define ITDF_SIE_WRITE_TDI (1 << 4)
58 | #define ITDF_SIE_READ_TDO (1 << 5)
59 | #define ITDF_SIE_WRITE_TMS (1 << 6)
60 | #define ITDF_SIE_SPECIAL (1 << 7)
61 |
62 | #define DELAY() asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop")
63 |
64 | enum sespm_state_t
65 | {
66 | IDLE = 0,
67 | /* TDI 字节传输 */
68 | TDI_RECV_LENGL_BYTE = 1,
69 | TDI_RECV_LENGH_BYTE = 2,
70 | TDI_DATA_BYTE = 3,
71 | #if 0
72 | /* TMS 字节传输, 不使用 */
73 | TMS_RECV_LENGL_BYTE = 4,
74 | TMS_RECV_LENGH_BYTE = 5,
75 | TMS_DATA_BYTE = 6,
76 | #endif
77 | /* Bitbang */
78 | BUS_DATA = 7,
79 | BUS_DIR = 8,
80 | /* TDI 位传输 */
81 | TDI_RECV_LENG_BIT = 9,
82 | TDI_DATA_BIT = 10,
83 | /* TMS 位传输 */
84 | TMS_RECV_LENG_BIT = 11,
85 | TMS_DATA_BIT = 12
86 | };
87 |
--------------------------------------------------------------------------------
/src/itdf_protocol.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipeed/open-ec/b6dee9b65ecbcf2b201490a45fc629aaa537e9c8/src/itdf_protocol.c
--------------------------------------------------------------------------------
/src/jtag_handler.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipeed/open-ec/b6dee9b65ecbcf2b201490a45fc629aaa537e9c8/src/jtag_handler.c
--------------------------------------------------------------------------------
/src/stm32f103x8.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the libopencm3 project.
3 | *
4 | * Copyright (C) 2015 Karl Palsson
5 | *
6 | * This library is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with this library. If not, see .
18 | */
19 |
20 | /* Linker script for STM32F103x8, 64k flash, 20k RAM. */
21 |
22 | /* Define memory regions. */
23 | /* 8k for the bootloader */
24 | MEMORY
25 | {
26 | rom (rx) : ORIGIN = 0x08002000, LENGTH = 56K
27 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
28 | }
29 |
30 | /* Include the common ld script. */
31 | INCLUDE libopencm3_stm32f1.ld
32 |
--------------------------------------------------------------------------------
/src/uart_handler.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipeed/open-ec/b6dee9b65ecbcf2b201490a45fc629aaa537e9c8/src/uart_handler.c
--------------------------------------------------------------------------------
/src/usb_private.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include "usb_private.h"
7 |
8 | uint8_t st_usbfs_ep_in_ready(usbd_device *dev, uint8_t addr)
9 | {
10 | (void)dev;
11 | addr &= 0x7f;
12 | if ((*USB_EP_REG(addr) & USB_EP_TX_STAT) == USB_EP_TX_STAT_VALID) {
13 | return 0;
14 | }
15 | return 1;
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/src/usb_private.h:
--------------------------------------------------------------------------------
1 | #ifndef USB_PRIVATE_H
2 | #define USB_PRIVATE_H
3 | uint8_t st_usbfs_ep_in_ready(usbd_device *dev, uint8_t addr);
4 | #endif
5 |
--------------------------------------------------------------------------------