mikroSDK Reference Manual
dfu.h
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2021 XMOS LIMITED
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
27#ifndef _TUSB_DFU_H_
28#define _TUSB_DFU_H_
29
30#include "common/tusb_common.h"
31
32#ifdef __cplusplus
33 extern "C" {
34#endif
35
36//--------------------------------------------------------------------+
37// Common Definitions
38//--------------------------------------------------------------------+
39
40// DFU Protocol
41typedef enum
42{
43 DFU_PROTOCOL_RT = 0x01,
44 DFU_PROTOCOL_DFU = 0x02,
45} dfu_protocol_type_t;
46
47// DFU Descriptor Type
48typedef enum
49{
50 DFU_DESC_FUNCTIONAL = 0x21,
51} dfu_descriptor_type_t;
52
53// DFU Requests
54typedef enum {
55 DFU_REQUEST_DETACH = 0,
56 DFU_REQUEST_DNLOAD = 1,
57 DFU_REQUEST_UPLOAD = 2,
58 DFU_REQUEST_GETSTATUS = 3,
59 DFU_REQUEST_CLRSTATUS = 4,
60 DFU_REQUEST_GETSTATE = 5,
61 DFU_REQUEST_ABORT = 6,
62} dfu_requests_t;
63
64// DFU States
65typedef enum {
66 APP_IDLE = 0,
67 APP_DETACH = 1,
68 DFU_IDLE = 2,
69 DFU_DNLOAD_SYNC = 3,
70 DFU_DNBUSY = 4,
71 DFU_DNLOAD_IDLE = 5,
72 DFU_MANIFEST_SYNC = 6,
73 DFU_MANIFEST = 7,
74 DFU_MANIFEST_WAIT_RESET = 8,
75 DFU_UPLOAD_IDLE = 9,
76 DFU_ERROR = 10,
77} dfu_state_t;
78
79// DFU Status
80typedef enum {
81 DFU_STATUS_OK = 0x00,
82 DFU_STATUS_ERR_TARGET = 0x01,
83 DFU_STATUS_ERR_FILE = 0x02,
84 DFU_STATUS_ERR_WRITE = 0x03,
85 DFU_STATUS_ERR_ERASE = 0x04,
86 DFU_STATUS_ERR_CHECK_ERASED = 0x05,
87 DFU_STATUS_ERR_PROG = 0x06,
88 DFU_STATUS_ERR_VERIFY = 0x07,
89 DFU_STATUS_ERR_ADDRESS = 0x08,
90 DFU_STATUS_ERR_NOTDONE = 0x09,
91 DFU_STATUS_ERR_FIRMWARE = 0x0A,
92 DFU_STATUS_ERR_VENDOR = 0x0B,
93 DFU_STATUS_ERR_USBR = 0x0C,
94 DFU_STATUS_ERR_POR = 0x0D,
95 DFU_STATUS_ERR_UNKNOWN = 0x0E,
96 DFU_STATUS_ERR_STALLEDPKT = 0x0F,
97} dfu_status_t;
98
99#define DFU_ATTR_CAN_DOWNLOAD (1u << 0)
100#define DFU_ATTR_CAN_UPLOAD (1u << 1)
101#define DFU_ATTR_MANIFESTATION_TOLERANT (1u << 2)
102#define DFU_ATTR_WILL_DETACH (1u << 3)
103
104// DFU Status Request Payload
105typedef struct TU_ATTR_PACKED
106{
107 uint8_t bStatus;
108 uint8_t bwPollTimeout[3];
109 uint8_t bState;
110 uint8_t iString;
112
113TU_VERIFY_STATIC( sizeof(dfu_status_response_t) == 6, "size is not correct");
114
115#ifdef __cplusplus
116 }
117#endif
118
119#endif /* _TUSB_DFU_H_ */
AUDIO Channel Cluster Descriptor (4.1)
Definition audio.h:647