summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/lpc43xx/chip/lpc43_flash.h
blob: 4f99484dac765b382624254308bd8161f377ff43 (plain) (blame)
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
/************************************************************************************
 * arch/arm/src/lpc43xx/chip/lpc43_flash.h
 *
 *   Copyright (C) 2012 Gregory Nutt. All rights reserved.
 *   Author: Gregory Nutt <gnutt@nuttx.org>
 *
 * 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. Neither the name NuttX nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS 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.
 *
 ************************************************************************************/

#ifndef __ARCH_ARM_SRC_LPC43XX_CHIP_LPC43_FLASH_H
#define __ARCH_ARM_SRC_LPC43XX_CHIP_LPC43_FLASH_H

/************************************************************************************
 * Included Files
 ************************************************************************************/

#include <nuttx/config.h>

/************************************************************************************
 * Pre-processor Definitions
 ************************************************************************************/
/* The AES is controlled through a set of simple API calls located in the LPC43xx
 * ROM.  This value holds the pointer to the AES driver table.
 */

#define LPC43_ROM_IAP_DRIVER_TABLE LPC43_ROM_DRIVER_TABLE0

#define IAP_LOCATION *(volatile unsigned int *)LPC43_ROM_IAP_DRIVER_TABLE;

/* General usage:
 *
 * Declare a function pointer in your code like:
 *
 *  iap_t iap = (iap_t)IAP_LOCATION;
 *
 * Then call the IAP using the function pointe like:
 *
 *  unsigned long command[6];
 *  unsigned long result[5];
 *  ...
 *  iap(command, result);
 */

/* IAP Commands
 *
 *   See tables 1042-1053 in the "LPC43xx User Manual" (UM10503), Rev. 1.2, 8 June
 *   2012, NXP for definitions descriptions of each IAP command.
 */

#define IAP_INIT            49   /* Initialization */
#define IAP_WRITE_PREPARE   50   /* Prepare sectors for write operation */
#define IAP_WRITE           51   /* Copy RAM to Flash */
#define IAP_ERASE_SECTOR    52   /* Erase sectors */
#define IAP_BLANK_CHECK     53   /* Blank check sectors */
#define IAP_PART_ID         54   /* Read part ID */
#define IAP_BOOT_VERSION    55   /* Read Boot Code version */
#define IAP_SERIAL_NUMBER   58   /* Read device serial number */
#define IAP_COMPARE         56   /* Compare */
#define IAP_REINVOKE        57   /* Reinvoke ISP */
#define IAP_ERASE_PAGE      59   /* Erase page */
#define IAP_SET_BANK        60   /* Set active boot flash bank */

/* ISP/IAP return codes */

/* Command is executed successfully. Sent by ISP handler only when command given by
 * the host has been completely and successfully executed.
 */

#define CMD_SUCCESS 0

/* Invalid command */

#define INVALID_COMMAND

/* Source address is not on word boundary. */

#define SRC_ADDR_ERROR 2

/* Destination address not on word or 256 byte boundary. */

#define DST_ADDR_ERROR 3

/* Source address is not mapped in the memory map. Count value is taken into
 * consideration where applicable.
 */

#define SRC_ADDR_NOT_MAPPED 4

/* Destination address is not mapped in the memory map. Count value is taken into
 * consideration where applicable.
 */

#define DST_ADDR_NOT_MAPPED 5

/* Byte count is not multiple of 4 or is not a permitted value. */

#define COUNT_ERROR 6

/* Sector number is invalid or end sector number is greater than start sector number. */

#define INVALID_SECTOR 7

/* Sector is not blank. */

#define SECTOR_NOT_BLANK 8

/* Command to prepare sector for write operation was not executed. */

#define SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION 9

/* Source and destination data not equal. */

#define COMPARE_ERROR 10

/* Flash programming hardware interface is busy. */

#define BUSY 11

/* Insufficient number of parameters or invalid parameter. */

#define PARAM_ERROR 12

/* Address is not on word boundary. */

#define ADDR_ERROR 13

/* Address is not mapped in the memory map. Count value is taken in to consideration
 * where applicable.
 */

#define ADDR_NOT_MAPPED 14

/* Command is locked. */

#define CMD_LOCKED 15

/* Unlock code is invalid. */

#define INVALID_CODE 16

/* Invalid baud rate setting. */

#define INVALID_BAUD_RATE 17

/************************************************************************************
 * Public Types
 ************************************************************************************/

/* IAP function pointer */

typedef void (*iap_t)(unsigned int *cmd, unsigned int *result);

/************************************************************************************
 * Public Data
 ************************************************************************************/

/************************************************************************************
 * Public Functions
 ************************************************************************************/

#endif /* __ARCH_ARM_SRC_LPC43XX_CHIP_LPC43_FLASH_H */