stm32: flash: pull lock/unlock up to common_f.
This is a common operation, so definition in _all, and every part except l0/l1 have the same implementation. Bring in an _f file too.
This commit is contained in:
parent
b23dccc7ae
commit
da7ebafcbe
@ -45,4 +45,15 @@ void flash_prefetch_disable(void);
|
|||||||
|
|
||||||
void flash_set_ws(uint32_t ws);
|
void flash_set_ws(uint32_t ws);
|
||||||
|
|
||||||
|
/** Lock the Flash Program and Erase Controller
|
||||||
|
* Used to prevent spurious writes to FLASH.
|
||||||
|
*/
|
||||||
|
void flash_lock(void);
|
||||||
|
|
||||||
|
/** Unlock the Flash Program and Erase Controller
|
||||||
|
* This enables write access to the Flash memory. It is locked by default on
|
||||||
|
* reset.
|
||||||
|
*/
|
||||||
|
void flash_unlock(void);
|
||||||
|
|
||||||
END_DECLS
|
END_DECLS
|
@ -99,8 +99,6 @@
|
|||||||
|
|
||||||
BEGIN_DECLS
|
BEGIN_DECLS
|
||||||
|
|
||||||
void flash_unlock(void);
|
|
||||||
void flash_lock(void);
|
|
||||||
void flash_clear_pgerr_flag(void);
|
void flash_clear_pgerr_flag(void);
|
||||||
void flash_clear_eop_flag(void);
|
void flash_clear_eop_flag(void);
|
||||||
void flash_clear_wrprterr_flag(void);
|
void flash_clear_wrprterr_flag(void);
|
||||||
|
@ -74,8 +74,6 @@
|
|||||||
|
|
||||||
BEGIN_DECLS
|
BEGIN_DECLS
|
||||||
|
|
||||||
void flash_unlock(void);
|
|
||||||
void flash_lock(void);
|
|
||||||
void flash_clear_pgperr_flag(void);
|
void flash_clear_pgperr_flag(void);
|
||||||
void flash_clear_eop_flag(void);
|
void flash_clear_eop_flag(void);
|
||||||
void flash_clear_status_flags(void);
|
void flash_clear_status_flags(void);
|
||||||
|
@ -118,8 +118,6 @@ void flash_unlock_progmem(void);
|
|||||||
void flash_lock_progmem(void);
|
void flash_lock_progmem(void);
|
||||||
void flash_unlock_option_bytes(void);
|
void flash_unlock_option_bytes(void);
|
||||||
void flash_lock_option_bytes(void);
|
void flash_lock_option_bytes(void);
|
||||||
void flash_unlock(void);
|
|
||||||
void flash_lock(void);
|
|
||||||
|
|
||||||
void eeprom_program_word(uint32_t address, uint32_t data);
|
void eeprom_program_word(uint32_t address, uint32_t data);
|
||||||
void eeprom_program_words(uint32_t address, uint32_t *data, int length_in_words);
|
void eeprom_program_words(uint32_t address, uint32_t *data, int length_in_words);
|
||||||
|
@ -152,8 +152,6 @@
|
|||||||
|
|
||||||
BEGIN_DECLS
|
BEGIN_DECLS
|
||||||
|
|
||||||
void flash_unlock(void);
|
|
||||||
void flash_lock(void);
|
|
||||||
void flash_clear_pgperr_flag(void);
|
void flash_clear_pgperr_flag(void);
|
||||||
void flash_clear_eop_flag(void);
|
void flash_clear_eop_flag(void);
|
||||||
void flash_wait_for_last_operation(void);
|
void flash_wait_for_last_operation(void);
|
||||||
|
@ -224,8 +224,6 @@
|
|||||||
|
|
||||||
BEGIN_DECLS
|
BEGIN_DECLS
|
||||||
|
|
||||||
void flash_unlock(void);
|
|
||||||
void flash_lock(void);
|
|
||||||
void flash_clear_pgperr_flag(void);
|
void flash_clear_pgperr_flag(void);
|
||||||
void flash_clear_eop_flag(void);
|
void flash_clear_eop_flag(void);
|
||||||
void flash_wait_for_last_operation(void);
|
void flash_wait_for_last_operation(void);
|
||||||
|
41
lib/stm32/common/flash_common_f.c
Normal file
41
lib/stm32/common/flash_common_f.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/** @addtogroup flash_file
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* This library is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**@{*/
|
||||||
|
|
||||||
|
#include <libopencm3/stm32/flash.h>
|
||||||
|
|
||||||
|
|
||||||
|
void flash_unlock(void)
|
||||||
|
{
|
||||||
|
/* Clear the unlock state. */
|
||||||
|
FLASH_CR |= FLASH_CR_LOCK;
|
||||||
|
|
||||||
|
/* Authorize the FPEC access. */
|
||||||
|
FLASH_KEYR = FLASH_KEYR_KEY1;
|
||||||
|
FLASH_KEYR = FLASH_KEYR_KEY2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void flash_lock(void)
|
||||||
|
{
|
||||||
|
FLASH_CR |= FLASH_CR_LOCK;
|
||||||
|
}
|
||||||
|
|
@ -48,26 +48,6 @@ This enables write access to the Flash memory. It is locked by default on
|
|||||||
reset.
|
reset.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void flash_unlock(void)
|
|
||||||
{
|
|
||||||
/* Clear the unlock state. */
|
|
||||||
FLASH_CR |= FLASH_CR_LOCK;
|
|
||||||
|
|
||||||
/* Authorize the FPEC access. */
|
|
||||||
FLASH_KEYR = FLASH_KEYR_KEY1;
|
|
||||||
FLASH_KEYR = FLASH_KEYR_KEY2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** @brief Lock the Flash Program and Erase Controller
|
|
||||||
|
|
||||||
Used to prevent spurious writes to FLASH.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void flash_lock(void)
|
|
||||||
{
|
|
||||||
FLASH_CR |= FLASH_CR_LOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @brief Clear the Programming Error Status Flag
|
/** @brief Clear the Programming Error Status Flag
|
||||||
|
@ -44,33 +44,6 @@ void flash_set_ws(uint32_t ws)
|
|||||||
FLASH_ACR = reg32;
|
FLASH_ACR = reg32;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** @brief Unlock the Flash Program and Erase Controller
|
|
||||||
|
|
||||||
This enables write access to the Flash memory. It is locked by default on
|
|
||||||
reset.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void flash_unlock(void)
|
|
||||||
{
|
|
||||||
/* Clear the unlock sequence state. */
|
|
||||||
FLASH_CR |= FLASH_CR_LOCK;
|
|
||||||
|
|
||||||
/* Authorize the FPEC access. */
|
|
||||||
FLASH_KEYR = FLASH_KEYR_KEY1;
|
|
||||||
FLASH_KEYR = FLASH_KEYR_KEY2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** @brief Lock the Flash Program and Erase Controller
|
|
||||||
|
|
||||||
Used to prevent spurious writes to FLASH.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void flash_lock(void)
|
|
||||||
{
|
|
||||||
FLASH_CR |= FLASH_CR_LOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @brief Clear the Programming Error Status Flag
|
/** @brief Clear the Programming Error Status Flag
|
||||||
|
@ -47,7 +47,7 @@ OBJS += gpio_common_all.o gpio_common_f0234.o crc_common_all.o crc_v2
|
|||||||
|
|
||||||
OBJS += adc_common_v2.o
|
OBJS += adc_common_v2.o
|
||||||
OBJS += crs_common_all.o
|
OBJS += crs_common_all.o
|
||||||
OBJS += flash_common_all.o flash_common_f01.o
|
OBJS += flash_common_all.o flash_common_f.o flash_common_f01.o
|
||||||
OBJS += usart_common_all.o usart_common_v2.o
|
OBJS += usart_common_all.o usart_common_v2.o
|
||||||
OBJS += i2c_common_v2.o
|
OBJS += i2c_common_v2.o
|
||||||
OBJS += spi_common_all.o spi_common_v2.o
|
OBJS += spi_common_all.o spi_common_v2.o
|
||||||
|
@ -46,7 +46,7 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_l1f013.o \
|
|||||||
timer_common_all.o usart_common_all.o usart_common_f124.o \
|
timer_common_all.o usart_common_all.o usart_common_f124.o \
|
||||||
rcc_common_all.o exti_common_all.o
|
rcc_common_all.o exti_common_all.o
|
||||||
|
|
||||||
OBJS += flash_common_all.o flash_common_f01.o
|
OBJS += flash_common_all.o flash_common_f.o flash_common_f01.o
|
||||||
OBJS += spi_common_all.o spi_common_v1.o
|
OBJS += spi_common_all.o spi_common_v1.o
|
||||||
|
|
||||||
OBJS += usb.o usb_control.o usb_standard.o usb_msc.o
|
OBJS += usb.o usb_control.o usb_standard.o usb_msc.o
|
||||||
|
@ -45,7 +45,7 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
|
|||||||
timer_common_f24.o usart_common_all.o usart_common_f124.o \
|
timer_common_f24.o usart_common_all.o usart_common_f124.o \
|
||||||
hash_common_f24.o \
|
hash_common_f24.o \
|
||||||
crypto_common_f24.o exti_common_all.o rcc_common_all.o
|
crypto_common_f24.o exti_common_all.o rcc_common_all.o
|
||||||
OBJS += flash_common_all.o flash_common_f234.o flash_common_f24.o
|
OBJS += flash_common_all.o flash_common_f.o flash_common_f234.o flash_common_f24.o
|
||||||
OBJS += rng_common_v1.o
|
OBJS += rng_common_v1.o
|
||||||
OBJS += spi_common_all.o spi_common_v1.o spi_common_v1_frf.o
|
OBJS += spi_common_all.o spi_common_v1.o spi_common_v1_frf.o
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ OBJS += gpio_common_all.o gpio_common_f0234.o \
|
|||||||
timer_common_all.o timer_common_f0234.o \
|
timer_common_all.o timer_common_f0234.o \
|
||||||
exti_common_all.o rcc_common_all.o
|
exti_common_all.o rcc_common_all.o
|
||||||
OBJS += adc_common_v2.o adc_common_v2_multi.o
|
OBJS += adc_common_v2.o adc_common_v2_multi.o
|
||||||
OBJS += flash_common_all.o flash_common_f234.o
|
OBJS += flash_common_all.o flash_common_f.o flash_common_f234.o
|
||||||
OBJS += usart_common_v2.o usart_common_all.o
|
OBJS += usart_common_v2.o usart_common_all.o
|
||||||
OBJS += i2c_common_v2.o
|
OBJS += i2c_common_v2.o
|
||||||
OBJS += spi_common_all.o spi_common_v2.o
|
OBJS += spi_common_all.o spi_common_v2.o
|
||||||
|
@ -50,7 +50,7 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
|
|||||||
usart_common_f124.o \
|
usart_common_f124.o \
|
||||||
hash_common_f24.o crypto_common_f24.o exti_common_all.o \
|
hash_common_f24.o crypto_common_f24.o exti_common_all.o \
|
||||||
rcc_common_all.o
|
rcc_common_all.o
|
||||||
OBJS += flash_common_all.o flash_common_f234.o flash_common_f24.o
|
OBJS += flash_common_all.o flash_common_f.o flash_common_f234.o flash_common_f24.o
|
||||||
OBJS += rng_common_v1.o
|
OBJS += rng_common_v1.o
|
||||||
OBJS += spi_common_all.o spi_common_v1.o spi_common_v1_frf.o
|
OBJS += spi_common_all.o spi_common_v1.o spi_common_v1_frf.o
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ TGT_CFLAGS += $(STANDARD_FLAGS)
|
|||||||
|
|
||||||
ARFLAGS = rcs
|
ARFLAGS = rcs
|
||||||
|
|
||||||
OBJS = flash_common_all.o flash.o pwr.o rcc.o
|
OBJS = flash_common_all.o flash_common_f.o flash.o pwr.o rcc.o
|
||||||
OBJS += gpio.o gpio_common_all.o gpio_common_f0234.o
|
OBJS += gpio.o gpio_common_all.o gpio_common_f0234.o
|
||||||
|
|
||||||
OBJS += rcc_common_all.o
|
OBJS += rcc_common_all.o
|
||||||
|
@ -84,34 +84,6 @@ void flash_set_ws(uint32_t ws)
|
|||||||
while ((FLASH_ACR & FLASH_ACR_LATENCY_MASK) != ws);
|
while ((FLASH_ACR & FLASH_ACR_LATENCY_MASK) != ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** @brief Unlock the Flash Program and Erase Controller
|
|
||||||
|
|
||||||
This enables write access to the Flash memory. It is locked by default on
|
|
||||||
reset.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void flash_unlock(void)
|
|
||||||
{
|
|
||||||
/* Clear the unlock sequence state. */
|
|
||||||
FLASH_CR |= FLASH_CR_LOCK;
|
|
||||||
|
|
||||||
/* Authorize the FPEC access. */
|
|
||||||
FLASH_KEYR = FLASH_KEYR_KEY1;
|
|
||||||
FLASH_KEYR = FLASH_KEYR_KEY2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** @brief Lock the Flash Program and Erase Controller
|
|
||||||
|
|
||||||
Used to prevent spurious writes to FLASH.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void flash_lock(void)
|
|
||||||
{
|
|
||||||
FLASH_CR |= FLASH_CR_LOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @brief Clear the Programming Error Status Flag
|
/** @brief Clear the Programming Error Status Flag
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ OBJS += exti_common_all.o
|
|||||||
OBJS += adc_common_v2.o adc_common_v2_multi.o
|
OBJS += adc_common_v2.o adc_common_v2_multi.o
|
||||||
OBJS += crc_common_all.o crc_v2.o
|
OBJS += crc_common_all.o crc_v2.o
|
||||||
OBJS += crs_common_all.o
|
OBJS += crs_common_all.o
|
||||||
OBJS += flash_common_all.o
|
OBJS += flash_common_all.o flash_common_f.o
|
||||||
OBJS += rng_common_v1.o
|
OBJS += rng_common_v1.o
|
||||||
OBJS += timer_common_all.o
|
OBJS += timer_common_all.o
|
||||||
OBJS += i2c_common_v2.o
|
OBJS += i2c_common_v2.o
|
||||||
|
@ -61,28 +61,6 @@ void flash_set_ws(uint32_t ws)
|
|||||||
FLASH_ACR = reg32;
|
FLASH_ACR = reg32;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Unlock the Flash Program and Erase Controller
|
|
||||||
* This enables write access to the Flash memory. It is locked by default on
|
|
||||||
* reset.
|
|
||||||
*/
|
|
||||||
void flash_unlock(void)
|
|
||||||
{
|
|
||||||
/* Clear the unlock sequence state. */
|
|
||||||
FLASH_CR |= FLASH_CR_LOCK;
|
|
||||||
|
|
||||||
/* Authorize the FPEC access. */
|
|
||||||
FLASH_KEYR = FLASH_KEYR_KEY1;
|
|
||||||
FLASH_KEYR = FLASH_KEYR_KEY2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Lock the Flash Program and Erase Controller
|
|
||||||
* Used to prevent spurious writes to FLASH.
|
|
||||||
*/
|
|
||||||
void flash_lock(void)
|
|
||||||
{
|
|
||||||
FLASH_CR |= FLASH_CR_LOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Clear the Programming Error Status Flag
|
/** @brief Clear the Programming Error Status Flag
|
||||||
*/
|
*/
|
||||||
void flash_clear_pgperr_flag(void)
|
void flash_clear_pgperr_flag(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user