rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions

Programming operation functions. More...

Collaboration diagram for Programming operation functions:

Functions

HAL_StatusTypeDef HAL_FLASH_Program (uint32_t TypeProgram, uint32_t Address, uint64_t Data)
 Program byte, halfword, word or double word at a specified address.
 
HAL_StatusTypeDef HAL_FLASH_Program_IT (uint32_t TypeProgram, uint32_t Address, uint64_t Data)
 Program byte, halfword, word or double word at a specified address with interrupt enabled.
 
void HAL_FLASH_IRQHandler (void)
 This function handles FLASH interrupt request.
 
__weak void HAL_FLASH_EndOfOperationCallback (uint32_t ReturnValue)
 FLASH end of operation interrupt callback.
 
__weak void HAL_FLASH_OperationErrorCallback (uint32_t ReturnValue)
 FLASH operation error interrupt callback.
 
HAL_StatusTypeDef HAL_FLASH_Program (uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress)
 Program flash word at a specified address.
 
HAL_StatusTypeDef HAL_FLASH_Program_IT (uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress)
 Program flash words of 256 bits at a specified address with interrupt enabled.
 

Detailed Description

Programming operation functions.

 ===============================================================================
                  ##### Programming operation functions #####
 ===============================================================================  
    [..]
    This subsection provides a set of functions allowing to manage the FLASH 
    program operations.

Function Documentation

◆ HAL_FLASH_EndOfOperationCallback()

void HAL_FLASH_EndOfOperationCallback ( uint32_t  ReturnValue)

FLASH end of operation interrupt callback.

Parameters
ReturnValueThe value saved in this parameter depends on the ongoing procedure Mass Erase: Bank number which has been requested to erase Sectors Erase: Sector which has been erased (if 0xFFFFFFFF, it means that all the selected sectors have been erased) Program: Address which was selected for data program
Return values
None
Parameters
ReturnValueThe value saved in this parameter depends on the ongoing procedure
  • Sectors Erase: Sector which has been erased (if 0xFFFFFFFF, it means that all the selected sectors have been erased)
  • Program : Address which was selected for data program
  • Mass Erase : No return value expected
Return values
None
Parameters
ReturnValueThe value saved in this parameter depends on the ongoing procedure Mass Erase: Bank number which has been requested to erase Sectors Erase: Sector which has been erased (if 0xFFFFFFFF, it means that all the selected sectors have been erased) Program: Address which was selected for data program
Return values
None

Definition at line 407 of file stm32f4xx_hal_flash.c.

408{
409 (void)ReturnValue;
410 /* NOTE : This function Should not be modified, when the callback is needed,
411 the HAL_FLASH_EndOfOperationCallback could be implemented in the user file
412 */
413}

Referenced by HAL_FLASH_IRQHandler().

Here is the caller graph for this function:

◆ HAL_FLASH_IRQHandler()

void HAL_FLASH_IRQHandler ( void  )

This function handles FLASH interrupt request.

Return values
None

Definition at line 289 of file stm32f4xx_hal_flash.c.

290{
291 uint32_t addresstmp = 0;
292
293 /* Check FLASH operation error flags */
294 if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | \
295 FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR | FLASH_FLAG_RDERR)) != RESET)
296 {
297 if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE)
298 {
299 /*return the faulty sector*/
300 addresstmp = pFlash.Sector;
301 pFlash.Sector = 0xFFFFFFFF;
302 }
303 else if(pFlash.ProcedureOnGoing == FLASH_PROC_MASSERASE)
304 {
305 /*return the faulty bank*/
306 addresstmp = pFlash.Bank;
307 }
308 else
309 {
310 /*return the faulty address*/
311 addresstmp = pFlash.Address;
312 }
313
314 /*Save the Error code*/
316
317 /* FLASH error interrupt user callback */
319
320 /*Stop the procedure ongoing*/
321 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
322 }
323
324 /* Check FLASH End of Operation flag */
325 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP) != RESET)
326 {
327 /* Clear FLASH End of Operation pending bit */
328 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
329
330 if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE)
331 {
332 /*Nb of sector to erased can be decreased*/
334
335 /* Check if there are still sectors to erase*/
336 if(pFlash.NbSectorsToErase != 0)
337 {
338 addresstmp = pFlash.Sector;
339 /*Indicate user which sector has been erased*/
341
342 /*Increment sector number*/
343 pFlash.Sector++;
344 addresstmp = pFlash.Sector;
346 }
347 else
348 {
349 /*No more sectors to Erase, user callback can be called.*/
350 /*Reset Sector and stop Erase sectors procedure*/
351 pFlash.Sector = addresstmp = 0xFFFFFFFF;
352 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
353
354 /* Flush the caches to be sure of the data consistency */
356
357 /* FLASH EOP interrupt user callback */
359 }
360 }
361 else
362 {
363 if(pFlash.ProcedureOnGoing == FLASH_PROC_MASSERASE)
364 {
365 /* MassErase ended. Return the selected bank */
366 /* Flush the caches to be sure of the data consistency */
368
369 /* FLASH EOP interrupt user callback */
371 }
372 else
373 {
374 /*Program ended. Return the selected address*/
375 /* FLASH EOP interrupt user callback */
377 }
378 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
379 }
380 }
381
382 if(pFlash.ProcedureOnGoing == FLASH_PROC_NONE)
383 {
384 /* Operation is completed, disable the PG, SER, SNB and MER Bits */
385 CLEAR_BIT(FLASH->CR, (FLASH_CR_PG | FLASH_CR_SER | FLASH_CR_SNB | FLASH_MER_BIT));
386
387 /* Disable End of FLASH Operation interrupt */
388 __HAL_FLASH_DISABLE_IT(FLASH_IT_EOP);
389
390 /* Disable Error source interrupt */
391 __HAL_FLASH_DISABLE_IT(FLASH_IT_ERR);
392
393 /* Process Unlocked */
394 __HAL_UNLOCK(&pFlash);
395 }
396}
__weak void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue)
FLASH operation error interrupt callback.
__weak void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue)
FLASH end of operation interrupt callback.
void FLASH_FlushCaches(void)
Flush the instruction and data caches.
static void FLASH_SetErrorCode(void)
Set the specific FLASH error flag.
FLASH_ProcessTypeDef pFlash
void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange)
Erase the specified FLASH memory sector.
__IO FLASH_ProcedureTypeDef ProcedureOnGoing
Here is the call graph for this function:

◆ HAL_FLASH_OperationErrorCallback()

void HAL_FLASH_OperationErrorCallback ( uint32_t  ReturnValue)

FLASH operation error interrupt callback.

Parameters
ReturnValueThe value saved in this parameter depends on the ongoing procedure Mass Erase: Bank number which has been requested to erase Sectors Erase: Sector number which returned an error Program: Address which was selected for data program
Return values
None
Parameters
ReturnValueThe value saved in this parameter depends on the ongoing procedure
  • Sectors Erase: Sector which has been erased (if 0xFFFFFFFF, it means that all the selected sectors have been erased)
  • Program : Address which was selected for data program
  • Mass Erase : No return value expected
Return values
None
Parameters
ReturnValueThe value saved in this parameter depends on the ongoing procedure Mass Erase: Bank number which has been requested to erase Sectors Erase: Sector number which returned an error Program: Address which was selected for data program
Return values
None

Definition at line 423 of file stm32f4xx_hal_flash.c.

424{
425 (void)ReturnValue;
426 /* NOTE : This function Should not be modified, when the callback is needed,
427 the HAL_FLASH_OperationErrorCallback could be implemented in the user file
428 */
429}

Referenced by HAL_FLASH_IRQHandler().

Here is the caller graph for this function:

◆ HAL_FLASH_Program() [1/2]

HAL_StatusTypeDef HAL_FLASH_Program ( uint32_t  TypeProgram,
uint32_t  Address,
uint64_t  Data 
)

Program byte, halfword, word or double word at a specified address.

Parameters
TypeProgramIndicate the way to program at a specified address. This parameter can be a value of FLASH Type Program
Addressspecifies the address to be programmed.
Dataspecifies the data to be programmed
Return values
HAL_StatusTypeDefHAL Status

Definition at line 184 of file stm32f4xx_hal_flash.c.

185{
186 HAL_StatusTypeDef status = HAL_ERROR;
187
188 /* Process Locked */
189 __HAL_LOCK(&pFlash);
190
191 /* Check the parameters */
192 assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
193
194 /* Wait for last operation to be completed */
195 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
196
197 if(status == HAL_OK)
198 {
199 if(TypeProgram == FLASH_TYPEPROGRAM_BYTE)
200 {
201 /*Program byte (8-bit) at a specified address.*/
202 FLASH_Program_Byte(Address, (uint8_t) Data);
203 }
204 else if(TypeProgram == FLASH_TYPEPROGRAM_HALFWORD)
205 {
206 /*Program halfword (16-bit) at a specified address.*/
207 FLASH_Program_HalfWord(Address, (uint16_t) Data);
208 }
209 else if(TypeProgram == FLASH_TYPEPROGRAM_WORD)
210 {
211 /*Program word (32-bit) at a specified address.*/
212 FLASH_Program_Word(Address, (uint32_t) Data);
213 }
214 else
215 {
216 /*Program double word (64-bit) at a specified address.*/
217 FLASH_Program_DoubleWord(Address, Data);
218 }
219
220 /* Wait for last operation to be completed */
221 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
222
223 /* If the program operation is completed, disable the PG Bit */
224 FLASH->CR &= (~FLASH_CR_PG);
225 }
226
227 /* Process Unlocked */
228 __HAL_UNLOCK(&pFlash);
229
230 return status;
231}
static void FLASH_Program_Word(uint32_t Address, uint32_t Data)
Program word (32-bit) at a specified address.
static void FLASH_Program_Byte(uint32_t Address, uint8_t Data)
Program byte (8-bit) at a specified address.
static void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data)
Program a half-word (16-bit) at a specified address.
static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data)
Program a double word (64-bit) at a specified address.
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout)
Wait for a FLASH operation to complete.
Here is the call graph for this function:

◆ HAL_FLASH_Program() [2/2]

HAL_StatusTypeDef HAL_FLASH_Program ( uint32_t  TypeProgram,
uint32_t  FlashAddress,
uint32_t  DataAddress 
)

Program flash word at a specified address.

Parameters
TypeProgramIndicate the way to program at a specified address. This parameter can be a value of FLASH Type Program
FlashAddressspecifies the address to be programmed.
DataAddressspecifies the address of data to be programmed
Return values
HAL_StatusTypeDefHAL Status

Definition at line 151 of file stm32h7xx_hal_flash.c.

152{
153 HAL_StatusTypeDef status;
154 __IO uint32_t *dest_addr = (__IO uint32_t *)FlashAddress;
155 __IO uint32_t *src_addr = (__IO uint32_t*)DataAddress;
156 uint32_t bank;
157 uint8_t row_index = FLASH_NB_32BITWORD_IN_FLASHWORD;
158
159 /* Check the parameters */
160 assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
161 assert_param(IS_FLASH_PROGRAM_ADDRESS(FlashAddress));
162
163 /* Process Locked */
164 __HAL_LOCK(&pFlash);
165
166#if defined (FLASH_OPTCR_PG_OTP)
167 if((IS_FLASH_PROGRAM_ADDRESS_BANK1(FlashAddress)) || (IS_FLASH_PROGRAM_ADDRESS_OTP(FlashAddress)))
168#else
169 if(IS_FLASH_PROGRAM_ADDRESS_BANK1(FlashAddress))
170#endif /* FLASH_OPTCR_PG_OTP */
171 {
172 bank = FLASH_BANK_1;
173 }
174#if defined (DUAL_BANK)
175 else if(IS_FLASH_PROGRAM_ADDRESS_BANK2(FlashAddress))
176 {
177 bank = FLASH_BANK_2;
178 }
179#endif /* DUAL_BANK */
180 else
181 {
182 return HAL_ERROR;
183 }
184
185 /* Reset error code */
186 pFlash.ErrorCode = HAL_FLASH_ERROR_NONE;
187
188 /* Wait for last operation to be completed */
189 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE, bank);
190
191 if(status == HAL_OK)
192 {
193#if defined (DUAL_BANK)
194 if(bank == FLASH_BANK_1)
195 {
196#if defined (FLASH_OPTCR_PG_OTP)
197 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
198 {
199 /* Set OTP_PG bit */
200 SET_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
201 }
202 else
203#endif /* FLASH_OPTCR_PG_OTP */
204 {
205 /* Set PG bit */
206 SET_BIT(FLASH->CR1, FLASH_CR_PG);
207 }
208 }
209 else
210 {
211 /* Set PG bit */
212 SET_BIT(FLASH->CR2, FLASH_CR_PG);
213 }
214#else /* Single Bank */
215#if defined (FLASH_OPTCR_PG_OTP)
216 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
217 {
218 /* Set OTP_PG bit */
219 SET_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
220 }
221 else
222#endif /* FLASH_OPTCR_PG_OTP */
223 {
224 /* Set PG bit */
225 SET_BIT(FLASH->CR1, FLASH_CR_PG);
226 }
227#endif /* DUAL_BANK */
228
229 __ISB();
230 __DSB();
231
232#if defined (FLASH_OPTCR_PG_OTP)
233 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
234 {
235 /* Program an OTP word (16 bits) */
236 *(__IO uint16_t *)FlashAddress = *(__IO uint16_t*)DataAddress;
237 }
238 else
239#endif /* FLASH_OPTCR_PG_OTP */
240 {
241 /* Program the flash word */
242 do
243 {
244 *dest_addr = *src_addr;
245 dest_addr++;
246 src_addr++;
247 row_index--;
248 } while (row_index != 0U);
249 }
250
251 __ISB();
252 __DSB();
253
254 /* Wait for last operation to be completed */
255 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE, bank);
256
257#if defined (DUAL_BANK)
258#if defined (FLASH_OPTCR_PG_OTP)
259 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
260 {
261 /* If the program operation is completed, disable the OTP_PG */
262 CLEAR_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
263 }
264 else
265#endif /* FLASH_OPTCR_PG_OTP */
266 {
267 if(bank == FLASH_BANK_1)
268 {
269 /* If the program operation is completed, disable the PG */
270 CLEAR_BIT(FLASH->CR1, FLASH_CR_PG);
271 }
272 else
273 {
274 /* If the program operation is completed, disable the PG */
275 CLEAR_BIT(FLASH->CR2, FLASH_CR_PG);
276 }
277 }
278#else /* Single Bank */
279#if defined (FLASH_OPTCR_PG_OTP)
280 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
281 {
282 /* If the program operation is completed, disable the OTP_PG */
283 CLEAR_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
284 }
285 else
286#endif /* FLASH_OPTCR_PG_OTP */
287 {
288 /* If the program operation is completed, disable the PG */
289 CLEAR_BIT(FLASH->CR1, FLASH_CR_PG);
290 }
291#endif /* DUAL_BANK */
292 }
293
294 /* Process Unlocked */
295 __HAL_UNLOCK(&pFlash);
296
297 return status;
298}
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout, uint32_t Bank)
Wait for a FLASH operation to complete.
FLASH_ProcessTypeDef pFlash
Here is the call graph for this function:

◆ HAL_FLASH_Program_IT() [1/2]

HAL_StatusTypeDef HAL_FLASH_Program_IT ( uint32_t  TypeProgram,
uint32_t  Address,
uint64_t  Data 
)

Program byte, halfword, word or double word at a specified address with interrupt enabled.

Parameters
TypeProgramIndicate the way to program at a specified address. This parameter can be a value of FLASH Type Program
Addressspecifies the address to be programmed.
Dataspecifies the data to be programmed
Return values
HALStatus

Definition at line 242 of file stm32f4xx_hal_flash.c.

243{
244 HAL_StatusTypeDef status = HAL_OK;
245
246 /* Process Locked */
247 __HAL_LOCK(&pFlash);
248
249 /* Check the parameters */
250 assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
251
252 /* Enable End of FLASH Operation interrupt */
253 __HAL_FLASH_ENABLE_IT(FLASH_IT_EOP);
254
255 /* Enable Error source interrupt */
256 __HAL_FLASH_ENABLE_IT(FLASH_IT_ERR);
257
258 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM;
259 pFlash.Address = Address;
260
261 if(TypeProgram == FLASH_TYPEPROGRAM_BYTE)
262 {
263 /*Program byte (8-bit) at a specified address.*/
264 FLASH_Program_Byte(Address, (uint8_t) Data);
265 }
266 else if(TypeProgram == FLASH_TYPEPROGRAM_HALFWORD)
267 {
268 /*Program halfword (16-bit) at a specified address.*/
269 FLASH_Program_HalfWord(Address, (uint16_t) Data);
270 }
271 else if(TypeProgram == FLASH_TYPEPROGRAM_WORD)
272 {
273 /*Program word (32-bit) at a specified address.*/
274 FLASH_Program_Word(Address, (uint32_t) Data);
275 }
276 else
277 {
278 /*Program double word (64-bit) at a specified address.*/
279 FLASH_Program_DoubleWord(Address, Data);
280 }
281
282 return status;
283}
Here is the call graph for this function:

◆ HAL_FLASH_Program_IT() [2/2]

HAL_StatusTypeDef HAL_FLASH_Program_IT ( uint32_t  TypeProgram,
uint32_t  FlashAddress,
uint32_t  DataAddress 
)

Program flash words of 256 bits at a specified address with interrupt enabled.

Parameters
TypeProgramIndicate the way to program at a specified address. This parameter can be a value of FLASH Type Program
FlashAddressspecifies the address to be programmed.
DataAddressspecifies the address of data (256 bits) to be programmed
Return values
HALStatus

Definition at line 309 of file stm32h7xx_hal_flash.c.

310{
311 HAL_StatusTypeDef status;
312 __IO uint32_t *dest_addr = (__IO uint32_t*)FlashAddress;
313 __IO uint32_t *src_addr = (__IO uint32_t*)DataAddress;
314 uint32_t bank;
315 uint8_t row_index = FLASH_NB_32BITWORD_IN_FLASHWORD;
316
317 /* Check the parameters */
318 assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
319 assert_param(IS_FLASH_PROGRAM_ADDRESS(FlashAddress));
320
321 /* Process Locked */
322 __HAL_LOCK(&pFlash);
323
324 /* Reset error code */
325 pFlash.ErrorCode = HAL_FLASH_ERROR_NONE;
326
327#if defined (FLASH_OPTCR_PG_OTP)
328 if((IS_FLASH_PROGRAM_ADDRESS_BANK1(FlashAddress)) || (IS_FLASH_PROGRAM_ADDRESS_OTP(FlashAddress)))
329#else
330 if(IS_FLASH_PROGRAM_ADDRESS_BANK1(FlashAddress))
331#endif /* FLASH_OPTCR_PG_OTP */
332 {
333 bank = FLASH_BANK_1;
334 }
335#if defined (DUAL_BANK)
336 else if(IS_FLASH_PROGRAM_ADDRESS_BANK2(FlashAddress))
337 {
338 bank = FLASH_BANK_2;
339 }
340#endif /* DUAL_BANK */
341 else
342 {
343 return HAL_ERROR;
344 }
345
346 /* Wait for last operation to be completed */
347 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE, bank);
348
349 if (status != HAL_OK)
350 {
351 /* Process Unlocked */
352 __HAL_UNLOCK(&pFlash);
353 }
354 else
355 {
356 pFlash.Address = FlashAddress;
357
358#if defined (DUAL_BANK)
359 if(bank == FLASH_BANK_1)
360 {
361 /* Set internal variables used by the IRQ handler */
362 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM_BANK1;
363
364#if defined (FLASH_OPTCR_PG_OTP)
365 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
366 {
367 /* Set OTP_PG bit */
368 SET_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
369 }
370 else
371#endif /* FLASH_OPTCR_PG_OTP */
372 {
373 /* Set PG bit */
374 SET_BIT(FLASH->CR1, FLASH_CR_PG);
375 }
376
377 /* Enable End of Operation and Error interrupts for Bank 1 */
378#if defined (FLASH_CR_OPERRIE)
379 __HAL_FLASH_ENABLE_IT_BANK1(FLASH_IT_EOP_BANK1 | FLASH_IT_WRPERR_BANK1 | FLASH_IT_PGSERR_BANK1 | \
380 FLASH_IT_STRBERR_BANK1 | FLASH_IT_INCERR_BANK1 | FLASH_IT_OPERR_BANK1);
381#else
382 __HAL_FLASH_ENABLE_IT_BANK1(FLASH_IT_EOP_BANK1 | FLASH_IT_WRPERR_BANK1 | FLASH_IT_PGSERR_BANK1 | \
383 FLASH_IT_STRBERR_BANK1 | FLASH_IT_INCERR_BANK1);
384#endif /* FLASH_CR_OPERRIE */
385 }
386 else
387 {
388 /* Set internal variables used by the IRQ handler */
389 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM_BANK2;
390
391 /* Set PG bit */
392 SET_BIT(FLASH->CR2, FLASH_CR_PG);
393
394 /* Enable End of Operation and Error interrupts for Bank2 */
395#if defined (FLASH_CR_OPERRIE)
396 __HAL_FLASH_ENABLE_IT_BANK2(FLASH_IT_EOP_BANK2 | FLASH_IT_WRPERR_BANK2 | FLASH_IT_PGSERR_BANK2 | \
397 FLASH_IT_STRBERR_BANK2 | FLASH_IT_INCERR_BANK2 | FLASH_IT_OPERR_BANK2);
398#else
399 __HAL_FLASH_ENABLE_IT_BANK2(FLASH_IT_EOP_BANK2 | FLASH_IT_WRPERR_BANK2 | FLASH_IT_PGSERR_BANK2 | \
400 FLASH_IT_STRBERR_BANK2 | FLASH_IT_INCERR_BANK2);
401#endif /* FLASH_CR_OPERRIE */
402 }
403#else /* Single Bank */
404 /* Set internal variables used by the IRQ handler */
405 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM_BANK1;
406
407#if defined (FLASH_OPTCR_PG_OTP)
408 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
409 {
410 /* Set OTP_PG bit */
411 SET_BIT(FLASH->OPTCR, FLASH_OPTCR_PG_OTP);
412 }
413 else
414#endif /* FLASH_OPTCR_PG_OTP */
415 {
416 /* Set PG bit */
417 SET_BIT(FLASH->CR1, FLASH_CR_PG);
418 }
419
420 /* Enable End of Operation and Error interrupts for Bank 1 */
421#if defined (FLASH_CR_OPERRIE)
422 __HAL_FLASH_ENABLE_IT_BANK1(FLASH_IT_EOP_BANK1 | FLASH_IT_WRPERR_BANK1 | FLASH_IT_PGSERR_BANK1 | \
423 FLASH_IT_STRBERR_BANK1 | FLASH_IT_INCERR_BANK1 | FLASH_IT_OPERR_BANK1);
424#else
425 __HAL_FLASH_ENABLE_IT_BANK1(FLASH_IT_EOP_BANK1 | FLASH_IT_WRPERR_BANK1 | FLASH_IT_PGSERR_BANK1 | \
426 FLASH_IT_STRBERR_BANK1 | FLASH_IT_INCERR_BANK1);
427#endif /* FLASH_CR_OPERRIE */
428#endif /* DUAL_BANK */
429
430 __ISB();
431 __DSB();
432
433#if defined (FLASH_OPTCR_PG_OTP)
434 if (TypeProgram == FLASH_TYPEPROGRAM_OTPWORD)
435 {
436 /* Program an OTP word (16 bits) */
437 *(__IO uint16_t *)FlashAddress = *(__IO uint16_t*)DataAddress;
438 }
439 else
440#endif /* FLASH_OPTCR_PG_OTP */
441 {
442 /* Program the flash word */
443 do
444 {
445 *dest_addr = *src_addr;
446 dest_addr++;
447 src_addr++;
448 row_index--;
449 } while (row_index != 0U);
450 }
451
452 __ISB();
453 __DSB();
454 }
455
456 return status;
457}
Here is the call graph for this function: