OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_STM32F103_GCC_Rowley/] [ST Library/] [inc/] [stm32f10x_flash.h] - Blame information for rev 582

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 582 jeremybenn
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2
* File Name          : stm32f10x_flash.h
3
* Author             : MCD Application Team
4
* Version            : V2.0.1
5
* Date               : 06/13/2008
6
* Description        : This file contains all the functions prototypes for the
7
*                      FLASH firmware library.
8
********************************************************************************
9
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15
*******************************************************************************/
16
 
17
/* Define to prevent recursive inclusion -------------------------------------*/
18
#ifndef __STM32F10x_FLASH_H
19
#define __STM32F10x_FLASH_H
20
 
21
/* Includes ------------------------------------------------------------------*/
22
#include "stm32f10x_map.h"
23
 
24
/* Exported types ------------------------------------------------------------*/
25
#ifdef _FLASH_PROG
26
/* FLASH Status */
27
typedef enum
28
{
29
  FLASH_BUSY = 1,
30
  FLASH_ERROR_PG,
31
  FLASH_ERROR_WRP,
32
  FLASH_COMPLETE,
33
  FLASH_TIMEOUT
34
}FLASH_Status;
35
#endif
36
 
37
/* Flash Latency -------------------------------------------------------------*/
38
#define FLASH_Latency_0                ((u32)0x00000000)  /* FLASH Zero Latency cycle */
39
#define FLASH_Latency_1                ((u32)0x00000001)  /* FLASH One Latency cycle */
40
#define FLASH_Latency_2                ((u32)0x00000002)  /* FLASH Two Latency cycles */
41
 
42
#define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \
43
                                   ((LATENCY) == FLASH_Latency_1) || \
44
                                   ((LATENCY) == FLASH_Latency_2))
45
 
46
/* Half Cycle Enable/Disable -------------------------------------------------*/
47
#define FLASH_HalfCycleAccess_Enable   ((u32)0x00000008)  /* FLASH Half Cycle Enable */
48
#define FLASH_HalfCycleAccess_Disable  ((u32)0x00000000)  /* FLASH Half Cycle Disable */
49
 
50
#define IS_FLASH_HALFCYCLEACCESS_STATE(STATE) (((STATE) == FLASH_HalfCycleAccess_Enable) || \
51
                                               ((STATE) == FLASH_HalfCycleAccess_Disable))
52
 
53
 
54
/* Prefetch Buffer Enable/Disable --------------------------------------------*/
55
#define FLASH_PrefetchBuffer_Enable    ((u32)0x00000010)  /* FLASH Prefetch Buffer Enable */
56
#define FLASH_PrefetchBuffer_Disable   ((u32)0x00000000)  /* FLASH Prefetch Buffer Disable */
57
 
58
#define IS_FLASH_PREFETCHBUFFER_STATE(STATE) (((STATE) == FLASH_PrefetchBuffer_Enable) || \
59
                                              ((STATE) == FLASH_PrefetchBuffer_Disable))
60
 
61
#ifdef _FLASH_PROG
62
/* Option Bytes Write Protection ---------------------------------------------*/
63
/* Values to be used with STM32F10Xxx Medium-density devices: FLASH memory density
64
   ranges between 32 and 128 Kbytes with page size equal to 1 Kbytes */
65
#define FLASH_WRProt_Pages0to3         ((u32)0x00000001) /* Write protection of page 0 to 3 */
66
#define FLASH_WRProt_Pages4to7         ((u32)0x00000002) /* Write protection of page 4 to 7 */
67
#define FLASH_WRProt_Pages8to11        ((u32)0x00000004) /* Write protection of page 8 to 11 */
68
#define FLASH_WRProt_Pages12to15       ((u32)0x00000008) /* Write protection of page 12 to 15 */
69
#define FLASH_WRProt_Pages16to19       ((u32)0x00000010) /* Write protection of page 16 to 19 */
70
#define FLASH_WRProt_Pages20to23       ((u32)0x00000020) /* Write protection of page 20 to 23 */
71
#define FLASH_WRProt_Pages24to27       ((u32)0x00000040) /* Write protection of page 24 to 27 */
72
#define FLASH_WRProt_Pages28to31       ((u32)0x00000080) /* Write protection of page 28 to 31 */
73
#define FLASH_WRProt_Pages32to35       ((u32)0x00000100) /* Write protection of page 32 to 35 */
74
#define FLASH_WRProt_Pages36to39       ((u32)0x00000200) /* Write protection of page 36 to 39 */
75
#define FLASH_WRProt_Pages40to43       ((u32)0x00000400) /* Write protection of page 40 to 43 */
76
#define FLASH_WRProt_Pages44to47       ((u32)0x00000800) /* Write protection of page 44 to 47 */
77
#define FLASH_WRProt_Pages48to51       ((u32)0x00001000) /* Write protection of page 48 to 51 */
78
#define FLASH_WRProt_Pages52to55       ((u32)0x00002000) /* Write protection of page 52 to 55 */
79
#define FLASH_WRProt_Pages56to59       ((u32)0x00004000) /* Write protection of page 56 to 59 */
80
#define FLASH_WRProt_Pages60to63       ((u32)0x00008000) /* Write protection of page 60 to 63 */
81
#define FLASH_WRProt_Pages64to67       ((u32)0x00010000) /* Write protection of page 64 to 67 */
82
#define FLASH_WRProt_Pages68to71       ((u32)0x00020000) /* Write protection of page 68 to 71 */
83
#define FLASH_WRProt_Pages72to75       ((u32)0x00040000) /* Write protection of page 72 to 75 */
84
#define FLASH_WRProt_Pages76to79       ((u32)0x00080000) /* Write protection of page 76 to 79 */
85
#define FLASH_WRProt_Pages80to83       ((u32)0x00100000) /* Write protection of page 80 to 83 */
86
#define FLASH_WRProt_Pages84to87       ((u32)0x00200000) /* Write protection of page 84 to 87 */
87
#define FLASH_WRProt_Pages88to91       ((u32)0x00400000) /* Write protection of page 88 to 91 */
88
#define FLASH_WRProt_Pages92to95       ((u32)0x00800000) /* Write protection of page 92 to 95 */
89
#define FLASH_WRProt_Pages96to99       ((u32)0x01000000) /* Write protection of page 96 to 99 */
90
#define FLASH_WRProt_Pages100to103     ((u32)0x02000000) /* Write protection of page 100 to 103 */
91
#define FLASH_WRProt_Pages104to107     ((u32)0x04000000) /* Write protection of page 104 to 107 */
92
#define FLASH_WRProt_Pages108to111     ((u32)0x08000000) /* Write protection of page 108 to 111 */
93
#define FLASH_WRProt_Pages112to115     ((u32)0x10000000) /* Write protection of page 112 to 115 */
94
#define FLASH_WRProt_Pages116to119     ((u32)0x20000000) /* Write protection of page 115 to 119 */
95
#define FLASH_WRProt_Pages120to123     ((u32)0x40000000) /* Write protection of page 120 to 123 */
96
#define FLASH_WRProt_Pages124to127     ((u32)0x80000000) /* Write protection of page 124 to 127 */
97
/* Values to be used with STM32F10Xxx High-density devices: FLASH memory density
98
   ranges between 256 and 512 Kbytes with page size equal to 2 Kbytes */
99
#define FLASH_WRProt_Pages0to1         ((u32)0x00000001) /* Write protection of page 0 to 1 */
100
#define FLASH_WRProt_Pages2to3         ((u32)0x00000002) /* Write protection of page 2 to 3 */
101
#define FLASH_WRProt_Pages4to5         ((u32)0x00000004) /* Write protection of page 4 to 5 */
102
#define FLASH_WRProt_Pages6to7         ((u32)0x00000008) /* Write protection of page 6 to 7 */
103
#define FLASH_WRProt_Pages8to9         ((u32)0x00000010) /* Write protection of page 8 to 9 */
104
#define FLASH_WRProt_Pages10to11       ((u32)0x00000020) /* Write protection of page 10 to 11 */
105
#define FLASH_WRProt_Pages12to13       ((u32)0x00000040) /* Write protection of page 12 to 13 */
106
#define FLASH_WRProt_Pages14to15       ((u32)0x00000080) /* Write protection of page 14 to 15 */
107
#define FLASH_WRProt_Pages16to17       ((u32)0x00000100) /* Write protection of page 16 to 17 */
108
#define FLASH_WRProt_Pages18to19       ((u32)0x00000200) /* Write protection of page 18 to 19 */
109
#define FLASH_WRProt_Pages20to21       ((u32)0x00000400) /* Write protection of page 20 to 21 */
110
#define FLASH_WRProt_Pages22to23       ((u32)0x00000800) /* Write protection of page 22 to 23 */
111
#define FLASH_WRProt_Pages24to25       ((u32)0x00001000) /* Write protection of page 24 to 25 */
112
#define FLASH_WRProt_Pages26to27       ((u32)0x00002000) /* Write protection of page 26 to 27 */
113
#define FLASH_WRProt_Pages28to29       ((u32)0x00004000) /* Write protection of page 28 to 29 */
114
#define FLASH_WRProt_Pages30to31       ((u32)0x00008000) /* Write protection of page 30 to 31 */
115
#define FLASH_WRProt_Pages32to33       ((u32)0x00010000) /* Write protection of page 32 to 33 */
116
#define FLASH_WRProt_Pages34to35       ((u32)0x00020000) /* Write protection of page 34 to 35 */
117
#define FLASH_WRProt_Pages36to37       ((u32)0x00040000) /* Write protection of page 36 to 37 */
118
#define FLASH_WRProt_Pages38to39       ((u32)0x00080000) /* Write protection of page 38 to 39 */
119
#define FLASH_WRProt_Pages40to41       ((u32)0x00100000) /* Write protection of page 40 to 41 */
120
#define FLASH_WRProt_Pages42to43       ((u32)0x00200000) /* Write protection of page 42 to 43 */
121
#define FLASH_WRProt_Pages44to45       ((u32)0x00400000) /* Write protection of page 44 to 45 */
122
#define FLASH_WRProt_Pages46to47       ((u32)0x00800000) /* Write protection of page 46 to 47 */
123
#define FLASH_WRProt_Pages48to49       ((u32)0x01000000) /* Write protection of page 48 to 49 */
124
#define FLASH_WRProt_Pages50to51       ((u32)0x02000000) /* Write protection of page 50 to 51 */
125
#define FLASH_WRProt_Pages52to53       ((u32)0x04000000) /* Write protection of page 52 to 53 */
126
#define FLASH_WRProt_Pages54to55       ((u32)0x08000000) /* Write protection of page 54 to 55 */
127
#define FLASH_WRProt_Pages56to57       ((u32)0x10000000) /* Write protection of page 56 to 57 */
128
#define FLASH_WRProt_Pages58to59       ((u32)0x20000000) /* Write protection of page 58 to 59 */
129
#define FLASH_WRProt_Pages60to61       ((u32)0x40000000) /* Write protection of page 60 to 61 */
130
#define FLASH_WRProt_Pages62to255      ((u32)0x80000000) /* Write protection of page 62 to 255 */
131
#define FLASH_WRProt_AllPages          ((u32)0xFFFFFFFF) /* Write protection of all Pages */
132
 
133
#define IS_FLASH_WRPROT_PAGE(PAGE) (((PAGE) != 0x00000000))
134
 
135
#define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x0807FFFF))
136
#define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))
137
 
138
/* Option Bytes IWatchdog ----------------------------------------------------*/
139
#define OB_IWDG_SW                     ((u16)0x0001)  /* Software IWDG selected */
140
#define OB_IWDG_HW                     ((u16)0x0000)  /* Hardware IWDG selected */
141
 
142
#define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
143
 
144
/* Option Bytes nRST_STOP ----------------------------------------------------*/
145
#define OB_STOP_NoRST                  ((u16)0x0002) /* No reset generated when entering in STOP */
146
#define OB_STOP_RST                    ((u16)0x0000) /* Reset generated when entering in STOP */
147
 
148
#define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
149
 
150
/* Option Bytes nRST_STDBY ---------------------------------------------------*/
151
#define OB_STDBY_NoRST                 ((u16)0x0004) /* No reset generated when entering in STANDBY */
152
#define OB_STDBY_RST                   ((u16)0x0000) /* Reset generated when entering in STANDBY */
153
 
154
#define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
155
 
156
/* FLASH Interrupts ----------------------------------------------------------*/
157
#define FLASH_IT_ERROR                 ((u32)0x00000400)  /* FPEC error interrupt source */
158
#define FLASH_IT_EOP                   ((u32)0x00001000)  /* End of FLASH Operation Interrupt source */
159
 
160
#define IS_FLASH_IT(IT) ((((IT) & (u32)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
161
 
162
/* FLASH Flags ---------------------------------------------------------------*/
163
#define FLASH_FLAG_BSY                 ((u32)0x00000001)  /* FLASH Busy flag */
164
#define FLASH_FLAG_EOP                 ((u32)0x00000020)  /* FLASH End of Operation flag */
165
#define FLASH_FLAG_PGERR               ((u32)0x00000004)  /* FLASH Program error flag */
166
#define FLASH_FLAG_WRPRTERR            ((u32)0x00000010)  /* FLASH Write protected error flag */
167
#define FLASH_FLAG_OPTERR              ((u32)0x00000001)  /* FLASH Option Byte error flag */
168
 
169
#define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (u32)0xFFFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
170
 
171
#define IS_FLASH_GET_FLAG(FLAG)  (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
172
                                  ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
173
                                  ((FLAG) == FLASH_FLAG_OPTERR))
174
#endif
175
 
176
/* Exported constants --------------------------------------------------------*/
177
/* Exported macro ------------------------------------------------------------*/
178
/* Exported functions ------------------------------------------------------- */
179
void FLASH_SetLatency(u32 FLASH_Latency);
180
void FLASH_HalfCycleAccessCmd(u32 FLASH_HalfCycleAccess);
181
void FLASH_PrefetchBufferCmd(u32 FLASH_PrefetchBuffer);
182
 
183
#ifdef _FLASH_PROG
184
void FLASH_Unlock(void);
185
void FLASH_Lock(void);
186
FLASH_Status FLASH_ErasePage(u32 Page_Address);
187
FLASH_Status FLASH_EraseAllPages(void);
188
FLASH_Status FLASH_EraseOptionBytes(void);
189
FLASH_Status FLASH_ProgramWord(u32 Address, u32 Data);
190
FLASH_Status FLASH_ProgramHalfWord(u32 Address, u16 Data);
191
FLASH_Status FLASH_ProgramOptionByteData(u32 Address, u8 Data);
192
FLASH_Status FLASH_EnableWriteProtection(u32 FLASH_Pages);
193
FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState);
194
FLASH_Status FLASH_UserOptionByteConfig(u16 OB_IWDG, u16 OB_STOP, u16 OB_STDBY);
195
u32 FLASH_GetUserOptionByte(void);
196
u32 FLASH_GetWriteProtectionOptionByte(void);
197
FlagStatus FLASH_GetReadOutProtectionStatus(void);
198
FlagStatus FLASH_GetPrefetchBufferStatus(void);
199
void FLASH_ITConfig(u16 FLASH_IT, FunctionalState NewState);
200
FlagStatus FLASH_GetFlagStatus(u16 FLASH_FLAG);
201
void FLASH_ClearFlag(u16 FLASH_FLAG);
202
FLASH_Status FLASH_GetStatus(void);
203
FLASH_Status FLASH_WaitForLastOperation(u32 Timeout);
204
#endif
205
 
206
#endif /* __STM32F10x_FLASH_H */
207
 
208
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.