28
28
// Minimum number of bytes to be programmed at a time
29
29
#define MIN_PROG_SIZE (4U)
30
30
31
- /** Initialize the flash peripheral and the flash_t object
32
- *
33
- * @param obj The flash object
34
- * @return 0 for success, -1 for error
35
- */
36
- int32_t flash_init (flash_t * obj )
37
- {
38
- return 0 ;
39
- }
40
-
41
- /** Uninitialize the flash peripheral and the flash_t object
42
- *
43
- * @param obj The flash object
44
- * @return 0 for success, -1 for error
45
- */
46
- int32_t flash_free (flash_t * obj )
47
- {
48
- return 0 ;
49
- }
50
-
51
31
static int32_t flash_unlock (void )
52
32
{
53
- /* Allow Access to Flash control registers and user Falsh */
33
+ /* Allow Access to Flash control registers and user Flash */
54
34
if (HAL_FLASH_Unlock ()) {
55
35
return -1 ;
56
36
} else {
@@ -69,13 +49,16 @@ static int32_t flash_lock(void)
69
49
}
70
50
}
71
51
72
- /** Erase one sector starting at defined address
73
- *
74
- * The address should be at sector boundary. This function does not do any check for address alignments
75
- * @param obj The flash object
76
- * @param address The sector starting address
77
- * @return 0 for success, -1 for error
78
- */
52
+ int32_t flash_init (flash_t * obj )
53
+ {
54
+ return 0 ;
55
+ }
56
+
57
+ int32_t flash_free (flash_t * obj )
58
+ {
59
+ return 0 ;
60
+ }
61
+
79
62
int32_t flash_erase_sector (flash_t * obj , uint32_t address )
80
63
{
81
64
uint32_t PAGEError = 0 ;
@@ -113,19 +96,7 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
113
96
return status ;
114
97
}
115
98
116
- /** Program one page starting at defined address
117
- *
118
- * The page should be at page boundary, should not cross multiple sectors.
119
- * This function does not do any check for address alignments or if size
120
- * is aligned to a page size.
121
- * @param obj The flash object
122
- * @param address The sector starting address
123
- * @param data The data buffer to be programmed
124
- * @param size The number of bytes to program
125
- * @return 0 for success, -1 for error
126
- */
127
- int32_t flash_program_page (flash_t * obj , uint32_t address ,
128
- const uint8_t * data , uint32_t size )
99
+ int32_t flash_program_page (flash_t * obj , uint32_t address , const uint8_t * data , uint32_t size )
129
100
{
130
101
uint32_t StartAddress = 0 ;
131
102
int32_t status = 0 ;
@@ -177,13 +148,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
177
148
return status ;
178
149
}
179
150
180
- /** Get sector size
181
- *
182
- * @param obj The flash object
183
- * @param address The sector starting address
184
- * @return The size of a sector (in our case considering 1 sector = 1 page)
185
- */
186
- uint32_t flash_get_sector_size (const flash_t * obj , uint32_t address )
151
+ uint32_t flash_get_sector_size (const flash_t * obj , uint32_t address )
187
152
{
188
153
if (!(IS_FLASH_PROGRAM_ADDRESS (address ))) {
189
154
return MBED_FLASH_INVALID_SIZE ;
@@ -192,33 +157,17 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
192
157
}
193
158
}
194
159
195
- /** Get page size
196
- *
197
- * @param obj The flash object
198
- * @param address The page starting address
199
- * @return The size of a page (in our case the minimum programmable size)
200
- */
201
160
uint32_t flash_get_page_size (const flash_t * obj )
202
161
{
203
162
return MIN_PROG_SIZE ;
204
163
}
205
164
206
- /** Get start address for the flash region
207
- *
208
- * @param obj The flash object
209
- * @return The start address for the flash region
210
- */
211
- uint32_t flash_get_start_address (const flash_t * obj )
165
+ uint32_t flash_get_start_address (const flash_t * obj )
212
166
{
213
167
return FLASH_BASE ;
214
168
}
215
169
216
- /** Get the flash region size
217
- *
218
- * @param obj The flash object
219
- * @return The flash region size
220
- */
221
- uint32_t flash_get_size (const flash_t * obj )
170
+ uint32_t flash_get_size (const flash_t * obj )
222
171
{
223
172
return FLASH_SIZE ;
224
173
}
0 commit comments