1 |
577 |
jeremybenn |
/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
|
2 |
|
|
* File Name : 91x_fmi.h
|
3 |
|
|
* Author : MCD Application Team
|
4 |
|
|
* Date First Issued : 05/18/2006 : Version 1.0
|
5 |
|
|
* Description : This file contains all the functions prototypes for the
|
6 |
|
|
* FMI software library.
|
7 |
|
|
********************************************************************************
|
8 |
|
|
* History:
|
9 |
|
|
* 05/24/2006 : Version 1.1
|
10 |
|
|
* 05/18/2006 : Version 1.0
|
11 |
|
|
********************************************************************************
|
12 |
|
|
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
|
13 |
|
|
* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS
|
14 |
|
|
* A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
|
15 |
|
|
* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
|
16 |
|
|
* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
|
17 |
|
|
* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
18 |
|
|
*******************************************************************************/
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
/* Define to prevent recursive inclusion ------------------------------------ */
|
22 |
|
|
|
23 |
|
|
#ifndef __91x_FMI_H
|
24 |
|
|
#define __91x_FMI_H
|
25 |
|
|
|
26 |
|
|
/* ========================================================================== */
|
27 |
|
|
/* When bank 1 is remapped at address 0x0, decomment the following line */
|
28 |
|
|
/* ========================================================================== */
|
29 |
|
|
|
30 |
|
|
//#define Remap_Bank_1
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/* Includes ------------------------------------------------------------------*/
|
34 |
|
|
|
35 |
|
|
#include "91x_map.h"
|
36 |
|
|
|
37 |
|
|
/* Exported types ------------------------------------------------------------*/
|
38 |
|
|
/* Exported constants --------------------------------------------------------*/
|
39 |
|
|
|
40 |
|
|
/* FMI banks */
|
41 |
|
|
|
42 |
|
|
#ifdef Remap_Bank_1
|
43 |
|
|
|
44 |
|
|
#define FMI_BANK_0 ((*(vu32*)0x54000010) << 2) /* FMI Bank 0 */
|
45 |
|
|
#define FMI_BANK_1 ((*(vu32*)0x5400000C) << 2) /* FMI Bank 1 */
|
46 |
|
|
|
47 |
|
|
#else /* Remap Bank 0 */
|
48 |
|
|
|
49 |
|
|
#define FMI_BANK_0 ((*(vu32*)0x5400000C) << 2) /* FMI Bank 0 */
|
50 |
|
|
#define FMI_BANK_1 ((*(vu32*)0x54000010) << 2) /* FMI Bank 1 */
|
51 |
|
|
|
52 |
|
|
#endif
|
53 |
|
|
|
54 |
|
|
/* FMI sectors */
|
55 |
|
|
|
56 |
|
|
#define FMI_B0S0 0x00000000 + FMI_BANK_0 /* Bank 0 sector 0 */
|
57 |
|
|
#define FMI_B0S1 0x00010000 + FMI_BANK_0 /* Bank 0 sector 1 */
|
58 |
|
|
#define FMI_B0S2 0x00020000 + FMI_BANK_0 /* Bank 0 sector 2 */
|
59 |
|
|
#define FMI_B0S3 0x00030000 + FMI_BANK_0 /* Bank 0 sector 3 */
|
60 |
|
|
#define FMI_B0S4 0x00040000 + FMI_BANK_0 /* Bank 0 sector 4 */
|
61 |
|
|
#define FMI_B0S5 0x00050000 + FMI_BANK_0 /* Bank 0 sector 5 */
|
62 |
|
|
#define FMI_B0S6 0x00060000 + FMI_BANK_0 /* Bank 0 sector 6 */
|
63 |
|
|
#define FMI_B0S7 0x00070000 + FMI_BANK_0 /* Bank 0 sector 7 */
|
64 |
|
|
|
65 |
|
|
#define FMI_B1S0 0x00000000 + FMI_BANK_1 /* Bank 1 sector 0 */
|
66 |
|
|
#define FMI_B1S1 0x00002000 + FMI_BANK_1 /* Bank 1 sector 1 */
|
67 |
|
|
#define FMI_B1S2 0x00004000 + FMI_BANK_1 /* Bank 1 sector 2 */
|
68 |
|
|
#define FMI_B1S3 0x00006000 + FMI_BANK_1 /* Bank 1 sector 3 */
|
69 |
|
|
|
70 |
|
|
/* FMI Flags */
|
71 |
|
|
|
72 |
|
|
#define FMI_FLAG_SPS 0x02 /* Sector Protection Status Flag */
|
73 |
|
|
#define FMI_FLAG_PSS 0x04 /* Program Suspend Status Flag */
|
74 |
|
|
#define FMI_FLAG_PS 0x10 /* Program Status Flag */
|
75 |
|
|
#define FMI_FLAG_ES 0x20 /* Erase Status Flag */
|
76 |
|
|
#define FMI_FLAG_ESS 0x40 /* Erase Suspend Status Flag */
|
77 |
|
|
#define FMI_FLAG_PECS 0x80 /* FPEC Status Flag */
|
78 |
|
|
|
79 |
|
|
/* FMI read wait states */
|
80 |
|
|
|
81 |
|
|
#define FMI_READ_WAIT_STATE_1 0x0000 /* One read wait state */
|
82 |
|
|
#define FMI_READ_WAIT_STATE_2 0x2000 /* Two read wait states */
|
83 |
|
|
#define FMI_READ_WAIT_STATE_3 0x4000 /* Three read wait states */
|
84 |
|
|
|
85 |
|
|
/* FMI write wait states */
|
86 |
|
|
|
87 |
|
|
#define FMI_WRITE_WAIT_STATE_0 0xFFFFFEFF /* Zero wait state */
|
88 |
|
|
#define FMI_WRITE_WAIT_STATE_1 0x00000100 /* One wait state */
|
89 |
|
|
|
90 |
|
|
/* FMI power down configuration */
|
91 |
|
|
|
92 |
|
|
#define FMI_PWD_ENABLE 0x1000 /* FMI Power Down Enable */
|
93 |
|
|
#define FMI_PWD_DISABLE 0x0000 /* FMI Power Down Disable */
|
94 |
|
|
|
95 |
|
|
/* FMI low voltage detector */
|
96 |
|
|
|
97 |
|
|
#define FMI_LVD_ENABLE 0x0000 /* FMI Low Voltage Detector Enable */
|
98 |
|
|
#define FMI_LVD_DISABLE 0x0800 /* FMI Low Voltage Detector Disable */
|
99 |
|
|
|
100 |
|
|
/* FMI frequency range */
|
101 |
|
|
|
102 |
|
|
#define FMI_FREQ_LOW 0x0000 /* FMI Low bus working frequency */
|
103 |
|
|
#define FMI_FREQ_HIGH 0x0040 /* FMI High bus working gfrequency */
|
104 |
|
|
/* Above 66 MHz*/
|
105 |
|
|
/* FMI OTP word addresses */
|
106 |
|
|
|
107 |
|
|
#define FMI_OTP_WORD_0 0x00 /* OTP word 0 */
|
108 |
|
|
#define FMI_OTP_WORD_1 0x04 /* OTP word 1 */
|
109 |
|
|
#define FMI_OTP_WORD_2 0x08 /* OTP word 2 */
|
110 |
|
|
#define FMI_OTP_WORD_3 0x0C /* OTP word 3 */
|
111 |
|
|
#define FMI_OTP_WORD_4 0x10 /* OTP word 4 */
|
112 |
|
|
#define FMI_OTP_WORD_5 0x14 /* OTP word 5 */
|
113 |
|
|
#define FMI_OTP_WORD_6 0x18 /* OTP word 6 */
|
114 |
|
|
#define FMI_OTP_WORD_7 0x1C /* OTP word 7 */
|
115 |
|
|
|
116 |
|
|
/* FMI OTP halfword addresses */
|
117 |
|
|
|
118 |
|
|
#define FMI_OTP_LOW_HALFWORD_0 0x00 /* OTP Low halfword 0 */
|
119 |
|
|
#define FMI_OTP_HIGH_HALFWORD_0 0x02 /* OTP High halfword 0 */
|
120 |
|
|
#define FMI_OTP_LOW_HALFWORD_1 0x04 /* OTP Low halfword 1 */
|
121 |
|
|
#define FMI_OTP_HIGH_HALFWORD_1 0x06 /* OTP High halfword 1 */
|
122 |
|
|
#define FMI_OTP_LOW_HALFWORD_2 0x08 /* OTP Low halfword 2 */
|
123 |
|
|
#define FMI_OTP_HIGH_HALFWORD_2 0x0A /* OTP High halfword 2 */
|
124 |
|
|
#define FMI_OTP_LOW_HALFWORD_3 0x0C /* OTP Low halfword 3 */
|
125 |
|
|
#define FMI_OTP_HIGH_HALFWORD_3 0x0E /* OTP High halfword 3 */
|
126 |
|
|
#define FMI_OTP_LOW_HALFWORD_4 0x10 /* OTP Low halfword 4 */
|
127 |
|
|
#define FMI_OTP_HIGH_HALFWORD_4 0x12 /* OTP High halfword 4 */
|
128 |
|
|
#define FMI_OTP_LOW_HALFWORD_5 0x14 /* OTP Low halfword 5 */
|
129 |
|
|
#define FMI_OTP_HIGH_HALFWORD_5 0x16 /* OTP High halfword 5 */
|
130 |
|
|
#define FMI_OTP_LOW_HALFWORD_6 0x18 /* OTP Low halfword 6 */
|
131 |
|
|
#define FMI_OTP_HIGH_HALFWORD_6 0x1A /* OTP High halfword 6 */
|
132 |
|
|
#define FMI_OTP_LOW_HALFWORD_7 0x1C /* OTP Low halfword 7 */
|
133 |
|
|
#define FMI_OTP_HIGH_HALFWORD_7 0x1E /* OTP High halfword 7 */
|
134 |
|
|
|
135 |
|
|
/* FMI sectors Masks */
|
136 |
|
|
|
137 |
|
|
#define FMI_B0S0_MASK 0x0001 /* FMI B0S0 mask */
|
138 |
|
|
#define FMI_B0S1_MASK 0x0002 /* FMI B0S1 mask */
|
139 |
|
|
#define FMI_B0S2_MASK 0x0004 /* FMI B0S2 mask */
|
140 |
|
|
#define FMI_B0S3_MASK 0x0008 /* FMI B0S3 mask */
|
141 |
|
|
#define FMI_B0S4_MASK 0x0010 /* FMI B0S4 mask */
|
142 |
|
|
#define FMI_B0S5_MASK 0x0020 /* FMI B0S5 mask */
|
143 |
|
|
#define FMI_B0S6_MASK 0x0040 /* FMI B0S6 mask */
|
144 |
|
|
#define FMI_B0S7_MASK 0x0080 /* FMI B0S7 mask */
|
145 |
|
|
|
146 |
|
|
#define FMI_B1S0_MASK 0x0100 /* FMI B1S0 mask */
|
147 |
|
|
#define FMI_B1S1_MASK 0x0200 /* FMI B1S1 mask */
|
148 |
|
|
#define FMI_B1S2_MASK 0x0400 /* FMI B1S2 mask */
|
149 |
|
|
#define FMI_B1S3_MASK 0x0800 /* FMI B1S3 mask */
|
150 |
|
|
|
151 |
|
|
/* Timeout error */
|
152 |
|
|
|
153 |
|
|
#define FMI_TIME_OUT_ERROR 0x00 /* Timeout error */
|
154 |
|
|
#define FMI_NO_TIME_OUT_ERROR 0x01 /* No Timeout error */
|
155 |
|
|
|
156 |
|
|
/* Module private variables --------------------------------------------------*/
|
157 |
|
|
/* Exported macro ------------------------------------------------------------*/
|
158 |
|
|
/* Private functions ---------------------------------------------------------*/
|
159 |
|
|
/* Exported functions ------------------------------------------------------- */
|
160 |
|
|
|
161 |
|
|
void FMI_BankRemapConfig(u8 FMI_BootBankSize, u8 FMI_NonBootBankSize, \
|
162 |
|
|
u32 FMI_BootBankAddress, u32 FMI_NonBootBankAddress);
|
163 |
|
|
void FMI_Config(u16 FMI_ReadWaitState, u32 FMI_WriteWaitState, u16 FMI_PWD,\
|
164 |
|
|
u16 FMI_LVDEN, u16 FMI_FreqRange);
|
165 |
|
|
void FMI_EraseSector(vu32 FMI_Sector);
|
166 |
|
|
void FMI_EraseBank(vu32 FMI_Bank);
|
167 |
|
|
void FMI_WriteHalfWord(u32 FMI_Address, u16 FMI_Data);
|
168 |
|
|
void FMI_WriteOTPHalfWord(u8 FMI_OTPHWAddress, u16 FMI_OTPData);
|
169 |
|
|
u32 FMI_ReadWord(u32 FMI_Address);
|
170 |
|
|
u32 FMI_ReadOTPData(u8 FMI_OTPAddress);
|
171 |
|
|
FlagStatus FMI_GetFlagStatus(u8 FMI_Flag, vu32 FMI_Bank);
|
172 |
|
|
u16 FMI_GetReadWaitStateValue(void);
|
173 |
|
|
u16 FMI_GetWriteWaitStateValue(void);
|
174 |
|
|
void FMI_SuspendEnable(vu32 FMI_Bank);
|
175 |
|
|
void FMI_ResumeEnable(vu32 FMI_Bank);
|
176 |
|
|
void FMI_ClearFlag(vu32 FMI_Bank);
|
177 |
|
|
void FMI_WriteProtectionCmd(vu32 FMI_Sector, FunctionalState FMI_NewState);
|
178 |
|
|
FlagStatus FMI_GetWriteProtectionStatus(u32 FMI_Sector_Protection);
|
179 |
|
|
u8 FMI_WaitForLastOperation(vu32 FMI_Bank);
|
180 |
|
|
|
181 |
|
|
#endif /* __91x_FMI_H */
|
182 |
|
|
|
183 |
|
|
/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
|
184 |
|
|
|