@@ -54,7 +54,7 @@ int32_t flash_init(flash_t *obj)
54
54
}
55
55
int32_t flash_free (flash_t * obj )
56
56
{
57
- /* Disable the Flash option control register access (recommended to protect
57
+ /* Disable the Flash option control register access (recommended to protect
58
58
the option Bytes against possible unwanted operations) */
59
59
if (HAL_FLASH_Lock ()) {
60
60
return -1 ;
@@ -68,12 +68,12 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
68
68
static FLASH_EraseInitTypeDef EraseInitStruct ;
69
69
uint32_t FirstSector ;
70
70
uint32_t SectorError = 0 ;
71
-
71
+
72
72
if ((address >= (FLASH_BASE + FLASH_SIZE )) || (address < FLASH_BASE )) {
73
73
74
74
return -1 ;
75
75
}
76
-
76
+
77
77
/* Get the 1st sector to erase */
78
78
FirstSector = GetSector (address );
79
79
@@ -123,7 +123,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
123
123
124
124
uint32_t flash_get_sector_size (const flash_t * obj , uint32_t address )
125
125
{
126
-
126
+
127
127
if ((address >= (FLASH_BASE + FLASH_SIZE )) || (address < FLASH_BASE )) {
128
128
return MBED_FLASH_INVALID_SIZE ;
129
129
}
@@ -142,7 +142,7 @@ uint32_t flash_get_start_address(const flash_t *obj)
142
142
}
143
143
uint32_t flash_get_size (const flash_t * obj )
144
144
{
145
- return FLASH_SIZE ;
145
+ return FLASH_SIZE ;
146
146
}
147
147
148
148
/**
@@ -152,21 +152,19 @@ uint32_t flash_get_size(const flash_t *obj)
152
152
*/
153
153
static uint32_t GetSector (uint32_t address )
154
154
{
155
- uint32_t sector = 0 ;
155
+ uint32_t sector = 0 ;
156
156
uint32_t tmp = address - ADDR_FLASH_SECTOR_0 ;
157
157
if (address & 0x100000 ) { // handle 2nd bank
158
158
sector = FLASH_SECTOR_12 ;
159
159
tmp = address - ADDR_FLASH_SECTOR_12 ;
160
160
}
161
161
if (address < ADDR_FLASH_SECTOR_4 ) { // 16k sectorsize
162
- //printf("tmp for sectors less than 4: 0X%4x")
163
162
sector += tmp >>14 ;
164
163
} else if (address < ADDR_FLASH_SECTOR_5 ) { //64k sector size
165
- sector += FLASH_SECTOR_4 ;
164
+ sector += FLASH_SECTOR_4 ;
166
165
} else {
167
166
sector += 4 + (tmp >>17 );
168
167
}
169
- printf ("address:0X%04x%04x, secteur: %d\n" , (address >>16 )& 0XFFFF , (address & 0XFFFF ), sector );
170
168
return sector ;
171
169
}
172
170
@@ -186,7 +184,7 @@ static uint32_t GetSectorSize(uint32_t Sector)
186
184
sectorsize = 64 * 1024 ;
187
185
} else {
188
186
sectorsize = 128 * 1024 ;
189
- }
187
+ }
190
188
return sectorsize ;
191
189
}
192
190
0 commit comments