1beacf11bSopenharmony_ci/**************************************************************************** 2beacf11bSopenharmony_ci * include/nuttx/usb/dfu.h 3beacf11bSopenharmony_ci * 4beacf11bSopenharmony_ci * Copyright (C) 2011-2018 Gregory Nutt. All rights reserved. 5beacf11bSopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2017-2019. All rights reserved. 6beacf11bSopenharmony_ci * Authors: Petteri Aimonen <jpa@git.mail.kapsi.fi> 7beacf11bSopenharmony_ci * 8beacf11bSopenharmony_ci * Redistribution and use in source and binary forms, with or without 9beacf11bSopenharmony_ci * modification, are permitted provided that the following conditions 10beacf11bSopenharmony_ci * are met: 11beacf11bSopenharmony_ci * 12beacf11bSopenharmony_ci * 1. Redistributions of source code must retain the above copyright 13beacf11bSopenharmony_ci * notice, this list of conditions and the following disclaimer. 14beacf11bSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 15beacf11bSopenharmony_ci * notice, this list of conditions and the following disclaimer in 16beacf11bSopenharmony_ci * the documentation and/or other materials provided with the 17beacf11bSopenharmony_ci * distribution. 18beacf11bSopenharmony_ci * 3. Neither the name NuttX nor the names of its contributors may be 19beacf11bSopenharmony_ci * used to endorse or promote products derived from this software 20beacf11bSopenharmony_ci * without specific prior written permission. 21beacf11bSopenharmony_ci * 22beacf11bSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23beacf11bSopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24beacf11bSopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25beacf11bSopenharmony_ci * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26beacf11bSopenharmony_ci * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27beacf11bSopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28beacf11bSopenharmony_ci * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 29beacf11bSopenharmony_ci * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 30beacf11bSopenharmony_ci * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31beacf11bSopenharmony_ci * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32beacf11bSopenharmony_ci * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33beacf11bSopenharmony_ci * POSSIBILITY OF SUCH DAMAGE. 34beacf11bSopenharmony_ci * 35beacf11bSopenharmony_ci ****************************************************************************/ 36beacf11bSopenharmony_ci/**************************************************************************** 37beacf11bSopenharmony_ci * Notice of Export Control Law 38beacf11bSopenharmony_ci * =============================================== 39beacf11bSopenharmony_ci * Huawei LiteOS may be subject to applicable export control laws and regulations, 40beacf11bSopenharmony_ci * which might include those applicable to Huawei LiteOS of U.S. and the country in 41beacf11bSopenharmony_ci * which you are located. 42beacf11bSopenharmony_ci * Import, export and usage of Huawei LiteOS in any manner by you shall be in 43beacf11bSopenharmony_ci * compliance with such applicable export control laws and regulations. 44beacf11bSopenharmony_ci ****************************************************************************/ 45beacf11bSopenharmony_ci 46beacf11bSopenharmony_ci#ifndef __INCLUDE_NUTTX_USB_DFU_H 47beacf11bSopenharmony_ci#define __INCLUDE_NUTTX_USB_DFU_H 48beacf11bSopenharmony_ci 49beacf11bSopenharmony_ci/************************************************************************************ 50beacf11bSopenharmony_ci * Included Files 51beacf11bSopenharmony_ci ************************************************************************************/ 52beacf11bSopenharmony_ci 53beacf11bSopenharmony_ci#include "gadget/usbdev.h" 54beacf11bSopenharmony_ci 55beacf11bSopenharmony_ci/************************************************************************************ 56beacf11bSopenharmony_ci * Public Functions 57beacf11bSopenharmony_ci ************************************************************************************/ 58beacf11bSopenharmony_ci 59beacf11bSopenharmony_ci#undef EXTERN 60beacf11bSopenharmony_ci#if defined(__cplusplus) 61beacf11bSopenharmony_ci# define EXTERN extern "C" 62beacf11bSopenharmony_ciextern "C" 63beacf11bSopenharmony_ci{ 64beacf11bSopenharmony_ci#else 65beacf11bSopenharmony_ci# define EXTERN extern 66beacf11bSopenharmony_ci#endif 67beacf11bSopenharmony_ci 68beacf11bSopenharmony_ci/* Response to DFU_GETSTATUS */ 69beacf11bSopenharmony_ci 70beacf11bSopenharmony_cistruct dfu_getstatus_response_s 71beacf11bSopenharmony_ci{ 72beacf11bSopenharmony_ci uint8_t status; /* Status of latest command */ 73beacf11bSopenharmony_ci uint8_t poll_timeout[3]; /* Time until next GETSTATUS request */ 74beacf11bSopenharmony_ci uint8_t state; /* Current state of the device */ 75beacf11bSopenharmony_ci uint8_t string_idx; /* Optional string description */ 76beacf11bSopenharmony_ci}; 77beacf11bSopenharmony_ci 78beacf11bSopenharmony_ci/**************************************************************************** 79beacf11bSopenharmony_ci * Name: usbdev_dfu_get_composite_devdesc 80beacf11bSopenharmony_ci * 81beacf11bSopenharmony_ci * Description: 82beacf11bSopenharmony_ci * Helper function to fill in some constants into the composite 83beacf11bSopenharmony_ci * configuration struct. 84beacf11bSopenharmony_ci * 85beacf11bSopenharmony_ci * Input Parameters: 86beacf11bSopenharmony_ci * dev - Pointer to the configuration struct we should fill 87beacf11bSopenharmony_ci * 88beacf11bSopenharmony_ci * Returned Value: 89beacf11bSopenharmony_ci * None 90beacf11bSopenharmony_ci * 91beacf11bSopenharmony_ci ****************************************************************************/ 92beacf11bSopenharmony_ci 93beacf11bSopenharmony_civoid usbdev_dfu_get_composite_devdesc(struct composite_devdesc_s *dev); 94beacf11bSopenharmony_civoid to_dfu_mode(void); 95beacf11bSopenharmony_civoid to_runtime_mode(void); 96beacf11bSopenharmony_ci 97beacf11bSopenharmony_ci#undef EXTERN 98beacf11bSopenharmony_ci#if defined(__cplusplus) 99beacf11bSopenharmony_ci} 100beacf11bSopenharmony_ci#endif 101beacf11bSopenharmony_ci 102beacf11bSopenharmony_ci#endif /* __INCLUDE_NUTTX_USB_DFU_H */ 103beacf11bSopenharmony_ci 104