From 7b45b38fe4b7d2ebd197463cf12f091a6f68ac91 Mon Sep 17 00:00:00 2001 From: Jeremiah McCarthy Date: Mon, 12 Apr 2021 11:17:01 -0400 Subject: [PATCH] Remove DFU mode and rt --- src/class/dfu/dfu_mode_device.c | 2 +- src/class/dfu/dfu_rt_and_mode_device.c | 114 ------------------------- src/class/dfu/dfu_rt_and_mode_device.h | 57 ------------- src/class/dfu/dfu_rt_device.c | 2 +- src/device/usbd.c | 12 --- src/tusb.h | 6 -- src/tusb_option.h | 10 --- 7 files changed, 2 insertions(+), 201 deletions(-) delete mode 100644 src/class/dfu/dfu_rt_and_mode_device.c delete mode 100644 src/class/dfu/dfu_rt_and_mode_device.h diff --git a/src/class/dfu/dfu_mode_device.c b/src/class/dfu/dfu_mode_device.c index 7ad0f5168..5f8c714c0 100644 --- a/src/class/dfu/dfu_mode_device.c +++ b/src/class/dfu/dfu_mode_device.c @@ -26,7 +26,7 @@ #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 "device/usbd_pvt.h" diff --git a/src/class/dfu/dfu_rt_and_mode_device.c b/src/class/dfu/dfu_rt_and_mode_device.c deleted file mode 100644 index 8b6a8a766..000000000 --- a/src/class/dfu/dfu_rt_and_mode_device.c +++ /dev/null @@ -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 diff --git a/src/class/dfu/dfu_rt_and_mode_device.h b/src/class/dfu/dfu_rt_and_mode_device.h deleted file mode 100644 index b311bb7a5..000000000 --- a/src/class/dfu/dfu_rt_and_mode_device.h +++ /dev/null @@ -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_ */ diff --git a/src/class/dfu/dfu_rt_device.c b/src/class/dfu/dfu_rt_device.c index 729b8e3e0..9da2e1e4f 100644 --- a/src/class/dfu/dfu_rt_device.c +++ b/src/class/dfu/dfu_rt_device.c @@ -26,7 +26,7 @@ #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 "device/usbd_pvt.h" diff --git a/src/device/usbd.c b/src/device/usbd.c index 92e521ec9..af34e53ac 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -199,18 +199,6 @@ static usbd_class_driver_t const _usbd_driver[] = }, #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 { DRIVER_NAME("NET") diff --git a/src/tusb.h b/src/tusb.h index 6eab4bee2..c9558515c 100644 --- a/src/tusb.h +++ b/src/tusb.h @@ -100,12 +100,6 @@ #include "class/dfu/dfu_mode_device.h" #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 #include "class/net/net_device.h" #endif diff --git a/src/tusb_option.h b/src/tusb_option.h index 4c2204964..3cd3df9f2 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -241,10 +241,6 @@ #define CFG_TUD_DFU_MODE 0 #endif -#ifndef CFG_TUD_DFU_RUNTIME_AND_MODE - #define CFG_TUD_DFU_RUNTIME_AND_MODE 0 -#endif - #ifndef CFG_TUD_DFU_TRANSFER_BUFFER_SIZE #define CFG_TUD_DFU_TRANSFER_BUFFER_SIZE 64 #endif @@ -289,12 +285,6 @@ #error Control Endpoint Max Packet Size cannot be larger than 64 #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_ */ /** @} */