Kinetis SDK v.1.2 Demo Applications User's Guide  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
driver_examples/flash/main.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef __MAIN__
32 #define __MAIN__
33 
34 #include "SSD_FTFx.h"
35 // size of array to copy__Launch_Command function to
36 // It should be at least equal to actual size of __Launch_Command func
37 // User can change this value based on RAM size availability and actual size of __Launch_Command function
38 #define LAUNCH_CMD_SIZE 0x100
39 
40 #define BUFFER_SIZE_BYTE 0x80
41 
42 #define DEBUGENABLE 0x00
43 
44 #define READ_NORMAL_MARGIN 0x00
45 #define READ_USER_MARGIN 0x01
46 #define READ_FACTORY_MARGIN 0x02
47 
48 #define ONE_KB 1024
49 
50 #define FTFx_REG_BASE 0x40020000
51 #define P_FLASH_BASE 0x00000000
52 
53 #define BACKDOOR_KEY_LOCATION 0x400
54 
55 // Program flash IFR
56 #if (FSL_FEATURE_FLASH_IS_FTFE == 1)
57 #define PFLASH_IFR 0x3C0
58 #else // FSL_FEATURE_FLASH_IS_FTFL == 1 or FSL_FEATURE_FLASH_IS_FTFA = =1
59 #define PFLASH_IFR 0xC0
60 #endif
61 // Program Flash block information
62 #define P_FLASH_SIZE (FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE * FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT)
63 #define P_BLOCK_NUM FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT
64 #define P_SECTOR_SIZE FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE
65 // Data Flash block information
66 #define FLEXNVM_BASE FSL_FEATURE_FLASH_FLEX_NVM_START_ADDRESS
67 #define FLEXNVM_SECTOR_SIZE FSL_FEATURE_FLASH_FLEX_NVM_BLOCK_SECTOR_SIZE
68 #define FLEXNVM_BLOCK_SIZE FSL_FEATURE_FLASH_FLEX_NVM_BLOCK_SIZE
69 #define FLEXNVM_BLOCK_NUM FSL_FEATURE_FLASH_FLEX_NVM_BLOCK_COUNT
70 
71 // Flex Ram block information
72 #define EERAM_BASE FSL_FEATURE_FLASH_FLEX_RAM_START_ADDRESS
73 #define EERAM_SIZE FSL_FEATURE_FLASH_FLEX_RAM_SIZE
74 
75 
76 // Has flash cache control in MCM module
77 #if (FSL_FEATURE_FLASH_HAS_MCM_FLASH_CACHE_CONTROLS == 1)
78 #define CACHE_DISABLE MCM_BWR_PLACR_DFCS(MCM_BASE_PTR, 1);
79 // Has flash cache control in FMC module
80 #elif (FSL_FEATURE_FLASH_HAS_FMC_FLASH_CACHE_CONTROLS == 1)
81 #if defined(FMC_PFB1CR) && defined(FMC_PFB1CR_B1SEBE_MASK)
82 #define CACHE_DISABLE FMC_PFB0CR &= ~(FMC_PFB0CR_B0SEBE_MASK | FMC_PFB0CR_B0IPE_MASK | FMC_PFB0CR_B0DPE_MASK | FMC_PFB0CR_B0ICE_MASK | FMC_PFB0CR_B0DCE_MASK);\
83  FMC_PFB1CR &= ~(FMC_PFB1CR_B1SEBE_MASK | FMC_PFB1CR_B1IPE_MASK | FMC_PFB1CR_B1DPE_MASK | FMC_PFB1CR_B1ICE_MASK | FMC_PFB1CR_B1DCE_MASK);
84 #else
85 #define CACHE_DISABLE FMC_PFB0CR &= ~(FMC_PFB0CR_B0SEBE_MASK | FMC_PFB0CR_B0IPE_MASK | FMC_PFB0CR_B0DPE_MASK | FMC_PFB0CR_B0ICE_MASK | FMC_PFB0CR_B0DCE_MASK);
86 #endif
87 #else
88 // No cache in the device
89 #define CACHE_DISABLE
90 #endif
91 
93 // Prototypes
95 extern uint32_t RelocateFunction(uint32_t dest, uint32_t size, uint32_t src);
96 void error_trap(void);
97 #endif // __MAIN__
uint32_t RelocateFunction(uint32_t dest, uint32_t size, uint32_t src)
void error_trap(void)
Definition: driver_examples/flash/main.c:209