|
23 | 23 | #include "mbed_assert.h"
|
24 | 24 | #include "cmsis.h"
|
25 | 25 |
|
| 26 | +/* Family specific include for WB with HW semaphores */ |
| 27 | +#include "hw.h" |
| 28 | +#include "hw_conf.h" |
| 29 | + |
26 | 30 | /**
|
27 | 31 | * @brief Gets the page of a given address
|
28 | 32 | * @param Addr: Address of the FLASH Memory
|
@@ -71,6 +75,11 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
71 | 75 | return -1;
|
72 | 76 | }
|
73 | 77 |
|
| 78 | +#if defined(CFG_HW_FLASH_SEMID) |
| 79 | + /* In case RNG is a shared ressource, get the HW semaphore first */ |
| 80 | + while( LL_HSEM_1StepLock( HSEM, CFG_HW_FLASH_SEMID ) ); |
| 81 | +#endif |
| 82 | + |
74 | 83 | /* Unlock the Flash to enable the flash control register access */
|
75 | 84 | if (HAL_FLASH_Unlock() != HAL_OK) {
|
76 | 85 | return -1;
|
@@ -99,6 +108,10 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
99 | 108 | to protect the FLASH memory against possible unwanted operation) */
|
100 | 109 | HAL_FLASH_Lock();
|
101 | 110 |
|
| 111 | +#if defined(CFG_HW_FLASH_SEMID) |
| 112 | + LL_HSEM_ReleaseLock( HSEM, CFG_HW_FLASH_SEMID, 0 ); |
| 113 | +#endif |
| 114 | + |
102 | 115 | return status;
|
103 | 116 | }
|
104 | 117 |
|
@@ -126,6 +139,11 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
126 | 139 | return -1;
|
127 | 140 | }
|
128 | 141 |
|
| 142 | +#if defined(CFG_HW_FLASH_SEMID) |
| 143 | + /* In case RNG is a shared ressource, get the HW semaphore first */ |
| 144 | + while( LL_HSEM_1StepLock( HSEM, CFG_HW_FLASH_SEMID ) ); |
| 145 | +#endif |
| 146 | + |
129 | 147 | /* Unlock the Flash to enable the flash control register access */
|
130 | 148 | if (HAL_FLASH_Unlock() != HAL_OK) {
|
131 | 149 | return -1;
|
@@ -163,6 +181,10 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
163 | 181 | to protect the FLASH memory against possible unwanted operation) */
|
164 | 182 | HAL_FLASH_Lock();
|
165 | 183 |
|
| 184 | +#if defined(CFG_HW_FLASH_SEMID) |
| 185 | + LL_HSEM_ReleaseLock( HSEM, CFG_HW_FLASH_SEMID, 0 ); |
| 186 | +#endif |
| 187 | + |
166 | 188 | return status;
|
167 | 189 | }
|
168 | 190 |
|
|
0 commit comments