Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 6 | ||
|---|---|---|---|
| Line 123... | Line 123... | ||
| 123 | ============================================================================== |
123 | ============================================================================== |
| 124 | ##### FLASH Erasing Programming functions ##### |
124 | ##### FLASH Erasing Programming functions ##### |
| 125 | ============================================================================== |
125 | ============================================================================== |
| 126 | 126 | ||
| 127 | [..] The FLASH Memory Erasing functions, includes the following functions: |
127 | [..] The FLASH Memory Erasing functions, includes the following functions: |
| 128 | (+) @ref HAL_FLASHEx_Erase: return only when erase has been done |
128 | (+) HAL_FLASHEx_Erase: return only when erase has been done |
| 129 | (+) @ref HAL_FLASHEx_Erase_IT: end of erase is done when @ref HAL_FLASH_EndOfOperationCallback |
129 | (+) HAL_FLASHEx_Erase_IT: end of erase is done when HAL_FLASH_EndOfOperationCallback |
| 130 | is called with parameter 0xFFFFFFFF |
130 | is called with parameter 0xFFFFFFFF |
| 131 | 131 | ||
| 132 | [..] Any operation of erase should follow these steps: |
132 | [..] Any operation of erase should follow these steps: |
| 133 | (#) Call the @ref HAL_FLASH_Unlock() function to enable the flash control register and |
133 | (#) Call the HAL_FLASH_Unlock() function to enable the flash control register and |
| 134 | program memory access. |
134 | program memory access. |
| 135 | (#) Call the desired function to erase page. |
135 | (#) Call the desired function to erase page. |
| 136 | (#) Call the @ref HAL_FLASH_Lock() to disable the flash program memory access |
136 | (#) Call the HAL_FLASH_Lock() to disable the flash program memory access |
| 137 | (recommended to protect the FLASH memory against possible unwanted operation). |
137 | (recommended to protect the FLASH memory against possible unwanted operation). |
| 138 | 138 | ||
| 139 | @endverbatim |
139 | @endverbatim |
| 140 | * @{ |
140 | * @{ |
| 141 | */ |
141 | */ |
| Line 692... | Line 692... | ||
| 692 | SET_BIT(FLASH->CR, FLASH_CR_OPTPG); |
692 | SET_BIT(FLASH->CR, FLASH_CR_OPTPG); |
| 693 | 693 | ||
| 694 | #if defined(OB_WRP0_WRP0) |
694 | #if defined(OB_WRP0_WRP0) |
| 695 | if(WRP0_Data != 0xFFU) |
695 | if(WRP0_Data != 0xFFU) |
| 696 | { |
696 | { |
| 697 | OB->WRP0 |= WRP0_Data; |
697 | OB->WRP0 &= WRP0_Data; |
| 698 | 698 | ||
| 699 | /* Wait for last operation to be completed */ |
699 | /* Wait for last operation to be completed */ |
| 700 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
700 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
| 701 | } |
701 | } |
| 702 | #endif /* OB_WRP0_WRP0 */ |
702 | #endif /* OB_WRP0_WRP0 */ |
| 703 | 703 | ||
| 704 | #if defined(OB_WRP1_WRP1) |
704 | #if defined(OB_WRP1_WRP1) |
| 705 | if((status == HAL_OK) && (WRP1_Data != 0xFFU)) |
705 | if((status == HAL_OK) && (WRP1_Data != 0xFFU)) |
| 706 | { |
706 | { |
| 707 | OB->WRP1 |= WRP1_Data; |
707 | OB->WRP1 &= WRP1_Data; |
| 708 | 708 | ||
| 709 | /* Wait for last operation to be completed */ |
709 | /* Wait for last operation to be completed */ |
| 710 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
710 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
| 711 | } |
711 | } |
| 712 | #endif /* OB_WRP1_WRP1 */ |
712 | #endif /* OB_WRP1_WRP1 */ |
| 713 | 713 | ||
| 714 | #if defined(OB_WRP2_WRP2) |
714 | #if defined(OB_WRP2_WRP2) |
| 715 | if((status == HAL_OK) && (WRP2_Data != 0xFFU)) |
715 | if((status == HAL_OK) && (WRP2_Data != 0xFFU)) |
| 716 | { |
716 | { |
| 717 | OB->WRP2 |= WRP2_Data; |
717 | OB->WRP2 &= WRP2_Data; |
| 718 | 718 | ||
| 719 | /* Wait for last operation to be completed */ |
719 | /* Wait for last operation to be completed */ |
| 720 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
720 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
| 721 | } |
721 | } |
| 722 | #endif /* OB_WRP2_WRP2 */ |
722 | #endif /* OB_WRP2_WRP2 */ |
| 723 | 723 | ||
| 724 | #if defined(OB_WRP3_WRP3) |
724 | #if defined(OB_WRP3_WRP3) |
| 725 | if((status == HAL_OK) && (WRP3_Data != 0xFFU)) |
725 | if((status == HAL_OK) && (WRP3_Data != 0xFFU)) |
| 726 | { |
726 | { |
| 727 | OB->WRP3 |= WRP3_Data; |
727 | OB->WRP3 &= WRP3_Data; |
| 728 | 728 | ||
| 729 | /* Wait for last operation to be completed */ |
729 | /* Wait for last operation to be completed */ |
| 730 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
730 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
| 731 | } |
731 | } |
| 732 | #endif /* OB_WRP3_WRP3 */ |
732 | #endif /* OB_WRP3_WRP3 */ |