LPCOpen Platform for LPC112X microcontrollers  112X
LPCOpen Platform for the NXP LPC112X family of Microcontrollers
fmc_112x.h
Go to the documentation of this file.
1 /*
2  * @brief FLASH Memory Controller (FMC) registers and control functions
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2013
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 __FMC_1125_H_
33 #define __FMC_1125_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
47 typedef struct {
48  __I uint32_t RESERVED1[4];
49  __IO uint32_t FLASHCFG;
50  __I uint32_t RESERVED2[3];
51  __IO uint32_t FMSSTART;
52  __IO uint32_t FMSSTOP;
53  __I uint32_t RESERVED3;
54  __I uint32_t FMSW[4];
55  __I uint32_t RESERVED4[25];
56  __I uint32_t RESERVED5[976];
57  __I uint32_t FMSTAT;
58  __I uint32_t RESERVED6;
59  __O uint32_t FMSTATCLR;
60 } LPC_FMC_T;
61 
65 typedef enum {
70 
79 {
80  uint32_t tmp = LPC_FMC->FLASHCFG & (~(0x3));
81 
82  /* Don't alter upper bits */
83  LPC_FMC->FLASHCFG = tmp | clks;
84 }
85 
86 /* Flash signature start and busy status bit */
87 #define FMC_FLASHSIG_BUSY (1UL << 17)
88 
89 /* Flash signature clear status bit */
90 #define FMC_FLASHSIG_STAT (1 << 2)
91 
102 STATIC INLINE void Chip_FMC_ComputeSignature(uint32_t start, uint32_t stop)
103 {
104  LPC_FMC->FMSSTART = (start >> 4);
105  LPC_FMC->FMSTATCLR = FMC_FLASHSIG_STAT;
106  LPC_FMC->FMSSTOP = (stop >> 4) | FMC_FLASHSIG_BUSY;
107 }
108 
119 STATIC INLINE void Chip_FMC_ComputeSignatureBlocks(uint32_t start, uint32_t blocks)
120 {
121  Chip_FMC_ComputeSignature(start, (start + (blocks * 16)));
122 }
123 
129 {
130  LPC_FMC->FMSTATCLR = FMC_FLASHSIG_STAT;
131 }
132 
138 {
139  return (bool) ((LPC_FMC->FMSTAT & FMC_FLASHSIG_STAT) == 0);
140 }
141 
148 {
149  return LPC_FMC->FMSW[index];
150 }
151 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* __FMC_1125_H_ */