Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DFU Class per Version 1.1 Spec #754

Merged
merged 27 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1138f8c
Add DFU Class per Version 1.1 Spec
xmos-jmccarthy Mar 26, 2021
fb7b47c
Minor cleanup
xmos-jmccarthy Mar 26, 2021
164d3e8
Fix incorrect DNLOAD request len passed to app
xmos-jmccarthy Apr 5, 2021
c5b8ef1
Separate DFU RT and Mode. Untested
xmos-jmccarthy Apr 5, 2021
fdc91f8
Fix bug during initialization of DFU Mode
xmos-jmccarthy Apr 5, 2021
bc2cb99
Remove unreachable callback
xmos-jmccarthy Apr 5, 2021
c39b7b8
Add DFU runtime and mode "class"
xmos-jmccarthy Apr 5, 2021
2e2dc7b
Revise per initial comments
xmos-jmccarthy Apr 7, 2021
ae851bb
Resolve gcc warnings for no parameter functions
xmos-jmccarthy Apr 7, 2021
7b45b38
Remove DFU mode and rt
xmos-jmccarthy Apr 12, 2021
01661b3
Replace dfu_mode with dfu
xmos-jmccarthy Apr 22, 2021
88dea7a
Move debug from .h to .c
xmos-jmccarthy Apr 22, 2021
0936a76
Remove nonstd behaviour
xmos-jmccarthy Apr 22, 2021
18e9d25
Remove usb reset callback
xmos-jmccarthy Apr 22, 2021
289af58
Remove uunused code
xmos-jmccarthy Apr 22, 2021
e54d9d1
Add const
xmos-jmccarthy Apr 22, 2021
45e401e
Remove unused alt_setting
xmos-jmccarthy Apr 22, 2021
cc440ad
Remove custom status description table
xmos-jmccarthy Apr 22, 2021
8c80dde
Fix statte check on DATA stage
xmos-jmccarthy Apr 22, 2021
b8e5885
Removes polltimeout behaviour and restructures
xmos-jmccarthy Apr 22, 2021
f830800
Fix typo and clean up reset
xmos-jmccarthy Apr 29, 2021
dab1ed6
Add example to be tested
xmos-jmccarthy May 5, 2021
b51e0eb
Fix typo
xmos-jmccarthy May 5, 2021
05892a5
Merge branch 'master' of github.com:xmos-jmccarthy/tinyusb
xmos-jmccarthy May 6, 2021
ce59d69
Merge remote-tracking branch 'official/master'
xmos-jmccarthy May 25, 2021
dbef50f
Merge branch 'master' into xmos-jmccarthy-master
hathach May 26, 2021
f9c542a
fix dfu example build
hathach May 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions src/class/dfu/dfu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 XMOS LIMITED
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/

#ifndef _TUSB_DFU_H_
#define _TUSB_DFU_H_

#include "common/tusb_common.h"

#ifdef __cplusplus
extern "C" {
#endif

//--------------------------------------------------------------------+
// Common Definitions
//--------------------------------------------------------------------+
// DFU Protocol
typedef enum
{
DFU_PROTOCOL_RT = 0x01,
DFU_PROTOCOL_DFU = 0x02,
} dfu_protocol_type_t;

// DFU Descriptor Type
typedef enum
{
DFU_DESC_FUNCTIONAL = 0x21,
} dfu_descriptor_type_t;

// DFU Requests
typedef enum {
DFU_REQUEST_DETACH = 0,
DFU_REQUEST_DNLOAD = 1,
DFU_REQUEST_UPLOAD = 2,
DFU_REQUEST_GETSTATUS = 3,
DFU_REQUEST_CLRSTATUS = 4,
DFU_REQUEST_GETSTATE = 5,
DFU_REQUEST_ABORT = 6,
} dfu_requests_t;

// DFU States
typedef enum {
APP_IDLE = 0,
APP_DETACH = 1,
DFU_IDLE = 2,
DFU_DNLOAD_SYNC = 3,
DFU_DNBUSY = 4,
DFU_DNLOAD_IDLE = 5,
DFU_MANIFEST_SYNC = 6,
DFU_MANIFEST = 7,
DFU_MANIFEST_WAIT_RESET = 8,
DFU_UPLOAD_IDLE = 9,
DFU_ERROR = 10,
} dfu_mode_state_t;

// DFU Status
typedef enum {
DFU_STATUS_OK = 0x00,
DFU_STATUS_ERRTARGET = 0x01,
DFU_STATUS_ERRFILE = 0x02,
DFU_STATUS_ERRWRITE = 0x03,
DFU_STATUS_ERRERASE = 0x04,
DFU_STATUS_ERRCHECK_ERASED = 0x05,
DFU_STATUS_ERRPROG = 0x06,
DFU_STATUS_ERRVERIFY = 0x07,
DFU_STATUS_ERRADDRESS = 0x08,
DFU_STATUS_ERRNOTDONE = 0x09,
DFU_STATUS_ERRFIRMWARE = 0x0A,
DFU_STATUS_ERRVENDOR = 0x0B,
DFU_STATUS_ERRUSBR = 0x0C,
DFU_STATUS_ERRPOR = 0x0D,
DFU_STATUS_ERRUNKNOWN = 0x0E,
DFU_STATUS_ERRSTALLEDPKT = 0x0F,
} dfu_mode_device_status_t;

#define DFU_FUNC_ATTR_CAN_DOWNLOAD_BITMASK (1 << 0)
#define DFU_FUNC_ATTR_CAN_UPLOAD_BITMASK (1 << 1)
#define DFU_FUNC_ATTR_MANIFESTATION_TOLERANT_BITMASK (1 << 2)
#define DFU_FUNC_ATTR_WILL_DETACH_BITMASK (1 << 3)

#ifdef __cplusplus
}
#endif

#endif /* _TUSB_DFU_H_ */
Loading