iLLD_TC27xD  1.0
IfxFlash.h
Go to the documentation of this file.
1 /**
2  * \file IfxFlash.h
3  * \brief FLASH basic functionality
4  * \ingroup IfxLld_Flash
5  *
6  * \version iLLD_1_0_0_11_0
7  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
8  *
9  *
10  * IMPORTANT NOTICE
11  *
12  *
13  * Infineon Technologies AG (Infineon) is supplying this file for use
14  * exclusively with Infineon's microcontroller products. This file can be freely
15  * distributed within development tools that are supporting such microcontroller
16  * products.
17  *
18  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23  *
24  *
25  * \defgroup IfxLld_Flash_Std_Enumerations Enumerations
26  * \ingroup IfxLld_Flash_Std
27  * \defgroup IfxLld_Flash_Std_CommandSequence CommandSequence Functions
28  * \ingroup IfxLld_Flash_Std
29  * \defgroup IfxLld_Flash_Std_ErrorTracking Error Tracking Functions
30  * \ingroup IfxLld_Flash_Std
31  */
32 
33 #ifndef IFXFLAS_H
34 #define IFXFLAS_H 1
35 
36 /******************************************************************************/
37 /*----------------------------------Includes----------------------------------*/
38 /******************************************************************************/
39 
40 #include "_Impl/IfxFlash_cfg.h"
41 #include "_Utilities/Ifx_Assert.h"
42 #include "IfxFlash_reg.h"
43 
44 /******************************************************************************/
45 /*--------------------------------Enumerations--------------------------------*/
46 /******************************************************************************/
47 
48 /** \addtogroup IfxLld_Flash_Std_Enumerations
49  * \{ */
50 /** \brief enumeration for Flash Error tracking
51  */
52 typedef enum
53 {
54  IfxFlash_ErrorTracking_none = 0, /**< \brief Error tracking disabled */
55  IfxFlash_ErrorTracking_correctedSingleBitError = 1, /**< \brief corrected single bit errors */
56  IfxFlash_ErrorTracking_correctedDoubleBitError = 2, /**< \brief Corrected double-bit errors */
57  IfxFlash_ErrorTracking_correctedSingleOrDoubleBitError = 3, /**< \brief Corrected single-bit and double-bit errors */
58  IfxFlash_ErrorTracking_uncorrectableMultiBitError = 4 /**< \brief Detected uncorrectable errors */
60 
61 /** \brief Corrected/UnCorrected Bits Address Buffer Port Id
62  */
63 typedef enum
64 {
65  IfxFlash_PortId_PortId_0 = 0, /**< \brief Port Id 0 */
66  IfxFlash_PortId_PortId_1 = 1 /**< \brief Port Id 1 */
68 
69 /** \} */
70 
71 /******************************************************************************/
72 /*-----------------------------Data Structures--------------------------------*/
73 /******************************************************************************/
74 
75 /** \addtogroup IfxLld_Flash_Std_Enumerations
76  * \{ */
77 /** \brief Error tracking address structure
78  */
79 typedef struct
80 {
81  uint32 address; /**< \brief Flash address for error tracking */
82  IfxFlash_ErrorTracking errorType; /**< \brief Error type */
84 
85 /** \} */
86 
87 /** \addtogroup IfxLld_Flash_Std_CommandSequence
88  * \{ */
89 
90 /******************************************************************************/
91 /*-------------------------Global Function Prototypes-------------------------*/
92 /******************************************************************************/
93 
94 /** \brief Performs the "Clear Status" sequence. Operation and error flags are cleared.
95  * \param flash selects the flash (PMU) module
96  * \return None
97  */
99 
100 /** \brief The password protection of the selected UCB (if this UCB offers this feature) is temporarily disabled. The command fails by setting PROER when any of the supplied PWs does not match. In this case until the next application reset all further calls of "Disable Protection" fail with PROER independent of the supplied password.
101  * \param flash selects the flash (PMU) module
102  * \param ucb selects the user configuration block (0 for UCB0, 1 for UCB1, 5 for UCB_HSMC)
103  * \param password password pointer to an array of 8 words
104  * \return None
105  */
107 
108 /** \brief Performs the sequence for entering program page mode
109  * \param pageAddr pageAddr specifies the page being written - the command sequence will be varied accordingly
110  * \return 0 on success, != 0 if invalid or not available page is selected
111  *
112  * Usage Example:
113  * \code
114  *
115  * unsigned int pageAddr = IFXFLASH_DFLASH_START + page*IFXFLASH_DFLASH_PAGE_LENGTH;
116  *
117  * // enter page mode
118  * IfxFlash_enterPageMode(pageAddr);
119  *
120  * \endcode
121  *
122  */
124 
125 /** \brief Performs the erase sequence for n sectors in program or data flash
126  * \param sectorAddr sector address
127  * \param numSector the no.of sectors to be erased
128  * \return None
129  *
130  * Usage Example:
131  * \code
132  *
133  * // erase the first and second data flash
134  * IfxFlash_eraseMultiplePhysicalSectors(IFXFLASH_DFLASH_START,2);
135  *
136  * \endcode
137  *
138  */
140 
141 /** \brief Performs the erase sequence for n sectors in program or data flash
142  * \param sectorAddr sector address
143  * \param numSector the no.of sectors to be erased
144  * \return None
145  *
146  * Usage Example:
147  * \code
148  *
149  * // erase logical sectors of program flash
150  * IfxFlash_eraseMultipleSectors(pFlashTableLog[sector].start,2);
151  *
152  * \endcode
153  *
154  */
155 IFX_EXTERN void IfxFlash_eraseMultipleSectors(uint32 sectorAddr, uint32 numSector);
156 
157 /** \brief Performs the erase sequence for a physical sector in program or data flash
158  * \param sectorAddr sector address
159  * \return None
160  *
161  * Usage Example:
162  * \code
163  *
164  * // erase the first data flash
165  * IfxFlash_erasePhysicalSector(IFXFLASH_DFLASH_START);
166  *
167  *
168  * \endcode
169  *
170  */
172 
173 /** \brief Performs the erase sequence for a sector in program or data flash.
174  * \param sectorAddr sector address
175  * \return None
176  *
177  * Usage Example:
178  * \code
179  *
180  *
181  * // erase all sectors of program flash
182  * for(sector=0; sector<IFXFLASH_PFLASH_NO_OF_LOG_SECTORS; ++sector) {
183  * // get address from predefined table
184  * unsigned int sector_addr = pFlashTableLog[sector].start;
185  * // erase sector
186  * IfxFlash_eraseSector(sector_addr);
187  * }
188  *
189  *
190  * \endcode
191  *
192  */
193 IFX_EXTERN void IfxFlash_eraseSector(uint32 sectorAddr);
194 
195 /** \brief Performs the "Erase Verify" sequence for multiple sectors
196  * \param sectorAddr sector address which should be verified
197  * \param numSector no.of sectors to be operated on
198  * \return None
199  */
200 IFX_EXTERN void IfxFlash_eraseVerifyMultipleSectors(uint32 sectorAddr, uint32 numSector);
201 
202 /** \brief Performs the "Erase Verify" sequence
203  * \param sectorAddr sector address which should be verified
204  * \return None
205  */
207 
208 /** \brief performs a load page sequence with a single 64bit access
209  * \param pageAddr pageAddr start address of page which should be programmed
210  * \param wordL Lower Address word
211  * \param wordU Upper address word
212  * \return None
213  *
214  * Usage Example:
215  * \code
216  *
217  * // load 64bit into assembly buffer of program flash
218  * IfxFlash_loadPage(IFXFLASH_PFLASH_START, 0x55555555, 0xaaaaaaaa);
219  *
220  * // load 64bit into assembly buffer of data flash
221  * IfxFlash_loadPage(0XAF000000, 0x55555555, 0xaaaaaaaa);
222  * \endcode
223  *
224  */
225 IFX_EXTERN void IfxFlash_loadPage(uint32 pageAddr, uint32 wordL, uint32 wordU);
226 
227 /** \brief performs a load page sequence with two 32bit accesses
228  * \param pageAddr pageAddr start address of page which should be programmed
229  * \param wordL Lower Address word
230  * \param wordU Upper Address word
231  * \return None
232  *
233  * Usage Example:
234  * \code
235  *
236  * // load 2*32bit into assembly buffer of program flash
237  * IfxFlash_loadPage2X32(IFXFLASH_PFLASH_START, 0x55555555, 0xaaaaaaaa);
238  *
239  * // load 2*32bit into assembly buffer of data flash
240  * IfxFlash_loadPage2X32(0XAF000000, 0x55555555, 0xaaaaaaaa);
241  * \endcode
242  *
243  */
244 IFX_EXTERN void IfxFlash_loadPage2X32(uint32 pageAddr, uint32 wordL, uint32 wordU);
245 
246 /** \brief reset to read mode
247  * \param flash flash selects the flash (PMU) module
248  * \return None
249  *
250  * Usage Example:
251  * \code
252  *
253  * // reset to read mode
254  * IfxFlash_resetToRead(0);
255  *
256  * \endcode
257  *
258  */
260 
261 /** \brief Performs the "Resume Protection" sequence
262  * \param flash selects the flash (PMU) module
263  * \return None
264  */
266 
267 /** \brief Performs the "Suspend Resume" sequence for multiple sectors
268  * \param sectorAddr sector address
269  * \param numSector the no.of sectors to be operated on
270  * \return None
271  */
273 
274 /** \brief Performs the "Suspend Resume" sequence
275  * \param sectorAddr sector address which should be resumed
276  * \return None
277  */
279 
280 /** \brief Polls the selected status flag in flash status register until it turns to 0
281  * \param flash selects the flash (PMU) module
282  * \param flashType selects the flash type
283  * \return 0 on success, != 0 if invalid or not available page is selected
284  *
285  * Usage Example:
286  * \code
287  *
288  * // wait until data flash 0 is unbusy
289  * IfxFlash_waitUnbusy(0, IfxFlash_FlashType_D0);
290  *
291  * \endcode
292  *
293  */
295 
296 /** \brief Performs the "Write Burst" sequence, similar to write page but performs a burst transfer instead of page.Make sure the appropriate amount of data is loaded using load page command
297  * \param pageAddr start address of page which should be programmed
298  * \return None
299  *
300  * Usage Example:
301  * \code
302  *
303  * // program the second page of the first sector of the Program Flash
304  * IfxFlash_writeBurst(0xa0000100);
305  *
306  * \endcode
307  *
308  */
309 IFX_EXTERN void IfxFlash_writeBurst(uint32 pageAddr);
310 
311 /** \brief Performs the "Write Page" sequence
312  * \param pageAddr start address of page which should be programmed
313  * \return None
314  *
315  * Usage Example:
316  * \code
317  *
318  * // program the second page of the first sector of the Program Flash
319  * IfxFlash_writePage(0xa0000100);
320  *
321  * \endcode
322  *
323  */
324 IFX_EXTERN void IfxFlash_writePage(uint32 pageAddr);
325 
326 /** \brief Performs the "Write Page Once" sequence, similar to write page but performs a program verify after writing.
327  * \param pageAddr start address of page which should be programmed
328  * \return None
329  *
330  * Usage Example:
331  * \code
332  *
333  * // program the second page of the first sector of the Program Flash
334  * IfxFlash_writePageOnce(0xa0000100);
335  *
336  * \endcode
337  *
338  */
340 
341 /** \} */
342 
343 /** \addtogroup IfxLld_Flash_Std_ErrorTracking
344  * \{ */
345 
346 /******************************************************************************/
347 /*-------------------------Global Function Prototypes-------------------------*/
348 /******************************************************************************/
349 
350 /** \brief Clear the Correctable errors in Corrected Bits Address Buffer Configuration Port x (CBABCFGx) register
351  * \param portId Corrected Bits Address Buffer Port Id
352  * \return None
353  */
355 
356 /** \brief Select the uncorrectable errors in UnCorrectable Bits Address Buffer Configuration Port x (UBABCFGx) register
357  * \param portId UnCorrected Bits Address Buffer Port Id
358  * \return None
359  */
361 
362 /** \brief Disable the Correctable errors in Corrected Bits Address Buffer Configuration Port x (CBABCFGx) register
363  * \param portId Corrected Bits Address Buffer Port Id
364  * \param disable Disable/enable the error tracking
365  * \return None
366  */
368 
369 /** \brief Clear the uncorrectable errors in UnCorrectable Bits Address Buffer Configuration Port x (UBABCFGx) register
370  * \param portId UnCorrected Bits Address Buffer Port Id
371  * \param disable Disable/enable the error tracking
372  * \return None
373  */
375 
376 /** \brief Returns the tracked correctable error addresses, error types and number of errors which are stored in the CBAB registers.
377  * \param portId Corrected Bits Address Buffer Port Id
378  * \param trackedFlashAdresses tracked flash addresses for correctable errors
379  * \return numErrors
380  *
381  * Example usage to print out tracked errors :
382  *
383  * \code
384  * {
385  * IfxFlash_ErrorTracking_Address trackedAddresses[IFX_FLASH_ERROR_TRACKING_MAX_CORRECTABLE_ERRORS];
386  * IfxFlash_portId portId = 0;
387  * uint8 numTrackedAddresses = IfxFlash_getTrackedCorrectableErrors(portId, trackedAddresses);
388  *
389  * for(int i=0; i<numTrackedAddresses; ++i) {
390  * printf("%d: A:0x%04x Error Type:%d \n",
391  * i,
392  * trackedAddresses[i].address,
393  * trackedAddresses[i].errorType);
394  * }
395  * }
396  * \endcode
397  *
398  */
400 
401 /** \brief Returns the tracked uncorrectable error addresses, error types and number of errors which are stored in the UBAB registers.
402  * \param portId UnCorrected Bits Address Buffer Port Id
403  * \param trackedFlashAdresses tracked flash addresses for uncorrectable errors
404  * \return numErrors
405  *
406  * Example usage to print out tracked errors :
407  *
408  * \code
409  * {
410  * IfxFlash_ErrorTracking_Address trackedAddresses[IFX_FLASH_ERROR_TRACKING_MAX_UNCORRECTABLE_ERRORS];
411  * IfxFlash_portId portId = 0;
412  * uint8 numTrackedAddresses = IfxFlash_getTrackedUnCorrectableErrors(portId, trackedAddresses);
413  *
414  * for(int i=0; i<numTrackedAddresses; ++i) {
415  * printf("%d: A:0x%04x Error Type:%d \n",
416  * i,
417  * trackedAddresses[i].address,
418  * trackedAddresses[i].errorType);
419  * }
420  * }
421  * \endcode
422  *
423  */
425 
426 /** \brief Enables error tracking for correctable flash errors
427  * \param portId Corrected Bits Address Buffer Port Id
428  * \param errorTracking Error Tracking to be selected
429  * \return None
430  *
431  * Usage example: how to enable error tracking for two flash ports:
432  * \code
433  * // enable error tracking
434  * {
435  * uint16 password = IfxScuWdt_getCpuWatchdogPassword();
436  * IfxScuWdt_clearCpuEndinit(password);
437  *
438  * // PFlash0
439  * IfxFlash_selectCorrectableErrorTracking(IfxFlash_PortId_PortId_0, IfxFlash_ErrorTracking_correctedSingleOrDoubleBitError);
440  * IfxFlash_selectUncorrectableErrorTracking(IfxFlash_PortId_PortId_0, IfxFlash_ErrorTracking_uncorrectableMultiBitError);
441  *
442  * // PFlash1
443  * IfxFlash_selectCorrectableErrorTracking(IfxFlash_PortId_PortId_1, IfxFlash_ErrorTracking_correctedSingleOrDoubleBitError);
444  * IfxFlash_selectUncorrectableErrorTracking(IfxFlash_PortId_PortId_1, IfxFlash_ErrorTracking_uncorrectableMultiBitError);
445  *
446  * IfxScuWdt_setCpuEndinit(password);
447  * }
448  * \endcode
449  *
450  */
452 
453 /** \brief Enables error tracking for uncorrectable flash errors
454  * \param portId UnCorrected Bits Address Buffer Port Id
455  * \param errorTracking Error Tracking to be selected
456  * \return None
457  *
458  * Usage example: see \ref IfxFlash_selectCorrectableErrorTracking
459  *
460  */
462 
463 /** \} */
464 
465 #endif /* IFXFLAS_H */