include: usb: add USB DFU class header
Add USB DFU class header. Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This commit is contained in:
parent
f7f56ccda5
commit
46700eaa65
2 changed files with 123 additions and 1 deletions
122
include/usb/class/usb_dfu.h
Normal file
122
include/usb/class/usb_dfu.h
Normal file
|
@ -0,0 +1,122 @@
|
|||
/***************************************************************************
|
||||
*
|
||||
* Copyright(c) 2015,2016 Intel Corporation.
|
||||
* Copyright(c) 2017 PHYTEC Messtechnik GmbH
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Intel Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief USB Device Firmware Upgrade (DFU) public header
|
||||
*
|
||||
* Header follows the Device Class Specification for
|
||||
* Device Firmware Upgrade Version 1.1
|
||||
*/
|
||||
|
||||
#ifndef __USB_DFU_H__
|
||||
#define __USB_DFU_H__
|
||||
|
||||
/** DFU Class Subclass */
|
||||
#define DFU_SUBCLASS 0x01
|
||||
|
||||
/** DFU Class runtime Protocol */
|
||||
#define DFU_RT_PROTOCOL 0x01
|
||||
|
||||
/** DFU Class DFU mode Protocol */
|
||||
#define DFU_MODE_PROTOCOL 0x02
|
||||
|
||||
/**
|
||||
* @brief DFU Class Specific Requests
|
||||
*/
|
||||
#define DFU_DETACH 0x00
|
||||
#define DFU_DNLOAD 0x01
|
||||
#define DFU_UPLOAD 0x02
|
||||
#define DFU_GETSTATUS 0x03
|
||||
#define DFU_CLRSTATUS 0x04
|
||||
#define DFU_GETSTATE 0x05
|
||||
#define DFU_ABORT 0x06
|
||||
|
||||
/** DFU FUNCTIONAL descriptor type */
|
||||
#define DFU_FUNC_DESC 0x21
|
||||
|
||||
/** DFU attributes DFU Functional Descriptor */
|
||||
#define DFU_ATTR_WILL_DETACH 0x08
|
||||
#define DFU_ATTR_MANIFESTATION_TOLERANT 0x04
|
||||
#define DFU_ATTR_CAN_UPLOAD 0x02
|
||||
#define DFU_ATTR_CAN_DNLOAD 0x01
|
||||
|
||||
/** DFU Specification release */
|
||||
#define DFU_VERSION 0x0110
|
||||
|
||||
/** Run-Time Functional Descriptor */
|
||||
struct dfu_runtime_descriptor {
|
||||
u8_t bLength;
|
||||
u8_t bDescriptorType;
|
||||
u8_t bmAttributes;
|
||||
u16_t wDetachTimeOut;
|
||||
u16_t wTransferSize;
|
||||
u16_t bcdDFUVersion;
|
||||
} __packed;
|
||||
|
||||
/** bStatus values for the DFU_GETSTATUS response */
|
||||
enum dfu_status {
|
||||
statusOK,
|
||||
errTARGET,
|
||||
errFILE,
|
||||
errWRITE,
|
||||
errERASE,
|
||||
errCHECK_ERASED,
|
||||
errPROG,
|
||||
errVERIFY,
|
||||
errADDRESS,
|
||||
errNOTDONE,
|
||||
errFIRMWARE,
|
||||
errVENDOR,
|
||||
errUSB,
|
||||
errPOR,
|
||||
errUNKNOWN,
|
||||
errSTALLEDPKT
|
||||
};
|
||||
|
||||
/** bState values for the DFU_GETSTATUS response */
|
||||
enum dfu_state {
|
||||
appIDLE,
|
||||
appDETACH,
|
||||
dfuIDLE,
|
||||
dfuDNLOAD_SYNC,
|
||||
dfuDNBUSY,
|
||||
dfuDNLOAD_IDLE,
|
||||
dfuMANIFEST_SYNC,
|
||||
dfuMANIFEST,
|
||||
dfuMANIFEST_WAIT_RST,
|
||||
dfuUPLOAD_IDLE,
|
||||
dfuERROR,
|
||||
};
|
||||
|
||||
#endif /* __USB_DFU_H__ */
|
|
@ -102,7 +102,7 @@
|
|||
#define WIRELESS_DEVICE_CLASS 0xE0
|
||||
#define MISC_CLASS 0xEF
|
||||
#define CUSTOM_CLASS 0xFF
|
||||
#define DFU_CLASS 0xFE
|
||||
#define DFU_DEVICE_CLASS 0xFE
|
||||
|
||||
/* Sub-classes */
|
||||
#define CDC_NCM_SUBCLASS 0x0d
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue