mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-21 21:41:09 +00:00
Remove DFU mode and rt
This commit is contained in:
parent
ae851bba31
commit
7b45b38fe4
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "tusb_option.h"
|
#include "tusb_option.h"
|
||||||
|
|
||||||
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_MODE) || (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_RUNTIME_AND_MODE)
|
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_MODE)
|
||||||
|
|
||||||
#include "dfu_mode_device.h"
|
#include "dfu_mode_device.h"
|
||||||
#include "device/usbd_pvt.h"
|
#include "device/usbd_pvt.h"
|
||||||
|
@ -1,114 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "tusb_option.h"
|
|
||||||
|
|
||||||
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_RUNTIME_AND_MODE)
|
|
||||||
|
|
||||||
#include "dfu_rt_and_mode_device.h"
|
|
||||||
|
|
||||||
#include "dfu_mode_device.h"
|
|
||||||
#include "dfu_rt_device.h"
|
|
||||||
#include "device/usbd_pvt.h"
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// MACRO CONSTANT TYPEDEF
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
void (* init ) (void);
|
|
||||||
void (* reset ) (uint8_t rhport);
|
|
||||||
uint16_t (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t max_len);
|
|
||||||
bool (* control_xfer_cb ) (uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
|
||||||
} dfu_local_driver_t;
|
|
||||||
|
|
||||||
static dfu_local_driver_t ctx =
|
|
||||||
{
|
|
||||||
.init = NULL,
|
|
||||||
.reset = NULL,
|
|
||||||
.open = NULL,
|
|
||||||
.control_xfer_cb = NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
static dfu_protocol_type_t mode = 0x00;
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// USBD Driver API
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
void dfu_d_init(void)
|
|
||||||
{
|
|
||||||
mode = tud_dfu_init_in_mode_cb();
|
|
||||||
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case DFU_PROTOCOL_RT:
|
|
||||||
{
|
|
||||||
ctx.init = dfu_rtd_init;
|
|
||||||
ctx.reset = dfu_rtd_reset;
|
|
||||||
ctx.open = dfu_rtd_open;
|
|
||||||
ctx.control_xfer_cb = dfu_rtd_control_xfer_cb;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DFU_PROTOCOL_DFU:
|
|
||||||
{
|
|
||||||
ctx.init = dfu_moded_init;
|
|
||||||
ctx.reset = dfu_moded_reset;
|
|
||||||
ctx.open = dfu_moded_open;
|
|
||||||
ctx.control_xfer_cb = dfu_moded_control_xfer_cb;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
TU_LOG2(" DFU Unexpected mode: %u\r\n", mode);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void dfu_d_reset(uint8_t rhport)
|
|
||||||
{
|
|
||||||
ctx.reset(rhport);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t dfu_d_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len)
|
|
||||||
{
|
|
||||||
return ctx.open(rhport, itf_desc, max_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dfu_d_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request)
|
|
||||||
{
|
|
||||||
return ctx.control_xfer_cb(rhport, stage, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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_RT_AND_MODE_DEVICE_H_
|
|
||||||
#define _TUSB_DFU_RT_AND_MODE_DEVICE_H_
|
|
||||||
|
|
||||||
#include "common/tusb_common.h"
|
|
||||||
#include "device/usbd.h"
|
|
||||||
#include "dfu.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Application Callback API (weak is optional)
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Invoked when the driver needs to determine the callbacks to use
|
|
||||||
dfu_protocol_type_t tud_dfu_init_in_mode_cb(void);
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// Internal Class Driver API
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
void dfu_d_init(void);
|
|
||||||
void dfu_d_reset(uint8_t rhport);
|
|
||||||
uint16_t dfu_d_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
|
||||||
bool dfu_d_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _TUSB_DFU_RT_AND_MODE_DEVICE_H_ */
|
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "tusb_option.h"
|
#include "tusb_option.h"
|
||||||
|
|
||||||
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_RUNTIME) || (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_RUNTIME_AND_MODE)
|
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_RUNTIME)
|
||||||
|
|
||||||
#include "dfu_rt_device.h"
|
#include "dfu_rt_device.h"
|
||||||
#include "device/usbd_pvt.h"
|
#include "device/usbd_pvt.h"
|
||||||
|
@ -199,18 +199,6 @@ static usbd_class_driver_t const _usbd_driver[] =
|
|||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUD_DFU_RUNTIME_AND_MODE
|
|
||||||
{
|
|
||||||
DRIVER_NAME("DFU-RT-MODE")
|
|
||||||
.init = dfu_d_init,
|
|
||||||
.reset = dfu_d_reset,
|
|
||||||
.open = dfu_d_open,
|
|
||||||
.control_xfer_cb = dfu_d_control_xfer_cb,
|
|
||||||
.xfer_cb = NULL,
|
|
||||||
.sof = NULL
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CFG_TUD_NET
|
#if CFG_TUD_NET
|
||||||
{
|
{
|
||||||
DRIVER_NAME("NET")
|
DRIVER_NAME("NET")
|
||||||
|
@ -100,12 +100,6 @@
|
|||||||
#include "class/dfu/dfu_mode_device.h"
|
#include "class/dfu/dfu_mode_device.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUD_DFU_RUNTIME_AND_MODE
|
|
||||||
#include "class/dfu/dfu_rt_and_mode_device.h"
|
|
||||||
#include "class/dfu/dfu_rt_device.h"
|
|
||||||
#include "class/dfu/dfu_mode_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CFG_TUD_NET
|
#if CFG_TUD_NET
|
||||||
#include "class/net/net_device.h"
|
#include "class/net/net_device.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -241,10 +241,6 @@
|
|||||||
#define CFG_TUD_DFU_MODE 0
|
#define CFG_TUD_DFU_MODE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUD_DFU_RUNTIME_AND_MODE
|
|
||||||
#define CFG_TUD_DFU_RUNTIME_AND_MODE 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CFG_TUD_DFU_TRANSFER_BUFFER_SIZE
|
#ifndef CFG_TUD_DFU_TRANSFER_BUFFER_SIZE
|
||||||
#define CFG_TUD_DFU_TRANSFER_BUFFER_SIZE 64
|
#define CFG_TUD_DFU_TRANSFER_BUFFER_SIZE 64
|
||||||
#endif
|
#endif
|
||||||
@ -289,12 +285,6 @@
|
|||||||
#error Control Endpoint Max Packet Size cannot be larger than 64
|
#error Control Endpoint Max Packet Size cannot be larger than 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (CFG_TUD_DFU_RUNTIME_AND_MODE && CFG_TUD_DFU_RUNTIME) \
|
|
||||||
|| (CFG_TUD_DFU_RUNTIME_AND_MODE && CFG_TUD_DFU_MODE) \
|
|
||||||
|| (CFG_TUD_DFU_RUNTIME && CFG_TUD_DFU_MODE)
|
|
||||||
#error Only one of CFG_TUD_DFU_RUNTIME_AND_MODE, CFG_TUD_DFU_RUNTIME, and CFG_TUD_DFU_MODE can be enabled in a single build
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _TUSB_OPTION_H_ */
|
#endif /* _TUSB_OPTION_H_ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user