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