annotate Small_CPU/Src/RTE_FlashAccess.c @ 547:12f8745c8a94

Added viewport calibration to dive menu: To allow adjustments of the viewport during dive an option has been added to the dive menu "Xtra" including multi language strings
author Ideenmodellierer
date Mon, 02 Nov 2020 21:17:45 +0100
parents 5f11787b4f42
children 91a8f9893e68
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file RTE_FLashAccess.c based on BonexFlashAccess.c based on firmwareEraseProgram.v
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 20-July-2016
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * @since 20-July-2016
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * @brief erase and program the STM32F4xx internal FLASH memory for compasss calib etc.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * based on firmwareEraseProgram.c from OSTC4
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ##### How to use #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 4 x 32 Byte with first block can not be 0xFFFFFFFF
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 * <h2><center>&copy; COPYRIGHT(c) 2015 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "RTE_FlashAccess.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #include "stdio.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 /** @addtogroup BONEXINFOSYSTEM
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 /* Exported variables --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 /* taken from
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 * C:\Users\hw\STM32Cube\Repository\STM32Cube_FW_F3_V1.2.0\Projects\STM32F3-Discovery\Examples\FLASH\FLASH_EraseProgram
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 #define FLASH_SECTOR_SIZE_128KB (0x00020000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 #define FLASH_USER_START_ADDR (ADDR_FLASH_SECTOR_7) /* Start @ of user Flash area */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 #define FLASH_USER_END_ADDR (ADDR_FLASH_SECTOR_7 + FLASH_SECTOR_SIZE_128KB) /* End @ of user Flash area */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 /* Base address of the Flash pages */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 #define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 #define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 #define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 #define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 #define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 #define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 #define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 #define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 //static FLASH_EraseInitTypeDef EraseInitStruct; //Variable used for Erase procedure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 uint32_t Address = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 uint32_t PageError = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 __IO uint32_t data32 = 0 , MemoryProgramStatus = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 //uint8_t BFA_eraseSectors(uint32_t SectorAddress, uint32_t NbSectors);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 //uint8_t BFA_eraseSectorsAll(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 uint8_t BFA_FindLastDataBlockAndSetAddress(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 uint8_t BFA_readLastDataBlock(uint32_t *dataArray4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 uint8_t answer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 answer = BFA_FindLastDataBlockAndSetAddress();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 if(answer != BFA_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 return answer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 dataArray4[0] = *(__IO uint32_t*)(Address + 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 dataArray4[1] = *(__IO uint32_t*)(Address + 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 dataArray4[2] = *(__IO uint32_t*)(Address + 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 dataArray4[3] = *(__IO uint32_t*)(Address + 12);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 return BFA_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 uint8_t BFA_writeDataBlock(const uint32_t *dataArray4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 uint8_t answer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 uint32_t dataTest[4];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 uint32_t StartAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 answer = BFA_FindLastDataBlockAndSetAddress();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 Address = Address + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 if((answer == BFA_EMPTY) || (Address >= FLASH_USER_END_ADDR) || (Address < FLASH_USER_START_ADDR))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 Address = FLASH_USER_START_ADDR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 dataTest[0] = *(__IO uint32_t*)(Address + 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 dataTest[1] = *(__IO uint32_t*)(Address + 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 dataTest[2] = *(__IO uint32_t*)(Address + 8);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 dataTest[3] = *(__IO uint32_t*)(Address + 12);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 for(int i=0;i<4;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 if(dataTest[i] != 0xFFFFFFFF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 // answer = BFA_eraseSectorsAll();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 // break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 answer = BFA_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 // can I write?
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 if(answer != BFA_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 return answer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 StartAddress = Address;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 HAL_FLASH_Unlock();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 for(int i=0;i<4;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 answer = HAL_FLASH_Program(TYPEPROGRAM_WORD, Address, dataArray4[i]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 Address = Address + 4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 HAL_FLASH_Lock();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 Address = StartAddress; // back to start of this data set (for reading etc.)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 return answer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 uint8_t BFA_eraseSectorsAll(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 return BFA_eraseSectors(FLASH_USER_START_ADDR, (FLASH_USER_END_ADDR - FLASH_USER_START_ADDR)/FLASH_SECTOR_SIZE_128KB);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 uint8_t BFA_eraseSectors(uint32_t SectorAddress, uint32_t NbSectors)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 if((NbSectors > 1) || (SectorAddress != FLASH_USER_START_ADDR))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 uint8_t answer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 uint32_t PageError = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 HAL_FLASH_Unlock();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;//ERASE_SECTORS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 EraseInitStruct.Sector = SectorAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 EraseInitStruct.NbSectors = NbSectors;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 answer = HAL_FLASHEx_Erase(&EraseInitStruct, &PageError);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 HAL_FLASH_Lock();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 return answer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 uint8_t BFA_FindLastDataBlockAndSetAddress(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 uint32_t StartAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 // first part from here to the end
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 // there it should be, most likely at Address itself
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 if(Address == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 Address = FLASH_USER_END_ADDR - 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 Address &= 0xFFFFFFF0; // align with 16Byte
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 StartAddress = Address;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 while (Address >= FLASH_USER_START_ADDR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 data32 = *(__IO uint32_t*)Address;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 if(data32 != 0xFFFFFFFF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 return BFA_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 Address = Address - 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 // second part from the end to here
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 if(StartAddress == FLASH_USER_END_ADDR - 16)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 return BFA_EMPTY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 Address = FLASH_USER_END_ADDR - 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 while (Address > StartAddress)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 data32 = *(__IO uint32_t*)Address;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 if(data32 != 0xFFFFFFFF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 return BFA_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 Address = Address - 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 // empty flash
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 return BFA_EMPTY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215