mirror of https://github.com/ARMmbed/mbed-os.git
STM32: remove critical sections in flash_program_page
parent
96e19afdd1
commit
d0ea0466ad
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
#if DEVICE_FLASH
|
||||
#include "mbed_assert.h"
|
||||
|
@ -97,8 +97,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Program the user Flash area word by word */
|
||||
StartAddress = address;
|
||||
|
||||
|
@ -129,8 +127,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
#if DEVICE_FLASH
|
||||
#include "mbed_assert.h"
|
||||
|
@ -100,8 +100,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Program the user Flash area word by word */
|
||||
StartAddress = address;
|
||||
|
||||
|
@ -132,8 +130,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -86,8 +86,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Note: If an erase operation in Flash memory also concerns data in the data or instruction cache,
|
||||
you have to make sure that these data are rewritten before they are accessed during code
|
||||
execution. If this cannot be done safely, it is recommended to flush the caches by setting the
|
||||
|
@ -111,8 +109,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
#if DEVICE_FLASH
|
||||
#include "mbed_assert.h"
|
||||
|
@ -100,8 +100,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Program the user Flash area word by word */
|
||||
StartAddress = address;
|
||||
|
||||
|
@ -132,8 +130,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -81,8 +81,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Note: If an erase operation in Flash memory also concerns data in the data or instruction cache,
|
||||
you have to make sure that these data are rewritten before they are accessed during code
|
||||
execution. If this cannot be done safely, it is recommended to flush the caches by setting the
|
||||
|
@ -106,8 +104,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -127,8 +127,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Note: If an erase operation in Flash memory also concerns data in the data or instruction cache,
|
||||
you have to make sure that these data are rewritten before they are accessed during code
|
||||
execution. If this cannot be done safely, it is recommended to flush the caches by setting the
|
||||
|
@ -151,8 +149,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
SCB_CleanInvalidateDCache_by_Addr((uint32_t *)StartAddress, FullSize);
|
||||
SCB_InvalidateICache();
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
#if DEVICE_FLASH
|
||||
#include "mbed_assert.h"
|
||||
|
@ -98,8 +98,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Program the user Flash area word by word */
|
||||
StartAddress = address;
|
||||
|
||||
|
@ -130,8 +128,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
#if DEVICE_FLASH
|
||||
#include "mbed_assert.h"
|
||||
|
@ -177,8 +177,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Clear error programming flags */
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
|
||||
|
||||
|
@ -215,8 +213,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -134,8 +134,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
StartAddress = address;
|
||||
while ((address < (StartAddress + size)) && (status == 0)) {
|
||||
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, address, (uint32_t)data) == HAL_OK) {
|
||||
|
@ -156,8 +154,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
SCB_InvalidateICache();
|
||||
#endif /* DUAL_CORE */
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
#if DEVICE_FLASH
|
||||
#include "mbed_assert.h"
|
||||
|
@ -100,8 +100,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Program the user Flash area word by word */
|
||||
StartAddress = address;
|
||||
|
||||
|
@ -132,8 +130,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
#if DEVICE_FLASH
|
||||
#include "mbed_assert.h"
|
||||
|
@ -95,8 +95,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Program the user Flash area word by word */
|
||||
StartAddress = address;
|
||||
|
||||
|
@ -127,8 +125,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
#if DEVICE_FLASH
|
||||
#include "mbed_assert.h"
|
||||
|
@ -181,8 +181,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Clear error programming flags */
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
|
||||
|
||||
|
@ -219,8 +217,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
if (HAL_FLASH_Lock() != HAL_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
#if DEVICE_FLASH
|
||||
|
||||
|
@ -173,8 +174,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Clear error programming flags */
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
|
||||
|
||||
|
@ -215,8 +214,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
#if DEVICE_FLASH
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "cmsis.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
|
||||
/**
|
||||
* @brief Gets the page of a given address
|
||||
|
@ -129,8 +127,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
core_util_critical_section_enter();
|
||||
|
||||
/* Program the user Flash area word by word */
|
||||
StartAddress = address;
|
||||
|
||||
|
@ -159,8 +155,6 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
|||
}
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
while (__HAL_FLASH_GET_FLAG(FLASH_FLAG_CFGBSY));
|
||||
|
||||
/* Lock the Flash to disable the flash control register access (recommended
|
||||
|
|
Loading…
Reference in New Issue