mirror of https://github.com/ARMmbed/mbed-os.git
STM32WB: Add FLASH HW Semaphore
Because FLASH is a shared resource between the 2 STM32WB cores, SW needs to acquire HW Semaphore before using the resource.pull/9814/head
parent
14ee4a1c7b
commit
b21110d6b8
|
@ -23,6 +23,10 @@
|
|||
#include "mbed_assert.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
/* Family specific include for WB with HW semaphores */
|
||||
#include "hw.h"
|
||||
#include "hw_conf.h"
|
||||
|
||||
/**
|
||||
* @brief Gets the page of a given address
|
||||
* @param Addr: Address of the FLASH Memory
|
||||
|
@ -71,6 +75,11 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if defined(CFG_HW_FLASH_SEMID)
|
||||
/* In case RNG is a shared ressource, get the HW semaphore first */
|
||||
while( LL_HSEM_1StepLock( HSEM, CFG_HW_FLASH_SEMID ) );
|
||||
#endif
|
||||
|
||||
/* Unlock the Flash to enable the flash control register access */
|
||||
if (HAL_FLASH_Unlock() != HAL_OK) {
|
||||
return -1;
|
||||
|
@ -99,6 +108,10 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
|||
to protect the FLASH memory against possible unwanted operation) */
|
||||
HAL_FLASH_Lock();
|
||||
|
||||
#if defined(CFG_HW_FLASH_SEMID)
|
||||
LL_HSEM_ReleaseLock( HSEM, CFG_HW_FLASH_SEMID, 0 );
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -126,6 +139,11 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if defined(CFG_HW_FLASH_SEMID)
|
||||
/* In case RNG is a shared ressource, get the HW semaphore first */
|
||||
while( LL_HSEM_1StepLock( HSEM, CFG_HW_FLASH_SEMID ) );
|
||||
#endif
|
||||
|
||||
/* Unlock the Flash to enable the flash control register access */
|
||||
if (HAL_FLASH_Unlock() != HAL_OK) {
|
||||
return -1;
|
||||
|
@ -163,6 +181,10 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
to protect the FLASH memory against possible unwanted operation) */
|
||||
HAL_FLASH_Lock();
|
||||
|
||||
#if defined(CFG_HW_FLASH_SEMID)
|
||||
LL_HSEM_ReleaseLock( HSEM, CFG_HW_FLASH_SEMID, 0 );
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue