Merged in f5soh/librepilot/LP-607_world_mag_model_2015v2 (pull request #526)
[librepilot.git] / flight / libraries / inc / op_dfu.h
blobfeba9e43124b0f1c7f84098ec6d2a7cac623f538
1 /**
2 ******************************************************************************
4 * @file op_dfu.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
6 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
7 * @brief
8 * @see The GNU Public License (GPL) Version 3
10 *****************************************************************************/
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 /* Define to prevent recursive inclusion -------------------------------------*/
28 #ifndef __OP_DFU_H
29 #define __OP_DFU_H
31 /* Includes ------------------------------------------------------------------*/
32 /* Exported types ------------------------------------------------------------*/
33 typedef enum {
34 start, keepgoing,
35 } DownloadAction;
37 /**************************************************/
38 /* OP_DFU states */
39 /**************************************************/
41 typedef enum {
42 DFUidle, // 0
43 uploading, // 1
44 wrong_packet_received, // 2
45 too_many_packets, // 3
46 too_few_packets, // 4
47 Last_operation_Success, // 5
48 downloading, // 6
49 BLidle, // 7
50 Last_operation_failed, // 8
51 uploadingStarting, // 9
52 outsideDevCapabilities, // 10
53 CRC_Fail, // 11
54 failed_jump,
55 // 12
56 } DFUStates;
57 /**************************************************/
58 /* OP_DFU commands */
59 /**************************************************/
60 typedef enum {
61 Reserved, // 0
62 Req_Capabilities, // 1
63 Rep_Capabilities, // 2
64 EnterDFU, // 3
65 JumpFW, // 4
66 Reset, // 5
67 Abort_Operation, // 6
68 Upload, // 7
69 Op_END, // 8
70 Download_Req, // 9
71 Download, // 10
72 Status_Request, // 11
73 Status_Rep
74 // 12
75 } DFUCommands;
77 typedef enum {
78 High_Density, Medium_Density
79 } DeviceType;
80 /**************************************************/
81 /* OP_DFU transfer types */
82 /**************************************************/
83 typedef enum {
84 FW, // 0
85 Descript
86 // 2
87 } DFUTransfer;
88 /**************************************************/
89 /* OP_DFU transfer port */
90 /**************************************************/
91 typedef enum {
92 Usb, // 0
93 Serial
94 // 2
95 } DFUPort;
96 /**************************************************/
97 /* OP_DFU programable programable HW types */
98 /**************************************************/
99 typedef enum {
100 Self_flash, // 0
101 Remote_flash_via_spi
102 // 1
103 } DFUProgType;
104 /**************************************************/
105 /* OP_DFU programable sources */
106 /**************************************************/
107 #define USB 0
108 #define SPI 1
110 #define DownloadDelay 100000
112 #define MAX_DEL_RETRYS 3
113 #define MAX_WRI_RETRYS 3
115 typedef struct {
116 uint8_t programmingType;
117 uint8_t readWriteFlags;
118 uint32_t startOfUserCode;
119 uint32_t sizeOfCode;
120 uint8_t sizeOfDescription;
121 uint8_t BL_Version;
122 uint16_t devID;
123 DeviceType devType;
124 uint32_t FW_Crc;
125 } Device;
127 /* Exported constants --------------------------------------------------------*/
128 /* Exported macro ------------------------------------------------------------*/
129 /* Exported define -----------------------------------------------------------*/
130 #define COMMAND 0
131 #define COUNT 1
132 #define DATA 5
134 /* Exported functions ------------------------------------------------------- */
135 void processComand(uint8_t *Receive_Buffer);
136 void DataDownload(DownloadAction);
138 #endif /* __OP_DFU_H */
140 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/