LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
spifi_001.h
Go to the documentation of this file.
1 /*
2 * @brief SPIFI registers and control functions
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * All rights reserved.
7 *
8 * @par
9 * Software that is described herein is for illustrative purposes only
10 * which provides customers with programming information regarding the
11 * LPC products. This software is supplied "AS IS" without any warranties of
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
13 * all warranties, express or implied, including all implied warranties of
14 * merchantability, fitness for a particular purpose and non-infringement of
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
16 * or liability for the use of the software, conveys no license or rights under any
17 * patent, copyright, mask work right, or any other intellectual property rights in
18 * or to any products. NXP Semiconductors reserves the right to make changes
19 * in the software without notification. NXP Semiconductors also makes no
20 * representation or warranty that such application will be suitable for the
21 * specified use without further testing or modification.
22 *
23 * @par
24 * Permission to use, copy, modify, and distribute this software and its
25 * documentation is hereby granted, under NXP Semiconductors' and its
26 * licensor's relevant copyrights in the software, without fee, provided that it
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
28 * copyright, permission, and disclaimer notice must appear in all copies of
29 * this code.
30 */
31 
32 #ifndef __SPIFI_001_H_
33 #define __SPIFI_001_H_
34 
35 #include "sys_config.h"
36 #include "cmsis.h"
37 #include "spifi_rom_api.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 // FIXME this file needs work and better explanations
44 
50 extern void cancel_mem_mode(SPIFIobj *obj);
51 extern void (*set_mem_mode) (SPIFIobj *obj);
52 
53  /* mid level functions */
54 extern int32_t checkAd(SPIFIobj *obj, SPIFIopers *opers);
55 extern int32_t setProt(SPIFIobj *obj, SPIFIopers *opers, char *change,
56  char *saveProt);
57 extern int32_t check_block(SPIFIobj *obj, char *source, SPIFIopers *opers,
58  uint32_t check_program);
59 extern int32_t send_erase_cmd(SPIFIobj *obj, uint8_t op, uint32_t addr);
60 extern uint32_t ck_erase(SPIFIobj *obj, uint32_t *addr, uint32_t length);
61 extern int32_t prog_block(SPIFIobj *obj, char *source, SPIFIopers *opers,
62  uint32_t *left_in_page);
63 extern uint32_t ck_prog(SPIFIobj *obj, char *source, char *dest, uint32_t length);
64 
65  /* low level functions */
66 extern void setSize(SPIFIobj *obj, int32_t value);
67 extern int32_t setDev(SPIFIobj *obj, uint32_t opts, uint32_t mem_cmd,
68  uint32_t prog_cmd);
69 extern uint32_t cmd(uc op, uc addrLen, uc intLen, uint16_t len);
70 extern uint32_t readAd(SPIFIobj *obj, uint32_t cmd, uint32_t addr);
71 extern void send04(SPIFIobj *obj, uc op, uc len, uint32_t value);
72 extern void wren_sendAd(SPIFIobj *obj, uint32_t cmd, uint32_t addr, uint32_t value);
73 extern int32_t write_stat(SPIFIobj *obj, uc len, uint16_t value);
74 extern int32_t wait_busy(SPIFIobj *obj, uc prog_or_erase);
75 
90 STATIC INLINE int32_t IP_SPIFI_Init(SPIFIobj *obj, uint32_t csHigh, uint32_t options, uint32_t mhz)
91 {
92  return spifi_init(obj, csHigh, options, mhz);
93 }
94 
106 STATIC INLINE int32_t IP_SPIFI_Program(SPIFIobj *obj, char *source, SPIFIopers *opers)
107 {
108  return spifi_program(obj, source, opers);
109 }
110 
119 {
120  return spifi_erase(obj, opers);
121 }
122 
129 {
130  cancel_mem_mode(obj);
131 }
132 
134 {
135  set_mem_mode(obj);
136 }
137 
138  /* mid level functions */
140 {
141  return checkAd(obj, opers);
142 }
143 
144 STATIC INLINE int32_t IP_SPIFI_setProt(SPIFIobj *obj, SPIFIopers *opers, char *change, char *saveProt)
145 {
146  return setProt(obj, opers, change, saveProt);
147 }
148 
149 STATIC INLINE int32_t IP_SPIFI_CheckBlock(SPIFIobj *obj, char *source, SPIFIopers *opers,
150  uint32_t check_program)
151 {
152  return check_block(obj, source, opers, check_program);
153 }
154 
155 STATIC INLINE int32_t IP_SPIFI_SendEraseCmd(SPIFIobj *obj, uint8_t op, uint32_t addr)
156 {
157  return send_erase_cmd(obj, op, addr);
158 }
159 
161 {
162  return ck_erase(obj, addr, length);
163 }
164 
165 STATIC INLINE int32_t IP_SPIFI_ProgBlock(SPIFIobj *obj, char *source, SPIFIopers *opers,
166  uint32_t *left_in_page)
167 {
168  return prog_block(obj, source, opers, left_in_page);
169 }
170 
171 STATIC INLINE uint32_t IP_SPIFI_CkProg(SPIFIobj *obj, char *source, char *dest, uint32_t length)
172 {
173  return ck_prog(obj, source, dest, length);
174 }
175 
176  /* low level functions */
177 STATIC INLINE void IP_SPIFI_SetSize(SPIFIobj *obj, int32_t value)
178 {
179  setSize(obj, value);
180 }
181 
183  uint32_t prog_cmd)
184 {
185  return setDev(obj, opts, mem_cmd, prog_cmd);
186 }
187 
188 STATIC INLINE uint32_t IP_SPIFI_Cmd(uc op, uc addrLen, uc intLen, uint16_t len)
189 {
190  return cmd(op, addrLen, intLen, len);
191 }
192 
194 {
195  return readAd(obj, cmd, addr);
196 }
197 
198 STATIC INLINE void IP_SPIFI_Send04(SPIFIobj *obj, uc op, uc len, uint32_t value)
199 {
200  send04(obj, op, len, value);
201 }
202 
204 {
205  wren_sendAd(obj, cmd, addr, value);
206 }
207 
208 STATIC INLINE int32_t IP_SPIFI_WriteStat(SPIFIobj *obj, uc len, uint16_t value)
209 {
210  return write_stat(obj, len, value);
211 }
212 
213 STATIC INLINE int32_t IP_SPIFI_WaitBusy(SPIFIobj *obj, uc prog_or_erase)
214 {
215  return wait_busy(obj, prog_or_erase);
216 }
217 
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif /* __SPIFI_001_H_ */