iLLD_TC29x  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 */
67  IfxFlash_PortId_PortId_2 = 2, /**< \brief Port Id 2 */
68  IfxFlash_PortId_PortId_3 = 3 /**< \brief Port Id 3 */
70 
71 /** \} */
72 
73 /******************************************************************************/
74 /*-----------------------------Data Structures--------------------------------*/
75 /******************************************************************************/
76 
77 /** \addtogroup IfxLld_Flash_Std_Enumerations
78  * \{ */
79 /** \brief Error tracking address structure
80  */
81 typedef struct
82 {
83  uint32 address; /**< \brief Flash address for error tracking */
84  IfxFlash_ErrorTracking errorType; /**< \brief Error type */
86 
87 /** \} */
88 
89 /** \addtogroup IfxLld_Flash_Std_CommandSequence
90  * \{ */
91 
92 /******************************************************************************/
93 /*-------------------------Global Function Prototypes-------------------------*/
94 /******************************************************************************/
95 
96 /** \brief Performs the "Clear Status" sequence. Operation and error flags are cleared.
97  * \param flash selects the flash (PMU) module
98  * \return None
99  */
101 
102 /** \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.
103  * \param flash selects the flash (PMU) module
104  * \param ucb selects the user configuration block (0 for UCB0, 1 for UCB1, 5 for UCB_HSMC)
105  * \param password password pointer to an array of 8 words
106  * \return None
107  */
109 
110 /** \brief Performs the sequence for entering program page mode
111  * \param pageAddr pageAddr specifies the page being written - the command sequence will be varied accordingly
112  * \return 0 on success, != 0 if invalid or not available page is selected
113  *
114  * Usage Example:
115  * \code
116  *
117  * unsigned int pageAddr = IFXFLASH_DFLASH_START + page*IFXFLASH_DFLASH_PAGE_LENGTH;
118  *
119  * // enter page mode
120  * IfxFlash_enterPageMode(pageAddr);
121  *
122  * \endcode
123  *
124  */
126 
127 /** \brief Performs the erase sequence for n sectors in program or data flash
128  * \param sectorAddr sector address
129  * \param numSector the no.of sectors to be erased
130  * \return None
131  *
132  * Usage Example:
133  * \code
134  *
135  * // erase the first and second data flash
136  * IfxFlash_eraseMultiplePhysicalSectors(IFXFLASH_DFLASH_START,2);
137  *
138  * \endcode
139  *
140  */
142 
143 /** \brief Performs the erase sequence for n sectors in program or data flash
144  * \param sectorAddr sector address
145  * \param numSector the no.of sectors to be erased
146  * \return None
147  *
148  * Usage Example:
149  * \code
150  *
151  * // erase logical sectors of program flash
152  * IfxFlash_eraseMultipleSectors(pFlashTableLog[sector].start,2);
153  *
154  * \endcode
155  *
156  */
157 IFX_EXTERN void IfxFlash_eraseMultipleSectors(uint32 sectorAddr, uint32 numSector);
158 
159 /** \brief Performs the erase sequence for a physical sector in program or data flash
160  * \param sectorAddr sector address
161  * \return None
162  *
163  * Usage Example:
164  * \code
165  *
166  * // erase the first data flash
167  * IfxFlash_erasePhysicalSector(IFXFLASH_DFLASH_START);
168  *
169  *
170  * \endcode
171  *
172  */
174 
175 /** \brief Performs the erase sequence for a sector in program or data flash.
176  * \param sectorAddr sector address
177  * \return None
178  *
179  * Usage Example:
180  * \code
181  *
182  *
183  * // erase all sectors of program flash
184  * for(sector=0; sector<IFXFLASH_PFLASH_NO_OF_LOG_SECTORS; ++sector) {
185  * // get address from predefined table
186  * unsigned int sector_addr = pFlashTableLog[sector].start;
187  * // erase sector
188  * IfxFlash_eraseSector(sector_addr);
189  * }
190  *
191  *
192  * \endcode
193  *
194  */
195 IFX_EXTERN void IfxFlash_eraseSector(uint32 sectorAddr);
196 
197 /** \brief Performs the "Erase Verify" sequence for multiple sectors
198  * \param sectorAddr sector address which should be verified
199  * \param numSector no.of sectors to be operated on
200  * \return None
201  */
202 IFX_EXTERN void IfxFlash_eraseVerifyMultipleSectors(uint32 sectorAddr, uint32 numSector);
203 
204 /** \brief Performs the "Erase Verify" sequence
205  * \param sectorAddr sector address which should be verified
206  * \return None
207  */
209 
210 /** \brief performs a load page sequence with a single 64bit access
211  * \param pageAddr pageAddr start address of page which should be programmed
212  * \param wordL Lower Address word
213  * \param wordU Upper address word
214  * \return None
215  *
216  * Usage Example:
217  * \code
218  *
219  * // load 64bit into assembly buffer of program flash
220  * IfxFlash_loadPage(IFXFLASH_PFLASH_START, 0x55555555, 0xaaaaaaaa);
221  *
222  * // load 64bit into assembly buffer of data flash
223  * IfxFlash_loadPage(0XAF000000, 0x55555555, 0xaaaaaaaa);
224  * \endcode
225  *
226  */
227 IFX_EXTERN void IfxFlash_loadPage(uint32 pageAddr, uint32 wordL, uint32 wordU);
228 
229 /** \brief performs a load page sequence with two 32bit accesses
230  * \param pageAddr pageAddr start address of page which should be programmed
231  * \param wordL Lower Address word
232  * \param wordU Upper Address word
233  * \return None
234  *
235  * Usage Example:
236  * \code
237  *
238  * // load 2*32bit into assembly buffer of program flash
239  * IfxFlash_loadPage2X32(IFXFLASH_PFLASH_START, 0x55555555, 0xaaaaaaaa);
240  *
241  * // load 2*32bit into assembly buffer of data flash
242  * IfxFlash_loadPage2X32(0XAF000000, 0x55555555, 0xaaaaaaaa);
243  * \endcode
244  *
245  */
246 IFX_EXTERN void IfxFlash_loadPage2X32(uint32 pageAddr, uint32 wordL, uint32 wordU);
247 
248 /** \brief reset to read mode
249  * \param flash flash selects the flash (PMU) module
250  * \return None
251  *
252  * Usage Example:
253  * \code
254  *
255  * // reset to read mode
256  * IfxFlash_resetToRead(0);
257  *
258  * \endcode
259  *
260  */
262 
263 /** \brief Performs the "Resume Protection" sequence
264  * \param flash selects the flash (PMU) module
265  * \return None
266  */
268 
269 /** \brief Performs the "Suspend Resume" sequence for multiple sectors
270  * \param sectorAddr sector address
271  * \param numSector the no.of sectors to be operated on
272  * \return None
273  */
275 
276 /** \brief Performs the "Suspend Resume" sequence
277  * \param sectorAddr sector address which should be resumed
278  * \return None
279  */
281 
282 /** \brief Polls the selected status flag in flash status register until it turns to 0
283  * \param flash selects the flash (PMU) module
284  * \param flashType selects the flash type
285  * \return 0 on success, != 0 if invalid or not available page is selected
286  *
287  * Usage Example:
288  * \code
289  *
290  * // wait until data flash 0 is unbusy
291  * IfxFlash_waitUnbusy(0, IfxFlash_FlashType_D0);
292  *
293  * \endcode
294  *
295  */
297 
298 /** \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
299  * \param pageAddr start address of page which should be programmed
300  * \return None
301  *
302  * Usage Example:
303  * \code
304  *
305  * // program the second page of the first sector of the Program Flash
306  * IfxFlash_writeBurst(0xa0000100);
307  *
308  * \endcode
309  *
310  */
311 IFX_EXTERN void IfxFlash_writeBurst(uint32 pageAddr);
312 
313 /** \brief Performs the "Write Page" sequence
314  * \param pageAddr start address of page which should be programmed
315  * \return None
316  *
317  * Usage Example:
318  * \code
319  *
320  * // program the second page of the first sector of the Program Flash
321  * IfxFlash_writePage(0xa0000100);
322  *
323  * \endcode
324  *
325  */
326 IFX_EXTERN void IfxFlash_writePage(uint32 pageAddr);
327 
328 /** \brief Performs the "Write Page Once" sequence, similar to write page but performs a program verify after writing.
329  * \param pageAddr start address of page which should be programmed
330  * \return None
331  *
332  * Usage Example:
333  * \code
334  *
335  * // program the second page of the first sector of the Program Flash
336  * IfxFlash_writePageOnce(0xa0000100);
337  *
338  * \endcode
339  *
340  */
342 
343 /** \} */
344 
345 /** \addtogroup IfxLld_Flash_Std_ErrorTracking
346  * \{ */
347 
348 /******************************************************************************/
349 /*-------------------------Global Function Prototypes-------------------------*/
350 /******************************************************************************/
351 
352 /** \brief Clear the Correctable errors in Corrected Bits Address Buffer Configuration Port x (CBABCFGx) register
353  * \param portId Corrected Bits Address Buffer Port Id
354  * \return None
355  */
357 
358 /** \brief Select the uncorrectable errors in UnCorrectable Bits Address Buffer Configuration Port x (UBABCFGx) register
359  * \param portId UnCorrected Bits Address Buffer Port Id
360  * \return None
361  */
363 
364 /** \brief Disable the Correctable errors in Corrected Bits Address Buffer Configuration Port x (CBABCFGx) register
365  * \param portId Corrected Bits Address Buffer Port Id
366  * \param disable Disable/enable the error tracking
367  * \return None
368  */
370 
371 /** \brief Clear the uncorrectable errors in UnCorrectable Bits Address Buffer Configuration Port x (UBABCFGx) register
372  * \param portId UnCorrected Bits Address Buffer Port Id
373  * \param disable Disable/enable the error tracking
374  * \return None
375  */
377 
378 /** \brief Returns the tracked correctable error addresses, error types and number of errors which are stored in the CBAB registers.
379  * \param portId Corrected Bits Address Buffer Port Id
380  * \param trackedFlashAdresses tracked flash addresses for correctable errors
381  * \return numErrors
382  *
383  * Example usage to print out tracked errors :
384  *
385  * \code
386  * {
387  * IfxFlash_ErrorTracking_Address trackedAddresses[IFX_FLASH_ERROR_TRACKING_MAX_CORRECTABLE_ERRORS];
388  * IfxFlash_portId portId = 0;
389  * uint8 numTrackedAddresses = IfxFlash_getTrackedCorrectableErrors(portId, trackedAddresses);
390  *
391  * for(int i=0; i<numTrackedAddresses; ++i) {
392  * printf("%d: A:0x%04x Error Type:%d \n",
393  * i,
394  * trackedAddresses[i].address,
395  * trackedAddresses[i].errorType);
396  * }
397  * }
398  * \endcode
399  *
400  */
402 
403 /** \brief Returns the tracked uncorrectable error addresses, error types and number of errors which are stored in the UBAB registers.
404  * \param portId UnCorrected Bits Address Buffer Port Id
405  * \param trackedFlashAdresses tracked flash addresses for uncorrectable errors
406  * \return numErrors
407  *
408  * Example usage to print out tracked errors :
409  *
410  * \code
411  * {
412  * IfxFlash_ErrorTracking_Address trackedAddresses[IFX_FLASH_ERROR_TRACKING_MAX_UNCORRECTABLE_ERRORS];
413  * IfxFlash_portId portId = 0;
414  * uint8 numTrackedAddresses = IfxFlash_getTrackedUnCorrectableErrors(portId, trackedAddresses);
415  *
416  * for(int i=0; i<numTrackedAddresses; ++i) {
417  * printf("%d: A:0x%04x Error Type:%d \n",
418  * i,
419  * trackedAddresses[i].address,
420  * trackedAddresses[i].errorType);
421  * }
422  * }
423  * \endcode
424  *
425  */
427 
428 /** \brief Enables error tracking for correctable flash errors
429  * \param portId Corrected Bits Address Buffer Port Id
430  * \param errorTracking Error Tracking to be selected
431  * \return None
432  *
433  * Usage example: how to enable error tracking for two flash ports:
434  * \code
435  * // enable error tracking
436  * {
437  * uint16 password = IfxScuWdt_getCpuWatchdogPassword();
438  * IfxScuWdt_clearCpuEndinit(password);
439  *
440  * // PFlash0
441  * IfxFlash_selectCorrectableErrorTracking(IfxFlash_PortId_PortId_0, IfxFlash_ErrorTracking_correctedSingleOrDoubleBitError);
442  * IfxFlash_selectUncorrectableErrorTracking(IfxFlash_PortId_PortId_0, IfxFlash_ErrorTracking_uncorrectableMultiBitError);
443  *
444  * // PFlash1
445  * IfxFlash_selectCorrectableErrorTracking(IfxFlash_PortId_PortId_1, IfxFlash_ErrorTracking_correctedSingleOrDoubleBitError);
446  * IfxFlash_selectUncorrectableErrorTracking(IfxFlash_PortId_PortId_1, IfxFlash_ErrorTracking_uncorrectableMultiBitError);
447  *
448  * IfxScuWdt_setCpuEndinit(password);
449  * }
450  * \endcode
451  *
452  */
454 
455 /** \brief Enables error tracking for uncorrectable flash errors
456  * \param portId UnCorrected Bits Address Buffer Port Id
457  * \param errorTracking Error Tracking to be selected
458  * \return None
459  *
460  * Usage example: see \ref IfxFlash_selectCorrectableErrorTracking
461  *
462  */
464 
465 /** \} */
466 
467 #endif /* IFXFLAS_H */