stm32: flash: pull up prefetch to _all

Turns out, there's lots of common code for flash.  Pull up prefetch
on/off to start with, as there's only a single bit name different.

Pull up the definitions of common API functions too, starting with
flash_set_ws.  Even if the implementations are different, things that
meant to be the same, should be defined centrally.
This commit is contained in:
Karl Palsson
2018-07-10 22:21:18 +00:00
parent 9dd901ba27
commit b23dccc7ae
30 changed files with 117 additions and 185 deletions

View File

@@ -0,0 +1,37 @@
/** @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_prefetch_enable(void)
{
FLASH_ACR |= FLASH_ACR_PRFTEN;
}
void flash_prefetch_disable(void)
{
FLASH_ACR &= ~FLASH_ACR_PRFTEN;
}
/*@}*/

View File

@@ -25,34 +25,6 @@
#include <libopencm3/stm32/flash.h>
/*---------------------------------------------------------------------------*/
/** @brief Enable the FLASH Prefetch Buffer
This buffer is used for instruction fetches and is enabled by default after
reset.
Note carefully the clock restrictions under which the prefetch buffer may be
enabled or disabled. Changes are normally made while the clock is running in
the power-on low frequency mode before being set to a higher speed mode.
See the reference manual for details.
*/
void flash_prefetch_enable(void)
{
FLASH_ACR |= FLASH_ACR_PRFTBE;
}
/*---------------------------------------------------------------------------*/
/** @brief Disable the FLASH Prefetch Buffer
Note carefully the clock restrictions under which the prefetch buffer may be
set to disabled. See the reference manual for details.
*/
void flash_prefetch_disable(void)
{
FLASH_ACR &= ~FLASH_ACR_PRFTBE;
}
/*---------------------------------------------------------------------------*/
/** @brief Set the Number of Wait States

View File

@@ -81,34 +81,6 @@ void flash_icache_disable(void)
FLASH_ACR &= ~FLASH_ACR_ICEN;
}
/*---------------------------------------------------------------------------*/
/** @brief Enable the FLASH Prefetch Buffer
This buffer is used for instruction fetches and is enabled by default after
reset.
Note carefully the clock restrictions under which the prefetch buffer may be
enabled or disabled. Changes are normally made while the clock is running in
the power-on low frequency mode before being set to a higher speed mode.
See the reference manual for details.
*/
void flash_prefetch_enable(void)
{
FLASH_ACR |= FLASH_ACR_PRFTEN;
}
/*---------------------------------------------------------------------------*/
/** @brief Disable the FLASH Prefetch Buffer
Note carefully the clock restrictions under which the prefetch buffer may be
set to disabled. See the reference manual for details.
*/
void flash_prefetch_disable(void)
{
FLASH_ACR &= ~FLASH_ACR_PRFTEN;
}
/*---------------------------------------------------------------------------*/
/** @brief Reset the Data Cache

View File

@@ -29,34 +29,6 @@
#include <libopencm3/stm32/flash.h>
/*---------------------------------------------------------------------------*/
/** @brief Enable the FLASH Prefetch Buffer
This buffer is used for instruction fetches and is enabled by default after
reset.
Note carefully the restrictions under which the prefetch buffer may be
enabled or disabled. Prefetch is only available when 64-bit
access is enabled.
*/
void flash_prefetch_enable(void)
{
FLASH_ACR |= FLASH_ACR_PRFTEN;
}
/*---------------------------------------------------------------------------*/
/** @brief Disable the FLASH Prefetch Buffer
Note carefully the restrictions under which the prefetch buffer may be
set to disabled. See the reference and programming manuals for details.
*/
void flash_prefetch_disable(void)
{
FLASH_ACR &= ~FLASH_ACR_PRFTEN;
}
/*---------------------------------------------------------------------------*/
/** @brief Set the Number of Wait States

View File

@@ -42,11 +42,12 @@ OBJS = can.o flash.o rcc.o dma.o rtc.o comparator.o \
OBJS += gpio_common_all.o gpio_common_f0234.o crc_common_all.o crc_v2.o \
pwr_common_v1.o iwdg_common_all.o rtc_common_l1f024.o \
dma_common_l1f013.o exti_common_all.o \
flash_common_f01.o dac_common_all.o \
dac_common_all.o \
timer_common_all.o timer_common_f0234.o rcc_common_all.o
OBJS += adc_common_v2.o
OBJS += crs_common_all.o
OBJS += flash_common_all.o flash_common_f01.o
OBJS += usart_common_all.o usart_common_v2.o
OBJS += i2c_common_v2.o
OBJS += spi_common_all.o spi_common_v2.o

View File

@@ -44,8 +44,9 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_l1f013.o \
gpio_common_all.o i2c_common_v1.o iwdg_common_all.o \
pwr_common_v1.o \
timer_common_all.o usart_common_all.o usart_common_f124.o \
rcc_common_all.o exti_common_all.o \
flash_common_f01.o
rcc_common_all.o exti_common_all.o
OBJS += flash_common_all.o flash_common_f01.o
OBJS += spi_common_all.o spi_common_v1.o
OBJS += usb.o usb_control.o usb_standard.o usb_msc.o

View File

@@ -43,8 +43,9 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
iwdg_common_all.o rtc_common_l1f024.o \
timer_common_all.o timer_common_f0234.o \
timer_common_f24.o usart_common_all.o usart_common_f124.o \
flash_common_f234.o flash_common_f24.o hash_common_f24.o \
hash_common_f24.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 += rng_common_v1.o
OBJS += spi_common_all.o spi_common_v1.o spi_common_v1_frf.o

View File

@@ -42,9 +42,10 @@ OBJS = rcc.o adc.o can.o pwr.o dma.o flash.o desig.o
OBJS += gpio_common_all.o gpio_common_f0234.o \
dac_common_all.o crc_common_all.o crc_v2.o \
iwdg_common_all.o pwr_common_v1.o dma_common_l1f013.o\
timer_common_all.o timer_common_f0234.o flash_common_f234.o \
flash.o exti_common_all.o rcc_common_all.o
timer_common_all.o timer_common_f0234.o \
exti_common_all.o rcc_common_all.o
OBJS += adc_common_v2.o adc_common_v2_multi.o
OBJS += flash_common_all.o flash_common_f234.o
OBJS += usart_common_v2.o usart_common_all.o
OBJS += i2c_common_v2.o
OBJS += spi_common_all.o spi_common_v2.o

View File

@@ -58,25 +58,5 @@ void flash_clear_status_flags(void)
flash_clear_eop_flag();
}
/**
* Enable the FLASH Prefetch Buffer
* This buffer is used for instruction fetches and is enabled by default after
* reset.
*/
void flash_prefetch_enable(void)
{
FLASH_ACR |= FLASH_ACR_PRFTBE;
}
/**
* Disable the FLASH Prefetch Buffer
* This buffer is used for instruction fetches and is enabled by default after
* reset.
*/
void flash_prefetch_disable(void)
{
FLASH_ACR &= ~FLASH_ACR_PRFTBE;
}
/**@}*/

View File

@@ -47,9 +47,10 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
iwdg_common_all.o pwr_common_v1.o rtc_common_l1f024.o \
timer_common_all.o \
timer_common_f0234.o timer_common_f24.o usart_common_all.o \
usart_common_f124.o flash_common_f234.o flash_common_f24.o \
usart_common_f124.o \
hash_common_f24.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 += rng_common_v1.o
OBJS += spi_common_all.o spi_common_v1.o spi_common_v1_frf.o

View File

@@ -42,7 +42,7 @@ TGT_CFLAGS += $(STANDARD_FLAGS)
ARFLAGS = rcs
OBJS = flash.o pwr.o rcc.o
OBJS = flash_common_all.o flash.o pwr.o rcc.o
OBJS += gpio.o gpio_common_all.o gpio_common_f0234.o
OBJS += rcc_common_all.o

View File

@@ -217,35 +217,6 @@ void flash_art_enable(void)
FLASH_ACR |= FLASH_ACR_ARTEN;
}
/*---------------------------------------------------------------------------*/
/** @brief Enable the FLASH Prefetch Buffer
This buffer is used for instruction fetches and is enabled by default after
reset.
Note carefully the clock restrictions under which the prefetch buffer may be
enabled or disabled. Changes are normally made while the clock is running in
the power-on low frequency mode before being set to a higher speed mode.
See the reference manual for details.
*/
void flash_prefetch_enable(void)
{
FLASH_ACR |= FLASH_ACR_PRFTEN;
}
/*---------------------------------------------------------------------------*/
/** @brief Disable the FLASH Prefetch Buffer
Note carefully the clock restrictions under which the prefetch buffer may be
set to disabled. See the reference manual for details.
*/
void flash_prefetch_disable(void)
{
FLASH_ACR &= ~FLASH_ACR_PRFTEN;
}
/*---------------------------------------------------------------------------*/
/** @brief Reset the ART Cache

View File

@@ -46,7 +46,7 @@ OBJS += adc_common_v2.o
OBJS += crs_common_all.o
OBJS += dma_common_l1f013.o
OBJS += exti_common_all.o
OBJS += flash.o flash_common_l01.o
OBJS += flash.o flash_common_all.o flash_common_l01.o
OBJS += i2c_common_v2.o
OBJS += rng_common_v1.o
OBJS += usart_common_all.o usart_common_v2.o

View File

@@ -38,7 +38,7 @@ ARFLAGS = rcs
OBJS = desig.o flash.o rcc.o dma.o lcd.o
OBJS += crc_common_all.o dac_common_all.o
OBJS += dma_common_l1f013.o
OBJS += flash_common_l01.o
OBJS += flash_common_all.o flash_common_l01.o
OBJS += gpio_common_all.o gpio_common_f0234.o
OBJS += i2c_common_v1.o iwdg_common_all.o
OBJS += pwr_common_v1.o pwr_common_v2.o rtc_common_l1f024.o

View File

@@ -47,6 +47,7 @@ OBJS += exti_common_all.o
OBJS += adc_common_v2.o adc_common_v2_multi.o
OBJS += crc_common_all.o crc_v2.o
OBJS += crs_common_all.o
OBJS += flash_common_all.o
OBJS += rng_common_v1.o
OBJS += timer_common_all.o
OBJS += i2c_common_v2.o

View File

@@ -42,31 +42,6 @@
#include <libopencm3/stm32/flash.h>
/** @brief Enable the FLASH Prefetch Buffer
This buffer is used for instruction fetches and is enabled by default after
reset.
Note carefully the clock restrictions under which the prefetch buffer may be
enabled or disabled. Changes are normally made while the clock is running in
the power-on low frequency mode before being set to a higher speed mode.
See the reference manual for details.
*/
void flash_prefetch_enable(void)
{
FLASH_ACR |= FLASH_ACR_PRFTEN;
}
/** @brief Disable the FLASH Prefetch Buffer
Note carefully the clock restrictions under which the prefetch buffer may be
set to disabled. See the reference manual for details.
*/
void flash_prefetch_disable(void)
{
FLASH_ACR &= ~FLASH_ACR_PRFTEN;
}
/** @brief Set the Number of Wait States
Used to match the system clock to the FLASH memory access time. See the