update doc structure,hosting with readdoc
@ -101,11 +101,9 @@ CherryUSB Host Stack has the following functions:
|
||||
|
||||
The CherryUSB Host stack also provides the lsusb function, which allows you to view information about all mounted devices, including those on external hubs, with the help of a shell plugin.
|
||||
|
||||

|
||||
|
||||
## CherryUSB Documentation Tutorial
|
||||
|
||||
Quickly start, API manual,and Class knowledge and examples, see [CherryUSB Documentation Tutorial](https://htmlpreview.github.io/?https://raw.githubusercontent.com/sakumisu/CherryUSB/master/docs/_build/html/index.html)
|
||||
Quickly start, USB basic concepts, API manual, Class basic concepts and examples, see [CherryUSB Documentation Tutorial](https://cherryusb.readthedocs.io/)
|
||||
|
||||
## CherryUSB Video Tutorial
|
||||
|
||||
|
@ -100,11 +100,9 @@ CherryUSB Host 协议栈当前实现以下功能:
|
||||
|
||||
同时,CherryUSB Host 协议栈还提供了 lsusb 的功能,借助 shell 插件可以查看所有挂载设备的信息,包括外部 hub 上的设备的信息。
|
||||
|
||||

|
||||
|
||||
## CherryUSB 文档教程
|
||||
|
||||
CherryUSB 快速入门、API 手册以及 Class 知识点和例程,参考 [CherryUSB 文档教程](https://htmlpreview.github.io/?https://raw.githubusercontent.com/sakumisu/CherryUSB/master/docs/_build/html/index.html)
|
||||
CherryUSB 快速入门、USB 基本概念,API 手册,Class 基本概念和例程,参考 [CherryUSB 文档教程](https://cherryusb.readthedocs.io/)
|
||||
|
||||
## CherryUSB 视频教程
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
|
BIN
docs/_build/doctrees/api/api_common.doctree
vendored
BIN
docs/_build/doctrees/api/api_device.doctree
vendored
BIN
docs/_build/doctrees/api/api_host.doctree
vendored
BIN
docs/_build/doctrees/class/class_audio.doctree
vendored
BIN
docs/_build/doctrees/class/class_cdc.doctree
vendored
BIN
docs/_build/doctrees/class/class_hid.doctree
vendored
BIN
docs/_build/doctrees/class/class_msc.doctree
vendored
BIN
docs/_build/doctrees/class/class_video.doctree
vendored
BIN
docs/_build/doctrees/class/winusb.doctree
vendored
BIN
docs/_build/doctrees/demo/daplink.doctree
vendored
BIN
docs/_build/doctrees/demo/mouse_keyboard.doctree
vendored
BIN
docs/_build/doctrees/demo/msc_boot.doctree
vendored
BIN
docs/_build/doctrees/demo/speaker_mic.doctree
vendored
BIN
docs/_build/doctrees/demo/usb2uart.doctree
vendored
BIN
docs/_build/doctrees/demo/video.doctree
vendored
BIN
docs/_build/doctrees/environment.pickle
vendored
BIN
docs/_build/doctrees/index.doctree
vendored
BIN
docs/_build/doctrees/porting.doctree
vendored
BIN
docs/_build/doctrees/quick_start/bl702.doctree
vendored
BIN
docs/_build/doctrees/quick_start/ch32v307.doctree
vendored
BIN
docs/_build/doctrees/quick_start/stm32f429.doctree
vendored
BIN
docs/_build/doctrees/usb/usb_basic.doctree
vendored
BIN
docs/_build/doctrees/usb/usb_desc.doctree
vendored
BIN
docs/_build/doctrees/usb/usb_enum.doctree
vendored
BIN
docs/_build/doctrees/usb/usb_request.doctree
vendored
4
docs/_build/html/.buildinfo
vendored
@ -1,4 +0,0 @@
|
||||
# Sphinx build info version 1
|
||||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||
config: acf2721d32ce29d0728f2c2892e0f919
|
||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
BIN
docs/_build/html/_images/11.png
vendored
Before Width: | Height: | Size: 105 KiB |
BIN
docs/_build/html/_images/111.png
vendored
Before Width: | Height: | Size: 9.8 KiB |
BIN
docs/_build/html/_images/21.png
vendored
Before Width: | Height: | Size: 77 KiB |
BIN
docs/_build/html/_images/211.png
vendored
Before Width: | Height: | Size: 7.1 KiB |
BIN
docs/_build/html/_images/31.png
vendored
Before Width: | Height: | Size: 122 KiB |
@ -1,2 +0,0 @@
|
||||
其他
|
||||
=========================
|
497
docs/_build/html/_sources/api/api_device.rst.txt
vendored
@ -1,497 +0,0 @@
|
||||
设备协议栈
|
||||
=========================
|
||||
|
||||
CORE
|
||||
-----------------
|
||||
|
||||
端点结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
端点结构体主要用于注册不同端点地址的中断完成回调函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbd_endpoint {
|
||||
usb_slist_t list;
|
||||
uint8_t ep_addr;
|
||||
usbd_endpoint_callback ep_cb;
|
||||
} usbd_endpoint_t;
|
||||
|
||||
- **list** 端点的链表节点
|
||||
- **ep_addr** 端点地址(带方向)
|
||||
- **ep_cb** 端点中断回调函数
|
||||
|
||||
接口结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
接口结构体主要用于注册不同类设备除了标准设备请求外的其他请求,包括类设备请求、厂商设备请求和自定义设备请求。以及协议栈中的相关通知回调函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbd_interface {
|
||||
usb_slist_t list;
|
||||
/** Handler for USB Class specific commands*/
|
||||
usbd_request_handler class_handler;
|
||||
/** Handler for USB Vendor specific commands */
|
||||
usbd_request_handler vendor_handler;
|
||||
/** Handler for USB custom specific commands */
|
||||
usbd_request_handler custom_handler;
|
||||
/** Handler for USB event notify commands */
|
||||
usbd_notify_handler notify_handler;
|
||||
uint8_t intf_num;
|
||||
usb_slist_t ep_list;
|
||||
} usbd_interface_t;
|
||||
|
||||
- **list** 接口的链表节点
|
||||
- **class_handler** class setup 请求回调函数
|
||||
- **vendor_handler** vendor setup 请求回调函数
|
||||
- **custom_handler** custom setup 请求回调函数
|
||||
- **notify_handler** 中断标志、协议栈相关状态回调函数
|
||||
- **intf_num** 当前接口偏移
|
||||
- **ep_list** 端点的链表节点
|
||||
|
||||
类结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
类结构体主要用于挂载接口链表。后期可能会删除,因为这个部分跟接口其实是有关系的。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbd_class {
|
||||
usb_slist_t list;
|
||||
const char *name;
|
||||
usb_slist_t intf_list;
|
||||
} usbd_class_t;
|
||||
|
||||
- **list** 类的链表节点
|
||||
- **name** 类的名称
|
||||
- **intf_list** 接口的链表节点
|
||||
|
||||
usbd_event_notify_handler
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_event_notify_handler`` 是 USB 中断中的核心,用于处理不同的中断标志。包括复位、端点0 IN/OUT/SETUP、其他端点 IN/OUT 、SUSPEND、RESUME、SOF 中断等等。用户需要在 porting 接口中的 USB中断中调用该接口。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_event_notify_handler(uint8_t event, void *arg);
|
||||
|
||||
- **event** 中断事件
|
||||
- **arg** 端点号
|
||||
|
||||
其中 ``event`` 有如下类型:
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
enum usbd_event_type {
|
||||
/** USB error reported by the controller */
|
||||
USBD_EVENT_ERROR,
|
||||
/** USB reset */
|
||||
USBD_EVENT_RESET,
|
||||
/** Start of Frame received */
|
||||
USBD_EVENT_SOF,
|
||||
/** USB connection established, hardware enumeration is completed */
|
||||
USBD_EVENT_CONNECTED,
|
||||
/** USB configuration done */
|
||||
USBD_EVENT_CONFIGURED,
|
||||
/** USB connection suspended by the HOST */
|
||||
USBD_EVENT_SUSPEND,
|
||||
/** USB connection lost */
|
||||
USBD_EVENT_DISCONNECTED,
|
||||
/** USB connection resumed by the HOST */
|
||||
USBD_EVENT_RESUME,
|
||||
|
||||
/** USB interface selected */
|
||||
USBD_EVENT_SET_INTERFACE,
|
||||
/** USB interface selected */
|
||||
USBD_EVENT_SET_REMOTE_WAKEUP,
|
||||
/** USB interface selected */
|
||||
USBD_EVENT_CLEAR_REMOTE_WAKEUP,
|
||||
/** Set Feature ENDPOINT_HALT received */
|
||||
USBD_EVENT_SET_HALT,
|
||||
/** Clear Feature ENDPOINT_HALT received */
|
||||
USBD_EVENT_CLEAR_HALT,
|
||||
/** setup packet received */
|
||||
USBD_EVENT_SETUP_NOTIFY,
|
||||
/** ep0 in packet received */
|
||||
USBD_EVENT_EP0_IN_NOTIFY,
|
||||
/** ep0 out packet received */
|
||||
USBD_EVENT_EP0_OUT_NOTIFY,
|
||||
/** ep in packet except ep0 received */
|
||||
USBD_EVENT_EP_IN_NOTIFY,
|
||||
/** ep out packet except ep0 received */
|
||||
USBD_EVENT_EP_OUT_NOTIFY,
|
||||
/** Initial USB connection status */
|
||||
USBD_EVENT_UNKNOWN
|
||||
};
|
||||
|
||||
usbd_desc_register
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_desc_register`` 用来注册 USB 描述符,描述符种类包括:设备描述符、配置描述符(包含配置描述符、接口描述符、class 类描述符、端点描述符)、字符串描述符、设备限定描述符。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_desc_register(const uint8_t *desc);
|
||||
|
||||
- **desc** 描述符的句柄
|
||||
|
||||
usbd_msosv1_desc_register
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_msosv1_desc_register`` 用来注册一个 WINUSB 1.0 描述符。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_msosv1_desc_register(struct usb_msosv1_descriptor *desc);
|
||||
|
||||
- **desc** 描述符句柄
|
||||
|
||||
usbd_msosv2_desc_register
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_msosv2_desc_register`` 用来注册一个 WINUSB 2.0 描述符。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_msosv2_desc_register(struct usb_msosv2_descriptor *desc);
|
||||
|
||||
- **desc** 描述符句柄
|
||||
|
||||
usbd_bos_desc_register
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_bos_desc_register`` 用来注册一个 BOS 描述符, USB 2.1 版本以上必须注册。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_bos_desc_register(struct usb_bos_descriptor *desc);
|
||||
|
||||
- **desc** 描述符句柄
|
||||
|
||||
usbd_class_register
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_class_register`` 用来注册一个 class,该 class 中的接口链表成员,用于后续挂载多个接口。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_class_register(usbd_class_t *devclass);
|
||||
|
||||
- **devclass** USB 设备类的句柄
|
||||
|
||||
usbd_class_add_interface
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_class_add_interface`` 用来给 USB 设备类增加接口,并将接口信息挂载在类的链表上。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_class_add_interface(usbd_class_t *devclass, usbd_interface_t *intf);
|
||||
|
||||
- **devclass** USB 设备类的句柄
|
||||
- **intf** USB 设备接口的句柄
|
||||
|
||||
**usbd_interface_add_endpoint**
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_interface_add_endpoint`` 用来给 USB 接口增加端点,并将端点信息挂载在接口的链表上。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_interface_add_endpoint(usbd_interface_t *intf, usbd_endpoint_t *ep);
|
||||
|
||||
|
||||
- **intf** USB 设备接口的句柄
|
||||
- **ep** USB 设备端点的句柄
|
||||
|
||||
**usb_device_is_configured**
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usb_device_is_configured`` 用来检查 USB 设备是否被配置(枚举)。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
bool usb_device_is_configured(void);
|
||||
|
||||
- **return** 配置状态, 0 表示未配置, 1 表示配置成功
|
||||
|
||||
CDC ACM
|
||||
-----------------
|
||||
|
||||
usbd_cdc_add_acm_interface
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_cdc_add_acm_interface`` 用来给 USB CDC ACM 类添加接口,并实现该接口相关的函数:
|
||||
|
||||
- ``cdc_acm_class_request_handler`` 用来处理 USB CDC ACM 类 Setup 请求。
|
||||
- ``cdc_notify_handler`` 用来处理 USB CDC 其他中断回调函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_cdc_add_acm_interface(usbd_class_t *devclass, usbd_interface_t *intf);
|
||||
|
||||
- **devclass** 类的句柄
|
||||
- **intf** 接口句柄
|
||||
|
||||
usbd_cdc_acm_set_line_coding
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_cdc_acm_set_line_coding`` 用来对串口进行配置,如果仅使用 USB 而不用 串口,该接口不用用户实现,使用默认。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_cdc_acm_set_line_coding(uint32_t baudrate, uint8_t databits, uint8_t parity, uint8_t stopbits);
|
||||
|
||||
- **baudrate** 波特率
|
||||
- **databits** 数据位
|
||||
- **parity** 校验位
|
||||
- **stopbits** 停止位
|
||||
|
||||
usbd_cdc_acm_set_dtr
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_cdc_acm_set_dtr`` 用来控制串口 DTR 。如果仅使用 USB 而不用 串口,该接口不用用户实现,使用默认。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_cdc_acm_set_dtr(bool dtr);
|
||||
|
||||
- **dtr** dtr 为1表示拉低电平,为0表示拉高电平
|
||||
|
||||
usbd_cdc_acm_set_rts
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_cdc_acm_set_rts`` 用来控制串口 RTS 。如果仅使用 USB 而不用 串口,该接口不用用户实现,使用默认。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_cdc_acm_set_rts(bool rts);
|
||||
|
||||
- **rts** rts 为1表示拉低电平,为0表示拉高电平
|
||||
|
||||
HID
|
||||
-----------------
|
||||
|
||||
usbd_hid_add_interface
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_hid_add_interface`` 用来给 USB HID 类添加接口,并实现该接口相关的函数:
|
||||
|
||||
- ``hid_class_request_handler`` 用来处理 USB HID 类的 Setup 请求。
|
||||
- ``hid_custom_request_handler`` 用来处理 USB HID 获取报告描述符请求。
|
||||
- ``hid_notify_handler`` 用来处理 USB HID 其他中断回调函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_hid_add_interface(usbd_class_t *devclass, usbd_interface_t *intf);
|
||||
|
||||
- **devclass** 类的句柄
|
||||
- **intf** 接口句柄
|
||||
|
||||
usbd_hid_report_descriptor_register
|
||||
""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_hid_report_descriptor_register`` 用来注册 hid 报告描述符。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_hid_report_descriptor_register(uint8_t intf_num, const uint8_t *desc, uint32_t desc_len);
|
||||
|
||||
- **intf_num** 当前 hid 报告描述符所在接口偏移
|
||||
- **desc** 报告描述符
|
||||
- **desc_len** 报告描述符长度
|
||||
|
||||
usbd_hid_set_request_callback
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_hid_set_request_callback`` 用来注册 hid 类请求命令的回调函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_hid_set_request_callback( uint8_t intf_num,
|
||||
uint8_t (*get_report_callback)(uint8_t report_id, uint8_t report_type),
|
||||
void (*set_report_callback)(uint8_t report_id, uint8_t report_type, uint8_t *report, uint8_t report_len),
|
||||
uint8_t (*get_idle_callback)(uint8_t report_id),
|
||||
void (*set_idle_callback)(uint8_t report_id, uint8_t duration),
|
||||
void (*set_protocol_callback)(uint8_t protocol),
|
||||
uint8_t (*get_protocol_callback)(void));
|
||||
|
||||
- **intf_num** 当前 hid 报告描述符所在接口偏移
|
||||
- **get_report_callback** get report命令处理回调函数
|
||||
- **set_report_callback** set report命令处理回调函数
|
||||
- **get_idle_callback** get idle命令处理回调函数
|
||||
- **set_idle_callback** set idle命令处理回调函数
|
||||
- **set_protocol_callback** set protocol命令处理回调函数
|
||||
- **get_protocol_callback** get protocol命令处理回调函数
|
||||
|
||||
MSC
|
||||
-----------------
|
||||
|
||||
usbd_msc_class_init
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
``usbd_msc_class_init`` 用来给 MSC 类添加接口,并实现该接口相关函数,并且注册端点回调函数。(因为 msc bot 协议是固定的,所以不需要用于实现,因此端点回调函数自然不需要用户实现)。
|
||||
|
||||
- ``msc_storage_class_request_handler`` 用于处理 USB MSC Setup 中断请求。
|
||||
- ``msc_storage_notify_handler`` 用于实现 USB MSC 其他中断回调函数。
|
||||
|
||||
- ``mass_storage_bulk_out`` 用于处理 USB MSC 端点 out 中断。
|
||||
- ``mass_storage_bulk_in`` 用于处理 USB MSC 端点 in 中断。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_msc_class_init(uint8_t out_ep, uint8_t in_ep);
|
||||
|
||||
- **out_ep** out 端点地址
|
||||
- **in_ep** in 端点地址
|
||||
|
||||
usbd_msc_get_cap
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_msc_get_cap`` 用来获取存储器的 lun、扇区个数和每个扇区大小。用户必须实现该函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_msc_get_cap(uint8_t lun, uint32_t *block_num, uint16_t *block_size);
|
||||
|
||||
- **lun** 存储逻辑单元,暂时无用,默认支持一个
|
||||
- **block_num** 存储扇区个数
|
||||
- **block_size** 存储扇区大小
|
||||
|
||||
usbd_msc_sector_read
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_msc_sector_read`` 用来对存储器某个扇区开始的地址进行数据读取。用户必须实现该函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
int usbd_msc_sector_read(uint32_t sector, uint8_t *buffer, uint32_t length);
|
||||
|
||||
- **sector** 扇区偏移
|
||||
- **buffer** 存储读取的数据的指针
|
||||
- **length** 读取长度
|
||||
|
||||
|
||||
usbd_msc_sector_write
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_msc_sector_write`` 用来对存储器某个扇区开始写入数据。用户必须实现该函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
int usbd_msc_sector_write(uint32_t sector, uint8_t *buffer, uint32_t length);
|
||||
|
||||
- **sector** 扇区偏移
|
||||
- **buffer** 写入数据指针
|
||||
- **length** 写入长度
|
||||
|
||||
UAC
|
||||
-----------------
|
||||
|
||||
usbd_audio_add_interface
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
``usbd_audio_add_interface`` 用来给 USB Audio 类添加接口,并实现该接口相关的函数:
|
||||
|
||||
- ``audio_class_request_handler`` 用于处理 USB Audio Setup 中断请求。
|
||||
- ``audio_notify_handler`` 用于实现 USB Audio 其他中断回调函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_audio_add_interface(usbd_class_t *devclass, usbd_interface_t *intf);
|
||||
|
||||
- **class** 类的句柄
|
||||
- **intf** 接口句柄
|
||||
|
||||
usbd_audio_set_mute
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_audio_set_mute`` 用来设置静音。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_audio_set_mute(uint8_t mute);
|
||||
|
||||
- **mute** 为1 表示静音,0相反
|
||||
|
||||
usbd_audio_set_volume
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_audio_set_volume`` 用来设置音量。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_audio_set_volume(uint8_t vol);
|
||||
|
||||
- **vol** 音量,从 0-100
|
||||
|
||||
usbd_audio_set_interface_callback
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_audio_set_interface_callback`` 用来开关音频数据传输。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_audio_set_interface_callback(uint8_t value);
|
||||
|
||||
- **value** 为1 表示开启 stream 传输,为0 相反
|
||||
|
||||
UVC
|
||||
-----------------
|
||||
|
||||
usbd_video_add_interface
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
``usbd_video_add_interface`` 用来给 USB Video 类添加接口,并实现该接口相关的函数:
|
||||
|
||||
- ``video_class_request_handler`` 用于处理 USB Video Setup 中断请求。
|
||||
- ``video_notify_handler`` 用于实现 USB Video 其他中断回调函数。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_video_add_interface(usbd_class_t *devclass, usbd_interface_t *intf);
|
||||
|
||||
- **class** 类的句柄
|
||||
- **intf** 接口句柄
|
||||
|
||||
usbd_video_probe_and_commit_controls_init
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_video_probe_and_commit_controls_init`` 用来开关视频数据传输。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_video_probe_and_commit_controls_init(uint32_t dwFrameInterval, uint32_t dwMaxVideoFrameSize, uint32_t dwMaxPayloadTransferSize);
|
||||
|
||||
- **value** 为1 表示开启 stream 传输,为0 相反
|
||||
|
||||
usbd_video_mjpeg_payload_fill
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_video_mjpeg_payload_fill`` 用来填充 mjpeg 到新的 buffer中,其中会对 mjpeg 数据按帧进行切分,切分大小由 ``dwMaxPayloadTransferSize`` 控制,并添加头部信息,当前头部字节数为 2。头部信息见 ``struct video_mjpeg_payload_header``
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
uint32_t usbd_video_mjpeg_payload_fill(uint8_t *input, uint32_t input_len, uint8_t *output, uint32_t *out_len);
|
||||
|
||||
- **input** mjpeg 格式的数据包,从 FFD8~FFD9结束
|
||||
- **input_len** mjpeg数据包大小
|
||||
- **output** 输出缓冲区
|
||||
- **out_len** 输出实际要发送的长度大小
|
||||
- **return** 返回 usb 按照 ``dwMaxPayloadTransferSize`` 大小要发多少帧
|
||||
|
||||
usbd_video_mjpeg_payload_header_toggle
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbd_video_mjpeg_payload_header_toggle`` 用来对每一帧图像数据要发送时进行翻转,并保持到一帧图像数据发送完成。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbd_video_mjpeg_payload_header_toggle(uint8_t *output, uint32_t packets);
|
||||
|
||||
- **output** 要翻转的 usb 缓冲区,该缓冲区是 ``usbd_video_mjpeg_payload_fill`` 中的 ``output``
|
||||
- **packets** USB 发送的帧个数
|
||||
|
||||
DFU
|
||||
-----------------
|
||||
|
||||
PORTING
|
||||
-----------------
|
161
docs/_build/html/_sources/api/api_host.rst.txt
vendored
@ -1,161 +0,0 @@
|
||||
主机协议栈
|
||||
=========================
|
||||
|
||||
CORE
|
||||
-----------------
|
||||
|
||||
CLASS 驱动信息结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
struct usbh_class_info {
|
||||
uint8_t class; /* Base device class code */
|
||||
uint8_t subclass; /* Sub-class, depends on base class. Eg. */
|
||||
uint8_t protocol; /* Protocol, depends on base class. Eg. */
|
||||
uint16_t vid; /* Vendor ID (for vendor/product specific devices) */
|
||||
uint16_t pid; /* Product ID (for vendor/product specific devices) */
|
||||
const struct usbh_class_driver *class_driver;
|
||||
};
|
||||
|
||||
端点结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_endpoint {
|
||||
struct usb_endpoint_descriptor ep_desc;
|
||||
} usbh_endpoint_t;
|
||||
|
||||
接口结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_interface {
|
||||
struct usb_interface_descriptor intf_desc;
|
||||
struct usbh_endpoint ep[CONFIG_USBHOST_EP_NUM];
|
||||
char devname[CONFIG_USBHOST_DEV_NAMELEN];
|
||||
struct usbh_class_driver *class_driver;
|
||||
void *priv;
|
||||
} usbh_interface_t;
|
||||
|
||||
|
||||
配置结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_configuration {
|
||||
struct usb_configuration_descriptor config_desc;
|
||||
struct usbh_interface intf[CONFIG_USBHOST_INTF_NUM];
|
||||
} usbh_configuration_t;
|
||||
|
||||
hubport 结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_hubport {
|
||||
bool connected; /* True: device connected; false: disconnected */
|
||||
bool port_change; /* True: port changed; false: port do not change */
|
||||
uint8_t port; /* Hub port index */
|
||||
uint8_t dev_addr; /* device address */
|
||||
uint8_t speed; /* device speed */
|
||||
usbh_epinfo_t ep0; /* control ep info */
|
||||
struct usb_device_descriptor device_desc;
|
||||
struct usbh_configuration config;
|
||||
#if 0
|
||||
uint8_t* config_desc;
|
||||
#endif
|
||||
struct usb_setup_packet *setup;
|
||||
struct usbh_hub *parent; /*if NULL, is roothub*/
|
||||
} usbh_hubport_t;
|
||||
|
||||
hub 结构体
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
typedef struct usbh_hub {
|
||||
usb_slist_t list;
|
||||
uint8_t index; /* Hub index */
|
||||
uint8_t nports; /* Hub port number */
|
||||
uint8_t dev_addr; /* Hub device address */
|
||||
usbh_epinfo_t intin;
|
||||
uint8_t *int_buffer;
|
||||
struct hub_port_status *port_status;
|
||||
struct usb_hub_descriptor hub_desc;
|
||||
struct usbh_hubport child[CONFIG_USBHOST_EHPORTS];
|
||||
struct usbh_hubport *parent; /* Parent hub port */
|
||||
struct usb_work work;
|
||||
} usbh_hub_t;
|
||||
|
||||
usbh_event_notify_handler
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbh_event_notify_handler`` 是 USB 中断中的核心,用于处理不同的中断标志。包括复位、端点0 IN/OUT/SETUP、其他端点 IN/OUT 、SUSPEND、RESUME、SOF 中断等等。用于需要在 porting 接口中的 USB中断中调用该接口。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void usbh_event_notify_handler(uint8_t event, uint8_t rhport);
|
||||
|
||||
- **event** 中断事件
|
||||
- **rhport** roothub 端口号
|
||||
|
||||
其中 ``event`` 有如下类型:
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
enum usbh_event_type {
|
||||
USBH_EVENT_ATTACHED,
|
||||
USBH_EVENT_REMOVED,
|
||||
};
|
||||
|
||||
usbh_initialize
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbh_initialize`` 用来初始化 usb 主机协议栈,包括:创建插拔检测用的信号量和枚举线程、高低工作队列、初始化 roothub端点0 配置,初始化 usb 主机控制器。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
int usbh_initialize(void);
|
||||
|
||||
usbh_find_class_instance
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``usbh_find_class_instance`` 根据注册的 class 名称查找对应的 class 结构体句柄。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void *usbh_find_class_instance(const char *devname);
|
||||
|
||||
- **devname** class 名称
|
||||
- **return** class 结构体句柄
|
||||
|
||||
lsusb
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
``lsusb`` 用来查看和操作 hub 上的设备信息。需要借助 shell 插件使用。
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
int lsusb(int argc, char **argv);
|
||||
|
||||
CDC ACM
|
||||
-----------------
|
||||
|
||||
HID
|
||||
-----------------
|
||||
|
||||
MSC
|
||||
-----------------
|
||||
|
||||
UAC
|
||||
-----------------
|
||||
|
||||
UVC
|
||||
-----------------
|
||||
|
||||
PORTING
|
||||
-----------------
|
@ -1,2 +0,0 @@
|
||||
UAC
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
CDC
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
HID
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
MSC
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
UVC
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
WINUSB
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
DAPLINK V2.0调试器
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
键盘与鼠标
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
U盘制作 BootLoader
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
USB 双通道扬声器和麦克风
|
||||
===========================
|
@ -1,2 +0,0 @@
|
||||
USB 转串口
|
||||
=========================
|
2
docs/_build/html/_sources/demo/video.rst.txt
vendored
@ -1,2 +0,0 @@
|
||||
USB 摄像头
|
||||
===========================
|
62
docs/_build/html/_sources/index.rst.txt
vendored
@ -1,62 +0,0 @@
|
||||
.. CherryUSB 使用指南 documentation master file, created by
|
||||
sphinx-quickstart on Thu Nov 21 10:50:33 2019.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
CherryUSB 使用指南
|
||||
======================================================
|
||||
|
||||
CherryUSB 是一个小而美的、可移植性高的、用于嵌入式系统的 USB 主从协议栈。
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
:caption: 快速入门
|
||||
|
||||
quick_start/bl702
|
||||
quick_start/stm32f429
|
||||
quick_start/ch32v307
|
||||
quick_start/rt-thread/rt-thread_zh
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: USB 基本知识点
|
||||
|
||||
usb/usb_basic
|
||||
usb/usb_desc
|
||||
usb/usb_request
|
||||
usb/usb_enum
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: API 手册
|
||||
|
||||
api/api_device
|
||||
api/api_host
|
||||
api/api_common
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Class 指南
|
||||
|
||||
class/class_cdc
|
||||
class/class_hid
|
||||
class/class_msc
|
||||
class/class_audio
|
||||
class/class_video
|
||||
class/winusb
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: 综合例程
|
||||
|
||||
demo/usb2uart
|
||||
demo/mouse_keyboard
|
||||
demo/msc_boot
|
||||
demo/video
|
||||
demo/speaker_mic
|
||||
demo/daplink
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Porting 说明
|
||||
|
||||
porting
|
2
docs/_build/html/_sources/porting.rst.txt
vendored
@ -1,2 +0,0 @@
|
||||
Porting 编写说明
|
||||
==============================
|
@ -1,2 +0,0 @@
|
||||
基于 BL702 开发指南
|
||||
=========================
|
@ -1,2 +0,0 @@
|
||||
基于 CH32V307 开发指南
|
||||
=========================
|
@ -1,84 +0,0 @@
|
||||
# RT-Thread based Software Package Development Guide
|
||||
|
||||
[中文版](rt-thread_zh.md)
|
||||
|
||||
To use CherryUSB package, you need to select it in the RT-Thread package manager. The specific path is as follows:
|
||||
|
||||
```
|
||||
-> RT-Thread online packages
|
||||
-> system packages
|
||||
--- CherryUSB: tiny and portable USB stack for embedded system with USB IP
|
||||
|
||||
CherryUSB Options ---->
|
||||
USB Speed (FS) --->
|
||||
[*] Enable usb device mode
|
||||
[*] Enable usb cdc acm device
|
||||
[ ] Enable usb hid device
|
||||
[ ] Enable usb dfu device
|
||||
[ ] Enable usb msc device
|
||||
[ ] Enable usb hub device
|
||||
[ ] Enable usb audio device
|
||||
[ ] Enable usb video device
|
||||
|
||||
Version (latest) --->
|
||||
```
|
||||
|
||||
## Based ON STM32 Platform
|
||||
|
||||
Please note that stm32 series have two usb ip. For usb ip, like stm32f0、stm32f1、stm32f3, for usb otg ip(as we know it is from **synopsys**),like stm32f4、stm32f7 and so on.
|
||||
|
||||
### Use USB Device
|
||||
|
||||
- Firstly,you should have a bsp project,and then go to `board\CubeMX_Config` directory, open file that suffix name with `.ioc` in **STM32CubeMX**.
|
||||
- Enable **USB** or **USB_OTG_FS** or **USB_OTG_HS** in **Connectivity** List,enable USB IRQ in **NVIC Setting**.
|
||||
|
||||

|
||||
|
||||
- Enable USB Clock for 48Mhz in **Clock configuration**.
|
||||
|
||||

|
||||
|
||||
- Generate code.
|
||||
- Copy **SystemClock_Config** into **board.c**.
|
||||
- ~~Copy **MX_USB_OTG_FS_PCD_Init** or **MX_USB_OTG_HS_PCD_Init** into **main.c** if you use **usb_dc_hal.c**.Also, USB Irq from **it.c** needs the same.~~
|
||||
- Implement **usb_dc_low_level_init** and copy codes in from ``HAL_PCD_MspInit``.
|
||||
|
||||
```
|
||||
void usb_dc_low_level_init(void)
|
||||
{
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_USB_CLK_ENABLE();
|
||||
/* USB interrupt Init */
|
||||
HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
- Implement **printf** or modify with **rt_kprintf** in **usb_utils.h**, usb stack needs.
|
||||
- Now we can call some functions provided by **usb_stack**.Your should register descriptors、interfaces and endpoint callback firstly, and then call `usb_dc_init`. Example is as follows:
|
||||
|
||||
```
|
||||
int main(void)
|
||||
{
|
||||
extern void cdc_init(void);
|
||||
cdc_init();
|
||||
usb_dc_init();
|
||||
while (1)
|
||||
{
|
||||
uint8_t data_buffer[10] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x31, 0x32, 0x33, 0x34, 0x35 };
|
||||
usbd_ep_write(0x81, data_buffer, 10, NULL);
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- How to register class you can go to [stm32 class examples](https://github.com/sakumisu/usb_stack/tree/master/demo/stm32/stm32f103c8t6/example) for a reference.
|
||||
|
||||
### CDC Demo Demonstration
|
||||
|
||||

|
||||
|
||||
### Video manual
|
||||
|
||||
If you have problem from steps above, you can see this video:[Use USB Stack in RT-Thread package manager](https://www.bilibili.com/video/BV1Ef4y1t73d?p=26)。
|
@ -1,148 +0,0 @@
|
||||
# 基于 RT-Thread 软件包开发指南
|
||||
|
||||
[English Version](rt-thread.md)
|
||||
|
||||
使用 CherryUSB package 需要在 RT-Thread 的包管理器中选择它,具体路径如下:
|
||||
|
||||
```
|
||||
-> RT-Thread online packages
|
||||
-> system packages
|
||||
--- CherryUSB: tiny and portable USB stack for embedded system with USB IP
|
||||
|
||||
CherryUSB Options ---->
|
||||
USB Speed (FS) --->
|
||||
[*] Enable usb device mode
|
||||
[ ] Enable usb host mode
|
||||
[*] Enable usb cdc acm device
|
||||
[ ] Enable usb hid device
|
||||
[ ] Enable usb dfu device
|
||||
[ ] Enable usb msc device
|
||||
[ ] Enable usb hub device
|
||||
[ ] Enable usb audio device
|
||||
[ ] Enable usb video device
|
||||
|
||||
Version (latest) --->
|
||||
```
|
||||
|
||||
## 基于 STM32 平台
|
||||
|
||||
STM32 系列单片机有两种 USB IP,分别是 USB IP 和 USB OTG IP。其中 USB IP,例如 STM32F0、STM32F1、STM32F3等等,USB OTG IP(我们都知道用的是 **synopsys** 公司的)的有 STM32F4、STM32F7、STM32H7等等。当前如果你需要使用 USB Device 功能,porting 接口提供了两种,一种是适配 USB IP的 **fsdev**,另一种是适配 USB OTG IP 的 **synopsys**。
|
||||
|
||||
### 使用 USB Device 功能
|
||||
|
||||
- 首先,你需要有一个 bsp 工程,之后进入到 `board\CubeMX_Config` 目录下,使用 **STM32CubeMX** 打开后缀名为 `.ioc` 的文件。
|
||||
- 进入 **Connectivity** 选项,选择 **USB** 或者 **USB_OTG_FS** 或者 **USB_OTG_HS**,并使能 device 功能,在 **NVIC Setting** 中开启 USB 中断。
|
||||
|
||||

|
||||
|
||||
- 在 **Clock configuration** 栏配置 USB 时钟为 48Mhz.
|
||||
|
||||

|
||||
|
||||
- 点击 **Generate code**。
|
||||
- 复制 **SystemClock_Config** 函数内容到 **board.c** 中。
|
||||
- 实现 ``usb_dc_low_level_init``,并将 ``HAL_PCD_MspInit`` 里面内容复制进来,例如:
|
||||
|
||||
```
|
||||
void usb_dc_low_level_init(void)
|
||||
{
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_USB_CLK_ENABLE();
|
||||
/* USB interrupt Init */
|
||||
HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
- 由于协议栈默认使用 `printf` 和 `malloc` 和 `free`,所以需要开启 libc 支持或者自己实现。
|
||||

|
||||
|
||||
- 使用 **menuconfig** 配置 **CherryUSB** 软件包,使能 usb device 并勾选需要的 device class。
|
||||

|
||||
|
||||
- 现在我们可以调用 CherryUSB 中的函数来注册描述符、接口、端点中断,并调用 `usb_dc_init`,示例如下:
|
||||
|
||||
```
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern void usb_dc_init(void);
|
||||
int main(void)
|
||||
{
|
||||
extern void cdc_init(void);
|
||||
cdc_init();
|
||||
usb_dc_init();
|
||||
while (1)
|
||||
{
|
||||
uint8_t data_buffer[10] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x31, 0x32, 0x33, 0x34, 0x35 };
|
||||
usbd_ep_write(0x81, data_buffer, 10, NULL);
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
- 关于如何注册 class 类可以参考 [stm32 class examples](https://github.com/sakumisu/usb_stack/tree/master/demo/stm32/stm32f103c8t6/example)。
|
||||
|
||||
### 使用 USB Host 功能
|
||||
|
||||
- 首先,你需要有一个 bsp 工程,之后进入到 `board\CubeMX_Config` 目录下,使用 **STM32CubeMX** 打开后缀名为 `.ioc` 的文件。
|
||||
- 进入 **Connectivity** 选项,选择 **USB_OTG_FS** 或者 **USB_OTG_HS**,并使能 **host only** 功能,在 **NVIC Setting** 中开启 OTG GLOBAL 中断,其余两个端点中断不需要。
|
||||
|
||||

|
||||
|
||||
- 在 **Clock configuration** 栏配置 USB 时钟为 48Mhz.
|
||||
- 点击 **Generate code**。
|
||||
- 复制 **SystemClock_Config** 函数内容到 **board.c** 中。
|
||||
- 修改 **usb_hc_synopsys.c** 中 HAL 库头文件包含,例如 `#include "stm32f4xx_hal.h"`。
|
||||
- 手动增加 **xxx_hal_hcd.c** 和 **xxx_ll_usb.c** 文件
|
||||
- 由于协议栈默认使用 `printf` 和 `malloc` 和 `free`,所以需要开启 libc 支持或者自己实现。
|
||||

|
||||
|
||||
- 使用 **menuconfig** 配置 **CherryUSB** 软件包,使能 usb host(默认加载所有支持的 class)。
|
||||

|
||||
|
||||
- `main.c` 中调用 `usbh_initialize` 初始化 host 协议栈。
|
||||
|
||||
```
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
#include "usbh_core.h"
|
||||
/* defined the LED0 pin: PH10 */
|
||||
#define LED0_PIN GET_PIN(H, 10)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* set LED0 pin mode to output */
|
||||
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
|
||||
usbh_initialize();
|
||||
while (1)
|
||||
{
|
||||
rt_pin_write(LED0_PIN, PIN_HIGH);
|
||||
rt_thread_mdelay(500);
|
||||
rt_pin_write(LED0_PIN, PIN_LOW);
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
### Demo 演示
|
||||
|
||||
- cdc acm device demo
|
||||
|
||||

|
||||
- host demo
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
### 视频教程
|
||||
|
||||
如果对上述步骤还有问题,可以参考 [协议栈在 RT-Thread 包管理器中的使用](https://www.bilibili.com/video/BV1Ef4y1t73d?p=26)。
|
@ -1,2 +0,0 @@
|
||||
基于 STM32F429 开发指南
|
||||
=========================
|
232
docs/_build/html/_sources/usb/usb_basic.rst.txt
vendored
@ -1,232 +0,0 @@
|
||||
USB 基本概念
|
||||
===========================
|
||||
|
||||
本文主要对 USB 官方手册 `usb2.0.pdf <https://www.usb.org/document-library/usb-20-specification>`_ 中提供的第五章、第七章、第八章、第九章进行讲解。
|
||||
|
||||
简介
|
||||
---------
|
||||
|
||||
USB 是什么?干什么用的?有什么优点?这些大家可以百度,我就不提了。主要先说 USB 的接口和速度根据不同的 USB 版本的分类,如图所示:
|
||||
|
||||
.. figure:: img/overview1.png
|
||||
|
||||
其次是 USB 需要满足的电平标准,有了电平标准后,下面说的信号状态就可以进行分类了。USB2.0 和 USB3.0 支持的电压范围和最大电流如下:
|
||||
|
||||
.. figure:: img/overview2.png
|
||||
|
||||
USB 信号状态
|
||||
-----------------
|
||||
|
||||
首先我们需要了解的是 USB 的电气特性中的 Signaling Level,也就是信号状态。USB 主要是靠 D+ 和 D- 来实现不同的信号状态,然后进行通信。官方手册 7.1.7 中列举出了低速、全速和高速时的信号状态对应的 D+ 和 D- 需要满足的要求。
|
||||
|
||||
.. figure:: img/1.png
|
||||
.. figure:: img/2.png
|
||||
.. figure:: img/3.png
|
||||
|
||||
- **差分 0 和差分 1**: 这两个状态用于通过 USB 进行的通用数据通信。当 D+线为高电平、 D-线为低电平时,该状态为差分 1。当 D+线为低电平、 D-线为高电平时,该状态为差分 0。
|
||||
- **J 状态和 K 状态**: 除了差分信号外, USB 规范还定义了其他两个差分状态: J 状态和 K 状态。它们的定义由设备速度决定。在全速和高速设备上, J 状态为差分 1 而 K 状态是差分 0。在低速设备上,该情况则相反。
|
||||
- **单端 0( SE0)**: 在 D+和 D-均为低电平时所发生的状态。该状态表示一个复位、断连或数据包的结束。
|
||||
- **单端 1( SE1)**: 在 D+和 D-均为高电平时发生的状态。不会故意生成该状态,并且不能在 USB 设计中出现。
|
||||
- **闲置**: 必须在发送一个数据包的前后发生的状态。如果一个数据线为低电平,而另一个数据线为高电平,则表示闲置状态。高电平和低电平的定义由设备的速度决定。在全速设备上,闲置状态是指 D+为高电平、 D-为低电平。在低速设备上,该情况则相反。
|
||||
- **恢复**: 用于使设备从挂起状态唤醒。通过发送一个 K 状态实现该操作。
|
||||
- **数据包的开始( SOP)**: 当 D+和 D-线从闲置状态转换到 K 状态时,将在开始低速或全速数据包前发生。
|
||||
- **数据包的结束( EOP)**: 在低速或全速数据包结束时发生。当 SE0 状态持续两位时间(后面的内容将介绍位时间)以及 J 状态持续 1 位时间时,将发生 EOP。
|
||||
- **复位**: 在 SE0 状态持续 10 ms 时发生。在 SE0 至少持续 2.5 ms 后,该设备会复位,并开始进入复位状态。
|
||||
- **保持活动( Keep Alive)**: 在低速设备中使用的信号。低速设备缺少了一个帧起始数据包(用于防止挂起状态)。每次经过 1 ms,它们都会使用一个 EOP 来防止设备进入挂起状态。
|
||||
|
||||
.. note::这里需要注意的一点就是, J K状态和差分0/1,对于低速来说,和全速/高速是相反的。
|
||||
|
||||
下面我们通过一个波形,来区分这些信号状态:
|
||||
|
||||
.. figure:: img/4.png
|
||||
|
||||
- 第一个红框,可以看出是一个数据包的开始,并且假设这是一个全速设备,那么D+ 为高,D- 为低,是一个闲置状态。
|
||||
- 第二个红框,D+为低,D- 为高,说明是一个 K 状态,由 闲置转 K 状态说明他是一个 SOP。
|
||||
- 第三个红框开始表示数据,表示 JKJKJKJKJK。
|
||||
- 第四个红框表示 SE0 ,因为D+和 D-均为低电平。
|
||||
- 第五个红框,而 SE0 持续了一段时间后,变成了 D+高,D- 低,说明他是一个 J 状态,从 SE0 切换成 J 状态,说明他是一个 EOP。
|
||||
|
||||
USB 速度识别
|
||||
---------------------
|
||||
|
||||
USB 的速度是如何判定的? 这个见手册 7.1.5.1。USB 的速度检测主要是靠 D+ 和 D-线上拉 1.5K决定,如果 D+上拉1.5k,则该设备为全速设备,如果 D-上拉1.5k,则为低速设备。而高速设备初始是以一个全速设备的身份出现,和全速设备一样,D+线上有一个1.5k的上拉电阻。USB2.0的hub把它当作一个全速设备,之后,hub 和设备通过一系列握手信号确认双方的身份,最终判定该设备为高速设备。
|
||||
|
||||
.. figure:: img/5.png
|
||||
|
||||
USB 连接与断开检测
|
||||
---------------------
|
||||
|
||||
那么 当我们的设备插上 USB 主机时,主机是如何知道有设备插入或者拔出呢?手册 7.1.7.3 给出了答案,如图所示:
|
||||
|
||||
.. figure:: img/6.png
|
||||
.. figure:: img/7.png
|
||||
|
||||
首先是连接检测,主机检测到某一个数据线电平拉高保持了一段时间,就认为有设备连接上来了。低速设备连接时,主机会检测到D-线被拉高,全速/高速设备连接时,主机会检测到D+线被拉高。
|
||||
而断开检测,则是主机端D+、D-数据线上的下拉电阻起作用,断开后使得二者都在低电平;当低电平持续 TDDIS 时间就会被主机认为是断开状态。上图中,TDDIS在2到2.5us之间。
|
||||
|
||||
USB 电源
|
||||
---------------------
|
||||
|
||||
作为 USB 电源时, USB 设备可被划分为两种设备类型:总线供电和自供电。
|
||||
|
||||
- 总线供电是 USB 设计的一个优势。由于设备通过总线供电,因此不需要使用笨重的内部或外部电源,它仍能够维持自身操作。总线可由主机或集线器供电。使用某个总线供电的设备时,用户将设备配置为某种状态前必须考虑其功耗。
|
||||
- 自供电设备通过使用外部电源(如直流电源适配器或电池)为自己供电。自供电设备在进行设计的过程中需要考虑到一些注意事项。 USB 规范要求自供电设备一直监控自己的 VBUS 线。 VBUS 不存在的时间内,设备必须断开提供给 D+/D-线上的上拉电阻的电源,从而防止向主机或集线器供电。 否则,会导致 USB 合规性测试发生失败。但是自供电集线器能够从总线获得最多 100 mA 的电流。
|
||||
|
||||
USB 设备状态
|
||||
---------------------
|
||||
|
||||
在 USB 插上主机的那一刻, USB 设备本身的设备状态是会变化的。而这个设备状态,后面如果学习到枚举过程,可以知道,其实这段变化描述的就是枚举过程。这部分见手册 9.1.1。
|
||||
|
||||
.. figure:: img/9.png
|
||||
|
||||
- 连接状态: 当将某个设备插入到主机/集线器,但主机/集线器不给 VBUS 线供电时,会出现这种状态。它通常在集线器检测到一个过流事件时出现。虽然仍连接着设备,但主机移除了供给它的电源。
|
||||
- 供电: 某个设备被连接到 USB 上并得到供电,但仍未接收到一个复位请求。
|
||||
- 默认: 某个设备被连接到 USB 上、得到供电,并且由主机进行了复位。这时,设备没有任何设备地址。 设备会响应地址 0。
|
||||
- 地址: 某个设备被连接到 USB、得到供电、被复位,并且有一个唯一的地址。但是设备仍未得到配置。
|
||||
- 配置: 设备已经连接到 USB、得到供电、被复位、具有唯一的地址、得到配置,但尚未进入挂起状态。此时,总线供电设备能够消耗超过 100 mA 的电流。
|
||||
- 挂起: 如上面所述,设备已经建立好了连接,并且得到配置,但在 3 ms 时间内不会进行任意总线操作。
|
||||
|
||||
翻译成中文图就是:
|
||||
|
||||
.. figure:: img/10.png
|
||||
|
||||
USB 编码与位填充
|
||||
---------------------
|
||||
|
||||
首先,USB 的数据是串行发送的,就像 UART、I2C、SPI 等等,连续的01 信号只通过一根数据线发送给接受者。但是因为发送者和接收者运行的频率不一样,信号的同步就是个问题,比如,接受者接收到了一个持续一段时间的低电平,无法得知这究竟是代表了 5 个 0 还是 1000 个 0。一个解决办法,就是在传输数据信号的同时,附加一个时钟信号,用来同步两端的传输,接受者在时钟信号的辅助下对数据信号采样,就可以正确解析出发送的数据了,比如 I2C 就是这样做的,SDA 来传输数据,SCL 来传输同步时钟:
|
||||
|
||||
.. figure:: img/11.png
|
||||
|
||||
虽然这样解决了问题,但是却需要附加一根时钟信号线来传输时钟。因为USB没有时钟信号,有没有不需要附加的时钟信号,也能保持两端的同步呢?
|
||||
有的,这就是 RZ 编码(Return-to-zero Code),也叫做归零编码。
|
||||
|
||||
RZ 编码(Return-to-zero Code)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
RZ 编码(Return-to-zero Code),也叫做归零编码。在 RZ 编码中,正电平代表逻辑 1,负电平代表逻辑 0,并且,每传输完一位数据,信号返回到零电平,也就是说,信号线上会出现 3 种电平:正电平、负电平、零电平。
|
||||
|
||||
.. figure:: img/12.png
|
||||
|
||||
从图上就可以看出来,因为每位传输之后都要归零,所以接受者只要在信号归零后采样即可,这样就不在需要单独的时钟信号。实际上, RZ 编码就是相当于把时钟信号用归零编码在了数据之内。这样的信号也叫做自同步(self-clocking)信号。
|
||||
这样虽然省了时钟数据线,但是还是有缺点的,因为在 RZ 编码中,大部分的数据带宽,都用来传输“归零”而浪费掉了。
|
||||
|
||||
NRZ 编码(Non-return-to-zero Code)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
去掉这个归零步骤,NRZ 编码(Non-return-to-zero Code)就出现了,和 RZ 的区别就是 NRZ 是不需要归零的。
|
||||
|
||||
.. figure:: img/13.png
|
||||
|
||||
NRZI 编码(Non-Return-to-Zero Inverted Code)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
NRZI 编码(Non-Return-to-Zero Inverted Code)和 NRZ 的区别就是 NRZI 用信号的翻转代表一个逻辑,信号保持不变代表另外一个逻辑。这个见手册 7.1.8。
|
||||
|
||||
.. figure:: img/14.png
|
||||
|
||||
如图所示,可以得出一个简单的记忆方式:遇到 0 的边沿电平就翻转,遇到 1 的边沿则不变。
|
||||
|
||||
位填充(bit-stuffing)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
但是,这样还是会有一个问题,就是虽然接受者可以主动和发送者的频率匹配,但是两者之间总会有误差。假如数据信号是 1000 个逻辑 1,经过 USB 的 NRZI 编码之后,就是很长一段没有变化的电平,在这种情况下,即使接受者的频率和发送者相差千分之一,就会造成把数据采样成 1001 个或者 999 个 1了。
|
||||
USB 对这个问题的解决办法,就是强制插 0,也就是(位填充)bit-stuffing,如果要传输的数据中有 6个连续的 1,发送前就会在第 6 个 1 后面强制插入一个 0,让发送的信号强制出现翻转,从而强制接受者进行频率调整。
|
||||
接受者只要删除 6 个连续 1 之后的 0,就可以恢复原始的数据了。这部分见手册 7.1.9。
|
||||
|
||||
.. figure:: img/15.png
|
||||
.. figure:: img/16.png
|
||||
.. figure:: img/17.png
|
||||
|
||||
在数据被NRZI编码之前,在数据流中每六个连续的1之后插入一个0,以强制NRZI数据流中的过渡,这使接收器逻辑至少每七位有一次数据转换,以保证数据和时钟的锁定。比特填充是从同步模式开始启用。结束同步模式的数据 "一 "被算作是序列中的第一个 "一"。序列中的第一个。除了高速EOP期间,发射器的位填充总是被强制执行。如果需要按照
|
||||
位填充规则的要求,零位将被插入,即使它是数据包结束(EOP)信号前的最后一位。接收器必须对NRZI数据进行解码,识别填充位,并将其丢弃。
|
||||
|
||||
USB 字段(域)
|
||||
---------------------
|
||||
|
||||
USB 字段构成了 USB 通信中最基本也是最小的单元,后面的包、事务,最根本都是由字段构成,而字段又是由比特构成。字段部分见手册 8.1。
|
||||
|
||||
.. note:: USB 的比特先行模式是按照 LSB 先行原则。
|
||||
|
||||
同步字段
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
在 USB 系统中,主机和设备不是共享一个时钟,这使得接收方没办法准确知道发送方什么时候发送数据,尽管能检测到SOP,但是远远不够,所有这个时候就需要同步字段,使得接收方和发送方收发过程中保持同步,所以任何一个包都要以同步字段开始。同步字段0x01,经过编码以后就是01010100B。
|
||||
|
||||
.. figure:: img/18.png
|
||||
|
||||
包标识符字段
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
PID 由一个四位数据包类型字段和一个四位校验字段组成,占用 8 个bit,如图所示。 PID指示数据包的类型,并通过推断,数据包的格式和应用于数据包的错误检测类型包。 PID的四位校验字段是通过执行分组类型字段的一个补码来生成,从而确保PID的可靠解码,以便正确解释分组的其余部分,如果四个PID校验位不是它们各自的分组标识符位的补码,则存在PID错误。
|
||||
|
||||
.. figure:: img/19.png
|
||||
|
||||
既然是 4个比特,说明了 PID 类型可以分为16种,从16种中,又细分成4类:令牌 PID,数据 PID,握手 PID 和特殊 PID。
|
||||
|
||||
.. figure:: img/20.png
|
||||
|
||||
地址字段
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
地址字段又分为设备地址字段和端点地址字段,其中设备地址字段占用 7 个bit,除去0 地址,主机可以分配的地址有 127个。
|
||||
|
||||
.. figure:: img/21.png
|
||||
|
||||
端点地址字段占用 4个 bit,总共可以提供 16 个端点。
|
||||
|
||||
.. figure:: img/22.png
|
||||
|
||||
帧号字段
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
帧号字段占用 11 个bit,主机每发出一个帧,帧号都会加1,如图所示。而高速设备中,帧中又包含微帧,1帧=8微帧,微帧则是加0.1。关于帧和微帧的概念,后续补充。
|
||||
|
||||
.. figure:: img/23.png
|
||||
|
||||
数据字段
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
CRC 字段
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
USB 包
|
||||
---------------------
|
||||
|
||||
令牌包
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
数据包
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
握手包
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
特殊数据包
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
USB 事务
|
||||
---------------------
|
||||
|
||||
SETUP 事务
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
IN 事务
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
OUT 事务
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
特殊事务
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
USB 传输
|
||||
---------------------
|
||||
|
||||
控制传输
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
批量传输
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
中断传输
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
同步传输
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
@ -1,2 +0,0 @@
|
||||
USB 描述符
|
||||
===========================
|
@ -1,2 +0,0 @@
|
||||
USB 枚举
|
||||
===========================
|
@ -1,2 +0,0 @@
|
||||
USB 设备请求
|
||||
===========================
|
904
docs/_build/html/_static/basic.css
vendored
@ -1,904 +0,0 @@
|
||||
/*
|
||||
* basic.css
|
||||
* ~~~~~~~~~
|
||||
*
|
||||
* Sphinx stylesheet -- basic theme.
|
||||
*
|
||||
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
/* -- main layout ----------------------------------------------------------- */
|
||||
|
||||
div.clearer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
div.section::after {
|
||||
display: block;
|
||||
content: '';
|
||||
clear: left;
|
||||
}
|
||||
|
||||
/* -- relbar ---------------------------------------------------------------- */
|
||||
|
||||
div.related {
|
||||
width: 100%;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
div.related h3 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.related ul {
|
||||
margin: 0;
|
||||
padding: 0 0 0 10px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
div.related li {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.related li.right {
|
||||
float: right;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/* -- sidebar --------------------------------------------------------------- */
|
||||
|
||||
div.sphinxsidebarwrapper {
|
||||
padding: 10px 5px 0 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
float: left;
|
||||
width: 230px;
|
||||
margin-left: -100%;
|
||||
font-size: 90%;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap : break-word;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul ul,
|
||||
div.sphinxsidebar ul.want-points {
|
||||
margin-left: 20px;
|
||||
list-style: square;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar form {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #98dbcc;
|
||||
font-family: sans-serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox form.search {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="text"] {
|
||||
float: left;
|
||||
width: 80%;
|
||||
padding: 0.25em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="submit"] {
|
||||
float: left;
|
||||
width: 20%;
|
||||
border-left: none;
|
||||
padding: 0.25em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* -- search page ----------------------------------------------------------- */
|
||||
|
||||
ul.search {
|
||||
margin: 10px 0 0 20px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul.search li {
|
||||
padding: 5px 0 5px 20px;
|
||||
background-image: url(file.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 7px;
|
||||
}
|
||||
|
||||
ul.search li a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.search li p.context {
|
||||
color: #888;
|
||||
margin: 2px 0 0 30px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
ul.keywordmatches li.goodmatch a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* -- index page ------------------------------------------------------------ */
|
||||
|
||||
table.contentstable {
|
||||
width: 90%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.contentstable p.biglink {
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
a.biglink {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
span.linkdescr {
|
||||
font-style: italic;
|
||||
padding-top: 5px;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
/* -- general index --------------------------------------------------------- */
|
||||
|
||||
table.indextable {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.indextable td {
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
table.indextable ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
table.indextable > tbody > tr > td > ul {
|
||||
padding-left: 0em;
|
||||
}
|
||||
|
||||
table.indextable tr.pcap {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
table.indextable tr.cap {
|
||||
margin-top: 10px;
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
img.toggler {
|
||||
margin-right: 3px;
|
||||
margin-top: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
div.modindex-jumpbox {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin: 1em 0 1em 0;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
div.genindex-jumpbox {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin: 1em 0 1em 0;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
/* -- domain module index --------------------------------------------------- */
|
||||
|
||||
table.modindextable td {
|
||||
padding: 2px;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
/* -- general body styles --------------------------------------------------- */
|
||||
|
||||
div.body {
|
||||
min-width: 450px;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
div.body p, div.body dd, div.body li, div.body blockquote {
|
||||
-moz-hyphens: auto;
|
||||
-ms-hyphens: auto;
|
||||
-webkit-hyphens: auto;
|
||||
hyphens: auto;
|
||||
}
|
||||
|
||||
a.headerlink {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
a.brackets:before,
|
||||
span.brackets > a:before{
|
||||
content: "[";
|
||||
}
|
||||
|
||||
a.brackets:after,
|
||||
span.brackets > a:after {
|
||||
content: "]";
|
||||
}
|
||||
|
||||
h1:hover > a.headerlink,
|
||||
h2:hover > a.headerlink,
|
||||
h3:hover > a.headerlink,
|
||||
h4:hover > a.headerlink,
|
||||
h5:hover > a.headerlink,
|
||||
h6:hover > a.headerlink,
|
||||
dt:hover > a.headerlink,
|
||||
caption:hover > a.headerlink,
|
||||
p.caption:hover > a.headerlink,
|
||||
div.code-block-caption:hover > a.headerlink {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
div.body p.caption {
|
||||
text-align: inherit;
|
||||
}
|
||||
|
||||
div.body td {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.first {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
p.rubric {
|
||||
margin-top: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
img.align-left, figure.align-left, .figure.align-left, object.align-left {
|
||||
clear: left;
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
img.align-right, figure.align-right, .figure.align-right, object.align-right {
|
||||
clear: right;
|
||||
float: right;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
img.align-center, figure.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
img.align-default, figure.align-default, .figure.align-default {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.align-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-default {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* -- sidebars -------------------------------------------------------------- */
|
||||
|
||||
div.sidebar,
|
||||
aside.sidebar {
|
||||
margin: 0 0 0.5em 1em;
|
||||
border: 1px solid #ddb;
|
||||
padding: 7px;
|
||||
background-color: #ffe;
|
||||
width: 40%;
|
||||
float: right;
|
||||
clear: right;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
p.sidebar-title {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.admonition, div.topic, blockquote {
|
||||
clear: left;
|
||||
}
|
||||
|
||||
/* -- topics ---------------------------------------------------------------- */
|
||||
|
||||
div.topic {
|
||||
border: 1px solid #ccc;
|
||||
padding: 7px;
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
p.topic-title {
|
||||
font-size: 1.1em;
|
||||
font-weight: bold;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* -- admonitions ----------------------------------------------------------- */
|
||||
|
||||
div.admonition {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
div.admonition dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
margin: 0px 10px 5px 0px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.body p.centered {
|
||||
text-align: center;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
/* -- content of sidebars/topics/admonitions -------------------------------- */
|
||||
|
||||
div.sidebar > :last-child,
|
||||
aside.sidebar > :last-child,
|
||||
div.topic > :last-child,
|
||||
div.admonition > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.sidebar::after,
|
||||
aside.sidebar::after,
|
||||
div.topic::after,
|
||||
div.admonition::after,
|
||||
blockquote::after {
|
||||
display: block;
|
||||
content: '';
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* -- tables ---------------------------------------------------------------- */
|
||||
|
||||
table.docutils {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
border: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-default {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table caption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
table caption span.caption-text {
|
||||
}
|
||||
|
||||
table.docutils td, table.docutils th {
|
||||
padding: 1px 8px 1px 5px;
|
||||
border-top: 0;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
table.footnote td, table.footnote th {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
table.citation td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
th > :first-child,
|
||||
td > :first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
th > :last-child,
|
||||
td > :last-child {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
/* -- figures --------------------------------------------------------------- */
|
||||
|
||||
div.figure, figure {
|
||||
margin: 0.5em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
div.figure p.caption, figcaption {
|
||||
padding: 0.3em;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-number,
|
||||
figcaption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-text,
|
||||
figcaption span.caption-text {
|
||||
}
|
||||
|
||||
/* -- field list styles ----------------------------------------------------- */
|
||||
|
||||
table.field-list td, table.field-list th {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
.field-list ul {
|
||||
margin: 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.field-list p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.field-name {
|
||||
-moz-hyphens: manual;
|
||||
-ms-hyphens: manual;
|
||||
-webkit-hyphens: manual;
|
||||
hyphens: manual;
|
||||
}
|
||||
|
||||
/* -- hlist styles ---------------------------------------------------------- */
|
||||
|
||||
table.hlist {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
table.hlist td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* -- object description styles --------------------------------------------- */
|
||||
|
||||
.sig {
|
||||
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
||||
}
|
||||
|
||||
.sig-name, code.descname {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.sig-name {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
code.descname {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.sig-prename, code.descclassname {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.optional {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.sig-paren {
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
.sig-param.n {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* C++ specific styling */
|
||||
|
||||
.sig-inline.c-texpr,
|
||||
.sig-inline.cpp-texpr {
|
||||
font-family: unset;
|
||||
}
|
||||
|
||||
.sig.c .k, .sig.c .kt,
|
||||
.sig.cpp .k, .sig.cpp .kt {
|
||||
color: #0033B3;
|
||||
}
|
||||
|
||||
.sig.c .m,
|
||||
.sig.cpp .m {
|
||||
color: #1750EB;
|
||||
}
|
||||
|
||||
.sig.c .s, .sig.c .sc,
|
||||
.sig.cpp .s, .sig.cpp .sc {
|
||||
color: #067D17;
|
||||
}
|
||||
|
||||
|
||||
/* -- other body styles ----------------------------------------------------- */
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal;
|
||||
}
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha;
|
||||
}
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha;
|
||||
}
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman;
|
||||
}
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman;
|
||||
}
|
||||
|
||||
:not(li) > ol > li:first-child > :first-child,
|
||||
:not(li) > ul > li:first-child > :first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
:not(li) > ol > li:last-child > :last-child,
|
||||
:not(li) > ul > li:last-child > :last-child {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
ol.simple ol p,
|
||||
ol.simple ul p,
|
||||
ul.simple ol p,
|
||||
ul.simple ul p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
ol.simple > li:not(:first-child) > p,
|
||||
ul.simple > li:not(:first-child) > p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
ol.simple p,
|
||||
ul.simple p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
dl.footnote > dt,
|
||||
dl.citation > dt {
|
||||
float: left;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
dl.footnote > dd,
|
||||
dl.citation > dd {
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
|
||||
dl.footnote > dd:after,
|
||||
dl.citation > dd:after {
|
||||
content: "";
|
||||
clear: both;
|
||||
}
|
||||
|
||||
dl.field-list {
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(30%) auto;
|
||||
}
|
||||
|
||||
dl.field-list > dt {
|
||||
font-weight: bold;
|
||||
word-break: break-word;
|
||||
padding-left: 0.5em;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
dl.field-list > dt:after {
|
||||
content: ":";
|
||||
}
|
||||
|
||||
dl.field-list > dd {
|
||||
padding-left: 0.5em;
|
||||
margin-top: 0em;
|
||||
margin-left: 0em;
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
dd > :first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
dd ul, dd table {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 10px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
dl > dd:last-child,
|
||||
dl > dd:last-child > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
dt:target, span.highlighted {
|
||||
background-color: #fbe54e;
|
||||
}
|
||||
|
||||
rect.highlighted {
|
||||
fill: #fbe54e;
|
||||
}
|
||||
|
||||
dl.glossary dt {
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.versionmodified {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.system-message {
|
||||
background-color: #fda;
|
||||
padding: 5px;
|
||||
border: 3px solid red;
|
||||
}
|
||||
|
||||
.footnote:target {
|
||||
background-color: #ffa;
|
||||
}
|
||||
|
||||
.line-block {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.line-block .line-block {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
.guilabel, .menuselection {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.accelerator {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.classifier {
|
||||
font-style: oblique;
|
||||
}
|
||||
|
||||
.classifier:before {
|
||||
font-style: normal;
|
||||
margin: 0.5em;
|
||||
content: ":";
|
||||
}
|
||||
|
||||
abbr, acronym {
|
||||
border-bottom: dotted 1px;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
/* -- code displays --------------------------------------------------------- */
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
overflow-y: hidden; /* fixes display issues on Chrome browsers */
|
||||
}
|
||||
|
||||
pre, div[class*="highlight-"] {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
span.pre {
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
-webkit-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
div[class*="highlight-"] {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
td.linenos pre {
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
table.highlighttable {
|
||||
display: block;
|
||||
}
|
||||
|
||||
table.highlighttable tbody {
|
||||
display: block;
|
||||
}
|
||||
|
||||
table.highlighttable tr {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
table.highlighttable td {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
table.highlighttable td.linenos {
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
table.highlighttable td.code {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.highlight .hll {
|
||||
display: block;
|
||||
}
|
||||
|
||||
div.highlight pre,
|
||||
table.highlighttable pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.code-block-caption + div {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.code-block-caption {
|
||||
margin-top: 1em;
|
||||
padding: 2px 5px;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
div.code-block-caption code {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
table.highlighttable td.linenos,
|
||||
span.linenos,
|
||||
div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
|
||||
user-select: none;
|
||||
-webkit-user-select: text; /* Safari fallback only */
|
||||
-webkit-user-select: none; /* Chrome/Safari */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* IE10+ */
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-number {
|
||||
padding: 0.1em 0.3em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-text {
|
||||
}
|
||||
|
||||
div.literal-block-wrapper {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
code.xref, a code {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.viewcode-link {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.viewcode-back {
|
||||
float: right;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
div.viewcode-block:target {
|
||||
margin: -1px -10px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
/* -- math display ---------------------------------------------------------- */
|
||||
|
||||
img.math {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div.body div.math p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
span.eqno {
|
||||
float: right;
|
||||
}
|
||||
|
||||
span.eqno a.headerlink {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
div.math:hover a.headerlink {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
/* -- printout stylesheet --------------------------------------------------- */
|
||||
|
||||
@media print {
|
||||
div.document,
|
||||
div.documentwrapper,
|
||||
div.bodywrapper {
|
||||
margin: 0 !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.sphinxsidebar,
|
||||
div.related,
|
||||
div.footer,
|
||||
#top-link {
|
||||
display: none;
|
||||
}
|
||||
}
|
1
docs/_build/html/_static/css/badge_only.css
vendored
@ -1 +0,0 @@
|
||||
.fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}
|
Before Width: | Height: | Size: 434 KiB |
BIN
docs/_build/html/_static/css/fonts/lato-bold.woff
vendored
BIN
docs/_build/html/_static/css/fonts/lato-bold.woff2
vendored
BIN
docs/_build/html/_static/css/fonts/lato-normal.woff
vendored
BIN
docs/_build/html/_static/css/fonts/lato-normal.woff2
vendored
4
docs/_build/html/_static/css/theme.css
vendored
321
docs/_build/html/_static/doctools.js
vendored
@ -1,321 +0,0 @@
|
||||
/*
|
||||
* doctools.js
|
||||
* ~~~~~~~~~~~
|
||||
*
|
||||
* Sphinx JavaScript utilities for all documentation.
|
||||
*
|
||||
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* select a different prefix for underscore
|
||||
*/
|
||||
$u = _.noConflict();
|
||||
|
||||
/**
|
||||
* make the code below compatible with browsers without
|
||||
* an installed firebug like debugger
|
||||
if (!window.console || !console.firebug) {
|
||||
var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
|
||||
"dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
|
||||
"profile", "profileEnd"];
|
||||
window.console = {};
|
||||
for (var i = 0; i < names.length; ++i)
|
||||
window.console[names[i]] = function() {};
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* small helper function to urldecode strings
|
||||
*
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
|
||||
*/
|
||||
jQuery.urldecode = function(x) {
|
||||
if (!x) {
|
||||
return x
|
||||
}
|
||||
return decodeURIComponent(x.replace(/\+/g, ' '));
|
||||
};
|
||||
|
||||
/**
|
||||
* small helper function to urlencode strings
|
||||
*/
|
||||
jQuery.urlencode = encodeURIComponent;
|
||||
|
||||
/**
|
||||
* This function returns the parsed url parameters of the
|
||||
* current request. Multiple values per key are supported,
|
||||
* it will always return arrays of strings for the value parts.
|
||||
*/
|
||||
jQuery.getQueryParameters = function(s) {
|
||||
if (typeof s === 'undefined')
|
||||
s = document.location.search;
|
||||
var parts = s.substr(s.indexOf('?') + 1).split('&');
|
||||
var result = {};
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var tmp = parts[i].split('=', 2);
|
||||
var key = jQuery.urldecode(tmp[0]);
|
||||
var value = jQuery.urldecode(tmp[1]);
|
||||
if (key in result)
|
||||
result[key].push(value);
|
||||
else
|
||||
result[key] = [value];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* highlight a given string on a jquery object by wrapping it in
|
||||
* span elements with the given class name.
|
||||
*/
|
||||
jQuery.fn.highlightText = function(text, className) {
|
||||
function highlight(node, addItems) {
|
||||
if (node.nodeType === 3) {
|
||||
var val = node.nodeValue;
|
||||
var pos = val.toLowerCase().indexOf(text);
|
||||
if (pos >= 0 &&
|
||||
!jQuery(node.parentNode).hasClass(className) &&
|
||||
!jQuery(node.parentNode).hasClass("nohighlight")) {
|
||||
var span;
|
||||
var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
|
||||
if (isInSVG) {
|
||||
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
||||
} else {
|
||||
span = document.createElement("span");
|
||||
span.className = className;
|
||||
}
|
||||
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
|
||||
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
|
||||
document.createTextNode(val.substr(pos + text.length)),
|
||||
node.nextSibling));
|
||||
node.nodeValue = val.substr(0, pos);
|
||||
if (isInSVG) {
|
||||
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
||||
var bbox = node.parentElement.getBBox();
|
||||
rect.x.baseVal.value = bbox.x;
|
||||
rect.y.baseVal.value = bbox.y;
|
||||
rect.width.baseVal.value = bbox.width;
|
||||
rect.height.baseVal.value = bbox.height;
|
||||
rect.setAttribute('class', className);
|
||||
addItems.push({
|
||||
"parent": node.parentNode,
|
||||
"target": rect});
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!jQuery(node).is("button, select, textarea")) {
|
||||
jQuery.each(node.childNodes, function() {
|
||||
highlight(this, addItems);
|
||||
});
|
||||
}
|
||||
}
|
||||
var addItems = [];
|
||||
var result = this.each(function() {
|
||||
highlight(this, addItems);
|
||||
});
|
||||
for (var i = 0; i < addItems.length; ++i) {
|
||||
jQuery(addItems[i].parent).before(addItems[i].target);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/*
|
||||
* backward compatibility for jQuery.browser
|
||||
* This will be supported until firefox bug is fixed.
|
||||
*/
|
||||
if (!jQuery.browser) {
|
||||
jQuery.uaMatch = function(ua) {
|
||||
ua = ua.toLowerCase();
|
||||
|
||||
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(msie) ([\w.]+)/.exec(ua) ||
|
||||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
|
||||
[];
|
||||
|
||||
return {
|
||||
browser: match[ 1 ] || "",
|
||||
version: match[ 2 ] || "0"
|
||||
};
|
||||
};
|
||||
jQuery.browser = {};
|
||||
jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Small JavaScript module for the documentation.
|
||||
*/
|
||||
var Documentation = {
|
||||
|
||||
init : function() {
|
||||
this.fixFirefoxAnchorBug();
|
||||
this.highlightSearchWords();
|
||||
this.initIndexTable();
|
||||
if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) {
|
||||
this.initOnKeyListeners();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* i18n support
|
||||
*/
|
||||
TRANSLATIONS : {},
|
||||
PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; },
|
||||
LOCALE : 'unknown',
|
||||
|
||||
// gettext and ngettext don't access this so that the functions
|
||||
// can safely bound to a different name (_ = Documentation.gettext)
|
||||
gettext : function(string) {
|
||||
var translated = Documentation.TRANSLATIONS[string];
|
||||
if (typeof translated === 'undefined')
|
||||
return string;
|
||||
return (typeof translated === 'string') ? translated : translated[0];
|
||||
},
|
||||
|
||||
ngettext : function(singular, plural, n) {
|
||||
var translated = Documentation.TRANSLATIONS[singular];
|
||||
if (typeof translated === 'undefined')
|
||||
return (n == 1) ? singular : plural;
|
||||
return translated[Documentation.PLURALEXPR(n)];
|
||||
},
|
||||
|
||||
addTranslations : function(catalog) {
|
||||
for (var key in catalog.messages)
|
||||
this.TRANSLATIONS[key] = catalog.messages[key];
|
||||
this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
|
||||
this.LOCALE = catalog.locale;
|
||||
},
|
||||
|
||||
/**
|
||||
* add context elements like header anchor links
|
||||
*/
|
||||
addContextElements : function() {
|
||||
$('div[id] > :header:first').each(function() {
|
||||
$('<a class="headerlink">\u00B6</a>').
|
||||
attr('href', '#' + this.id).
|
||||
attr('title', _('Permalink to this headline')).
|
||||
appendTo(this);
|
||||
});
|
||||
$('dt[id]').each(function() {
|
||||
$('<a class="headerlink">\u00B6</a>').
|
||||
attr('href', '#' + this.id).
|
||||
attr('title', _('Permalink to this definition')).
|
||||
appendTo(this);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* workaround a firefox stupidity
|
||||
* see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075
|
||||
*/
|
||||
fixFirefoxAnchorBug : function() {
|
||||
if (document.location.hash && $.browser.mozilla)
|
||||
window.setTimeout(function() {
|
||||
document.location.href += '';
|
||||
}, 10);
|
||||
},
|
||||
|
||||
/**
|
||||
* highlight the search words provided in the url in the text
|
||||
*/
|
||||
highlightSearchWords : function() {
|
||||
var params = $.getQueryParameters();
|
||||
var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
|
||||
if (terms.length) {
|
||||
var body = $('div.body');
|
||||
if (!body.length) {
|
||||
body = $('body');
|
||||
}
|
||||
window.setTimeout(function() {
|
||||
$.each(terms, function() {
|
||||
body.highlightText(this.toLowerCase(), 'highlighted');
|
||||
});
|
||||
}, 10);
|
||||
$('<p class="highlight-link"><a href="javascript:Documentation.' +
|
||||
'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
|
||||
.appendTo($('#searchbox'));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* init the domain index toggle buttons
|
||||
*/
|
||||
initIndexTable : function() {
|
||||
var togglers = $('img.toggler').click(function() {
|
||||
var src = $(this).attr('src');
|
||||
var idnum = $(this).attr('id').substr(7);
|
||||
$('tr.cg-' + idnum).toggle();
|
||||
if (src.substr(-9) === 'minus.png')
|
||||
$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
|
||||
else
|
||||
$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
|
||||
}).css('display', '');
|
||||
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
|
||||
togglers.click();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* helper function to hide the search marks again
|
||||
*/
|
||||
hideSearchWords : function() {
|
||||
$('#searchbox .highlight-link').fadeOut(300);
|
||||
$('span.highlighted').removeClass('highlighted');
|
||||
},
|
||||
|
||||
/**
|
||||
* make the url absolute
|
||||
*/
|
||||
makeURL : function(relativeURL) {
|
||||
return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
|
||||
},
|
||||
|
||||
/**
|
||||
* get the current relative url
|
||||
*/
|
||||
getCurrentURL : function() {
|
||||
var path = document.location.pathname;
|
||||
var parts = path.split(/\//);
|
||||
$.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
|
||||
if (this === '..')
|
||||
parts.pop();
|
||||
});
|
||||
var url = parts.join('/');
|
||||
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
|
||||
},
|
||||
|
||||
initOnKeyListeners: function() {
|
||||
$(document).keydown(function(event) {
|
||||
var activeElementType = document.activeElement.tagName;
|
||||
// don't navigate when in search box, textarea, dropdown or button
|
||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT'
|
||||
&& activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey
|
||||
&& !event.shiftKey) {
|
||||
switch (event.keyCode) {
|
||||
case 37: // left
|
||||
var prevHref = $('link[rel="prev"]').prop('href');
|
||||
if (prevHref) {
|
||||
window.location.href = prevHref;
|
||||
return false;
|
||||
}
|
||||
case 39: // right
|
||||
var nextHref = $('link[rel="next"]').prop('href');
|
||||
if (nextHref) {
|
||||
window.location.href = nextHref;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// quick alias for translations
|
||||
_ = Documentation.gettext;
|
||||
|
||||
$(document).ready(function() {
|
||||
Documentation.init();
|
||||
});
|
@ -1,12 +0,0 @@
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
||||
VERSION: '',
|
||||
LANGUAGE: 'zh_CN',
|
||||
COLLAPSE_INDEX: false,
|
||||
BUILDER: 'html',
|
||||
FILE_SUFFIX: '.html',
|
||||
LINK_SUFFIX: '.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt',
|
||||
NAVIGATION_WITH_KEYS: false
|
||||
};
|
BIN
docs/_build/html/_static/file.png
vendored
Before Width: | Height: | Size: 286 B |