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