summaryrefslogtreecommitdiff
path: root/bsp/samd21/sam_d2x_asflib/common/services/isp/flip/flip_protocol.h
blob: 64a49b985d2a45b85a830f558429784927ba53e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/**
 * \file
 *
 * \brief FLIP protocol definitions.
 *
 * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
 *
 * \asf_license_start
 *
 * \page License
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * 3. The name of Atmel may not be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * 4. This software may only be redistributed and used in connection with an
 *    Atmel microcontroller product.
 *
 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * \asf_license_stop
 *
 */
/*
 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
 */

#ifndef _FLIP_PROTOCOL_H_
#define _FLIP_PROTOCOL_H_

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \defgroup flip_protocol Atmel FLIP Protocol definitions
 *
 * To perform firmware upgrade, Atmel has developed an application called "FLIP"
 * This software is a flexible application which lets you program and
 * configure Atmel's microcontroller devices in their final environment
 * without needing any dedicated hardware.
 * @{
 */

//! \defgroup FLIP Protocol versions
//@{
#define  FLIP_PROTOCOL_VERSION_2     2 // Used by UC3 parts and Xmega parts
#define  FLIP_PROTOCOL_VERSION_1     1 // Used by Mega
#define  FLIP_PROTOCOL_VERSION_0     0 // Used by C51 parts
//@}


/**
 * \defgroup flip_pv1 Definitions for FLIP Protocol version 1
 *
 * Note: Used by Mega parts.
 *
 * @{
 */

COMPILER_PACK_SET(1)
/**
 * \brief FLIP message structure
 */
typedef struct {
	uint8_t cmd_id;
	uint8_t arg[5];
} flip_msg_v1_t;
COMPILER_PACK_RESET()

//! Size of buffer used by FLIP to receive or send data
#define  FLIP_V1_BUF_TRANS_SIZE  1024

//! \name FLIP commands
//@{
#define  FLIP_V1_CMD_PROG_START            0x01
#define  FLIP_V1_CMD_READ                  0x03
#define  FLIP_V1_CMD_WRITE                 0x04
#define  FLIP_V1_CMD_READ_ID               0x05
#define  FLIP_V1_CMD_CHANGE_BASE_ADDR      0x06

//! \name FLIP_V1_CMD_PROG_START first argument
//@{
#define FLIP_V1_CMD_PROG_START_ARG_FLASH   0x00
#define FLIP_V1_CMD_PROG_START_ARG_EEPROM  0x01
#define FLIP_V1_CMD_PROG_START_ARG_CUSTOM  0x08
//@}

//! \name FLIP_V1_CMD_READ first argument
//@{
#define FLIP_V1_CMD_READ_ARG_FLASH      0x00
#define FLIP_V1_CMD_READ_ARG_FLASHCHECK 0x01
#define FLIP_V1_CMD_READ_ARG_EEPROM     0x02
#define FLIP_V1_CMD_READ_ARG_CUSTOM     0x03
//@}

//! \name FLIP_V1_CMD_WRITE first argument
//@{
#define FLIP_V1_CMD_WRITE_ARG_ERASE     0x00
#define FLIP_V1_CMD_WRITE_ARG_RST       0x03
//! \name FLIP_V1_CMD_WRITE_ARG_ERASE following argument
//@{
#define FLIP_V1_CMD_WRITE_ARG_ERASE_CHIP 0xFF
//@}
//! \name FLIP_V1_CMD_WRITE_ARG_RST following arguments
//@{
#define FLIP_V1_CMD_WRITE_ARG_RST_HW    0x00
#define FLIP_V1_CMD_WRITE_ARG_RST_SF    0x01
//@}
//@}

//! \name FLIP_V1_CMD_READ_ID first argument
//@{
#define FLIP_V1_CMD_READ_ID_ARG_BOOTLOADER 0x00
#define FLIP_V1_CMD_READ_ID_ARG_SIGNATURE  0x01
//! \name FLIP_V1_CMD_READ_ID_ARG_SIGNATURE following arguments
//@{
#define FLIP_V1_CMD_READ_ID_SIGNATURE_ARG_MANUF              0x30
#define FLIP_V1_CMD_READ_ID_SIGNATURE_ARG_FAMILY             0x31
#define FLIP_V1_CMD_READ_ID_SIGNATURE_ARG_PRODUCT            0x60
#define FLIP_V1_CMD_READ_ID_SIGNATURE_ARG_REVISION           0x61
//@}
//@}

//! \name FLIP_V1_CMD_CHANGE_BASE_ADDR first argument
//@{
#define FLIP_V1_CMD_CHANGE_BASE_ADDR_ARG0   0x03
#define FLIP_V1_CMD_CHANGE_BASE_ADDR_ARG1   0x00
//@}

//@}
//@}


/**
 * \defgroup flip_pv2 Definitions for Atmel FLIP Protocol version 2
 *
 * Note: Used by uc3 and Xmega parts
 *
 * @{
 */

COMPILER_PACK_SET(1)
/**
 * \brief FLIP message structure
 */
typedef struct {
	uint8_t group;
	uint8_t cmd_id;
	uint8_t arg[4];
} flip_msg_v2_t;
COMPILER_PACK_RESET()

//! Size of buffer used by FLIP to receive or send data
//! Note:  Write uses 2K and Read uses 1KB
#define  FLIP_V2_BUF_TRANS_SIZE  (2*1024)

//! \name Command Groups
//@{
#define FLIP_V2_CMD_GRP_DNLOAD                0x01
#define FLIP_V2_CMD_GRP_UPLOAD                0x03
#define FLIP_V2_CMD_GRP_EXEC                  0x04
#define FLIP_V2_CMD_GRP_SELECT                0x06
//@}

//! \name FLIP_V2_CMD_GRP_DNLOAD first argument
//@{
#define FLIP_V2_CMD_PROGRAM_START             0x00
//@}


//! \name FLIP_V2_CMD_GRP_UPLOAD first argument
//@{
#define FLIP_V2_CMD_READ_MEMORY               0x00
#define FLIP_V2_CMD_BLANK_CHECK               0x01
//@}

//! \name FLIP_V2_CMD_GRP_EXEC first argument
//@{
#define FLIP_V2_CMD_ERASE                     0x00
#define FLIP_V2_CMD_START_APPLI               0x03
//! \name FLIP_V2_CMD_ERASE following argument
//@{
#define FLIP_V2_CMD_ERASE_ARG_CHIP            0xFF
//@}
//! \name FLIP_V2_CMD_START_APPLI following arguments
//@{
#define FLIP_V2_CMD_START_APPLI_ARG_RESET     0x00
#define FLIP_V2_CMD_START_APPLI_ARG_NO_RESET  0x01
//@}
//@}

//! \name FLIP_V2_CMD_GRP_SELECT first argument
//@{
#define FLIP_V2_CMD_SELECT_MEMORY             0x03
//! \name FLIP_V2_CMD_SELECT_MEMORY following arguments
//@{
#define FLIP_V2_CMD_SELECT_MEMORY_ARG_UNIT    0x00
#define FLIP_V2_CMD_SELECT_MEMORY_ARG_PAGE    0x01
//@}
//! \name FLIP_V2_CMD_SELECT_MEMORY_ARG_UNIT following arguments
//! Memory units field
//@{
#define FLIP_V2_CMD_SELECT_MEM_FLASH          0x00
#define FLIP_V2_CMD_SELECT_MEM_EEPROM         0x01
#define FLIP_V2_CMD_SELECT_MEM_SECURITY       0x02
#define FLIP_V2_CMD_SELECT_MEM_CONFIGURATION  0x03
#define FLIP_V2_CMD_SELECT_MEM_BOOTLOADER     0x04
#define FLIP_V2_CMD_SELECT_MEM_SIGNATURE      0x05
#define FLIP_V2_CMD_SELECT_MEM_USER           0x06
#define FLIP_V2_CMD_SELECT_MEM_INT_RAM        0x07
#define FLIP_V2_CMD_SELECT_MEM_EXT_MEM_CS0    0x08
#define FLIP_V2_CMD_SELECT_MEM_EXT_MEM_CS1    0x09
#define FLIP_V2_CMD_SELECT_MEM_EXT_MEM_CS2    0x0A
#define FLIP_V2_CMD_SELECT_MEM_EXT_MEM_CS3    0x0B
#define FLIP_V2_CMD_SELECT_MEM_EXT_MEM_CS4    0x0C
#define FLIP_V2_CMD_SELECT_MEM_EXT_MEM_CS5    0x0D
#define FLIP_V2_CMD_SELECT_MEM_EXT_MEM_CS6    0x0E
#define FLIP_V2_CMD_SELECT_MEM_EXT_MEM_CS7    0x0F
#define FLIP_V2_CMD_SELECT_MEM_EXT_MEM_DF     0x10
#define FLIP_V2_CMD_SELECT_MEM_COUNT          0x11	// Number of memory units
//@}
//@}

//@}

//@}


#ifdef __cplusplus
}
#endif

#endif // _FLIP_PROTOCOL_H_