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:
48
include/libopencm3/stm32/common/flash_common_all.h
Normal file
48
include/libopencm3/stm32/common/flash_common_all.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/** @addtogroup flash_defines
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <libopencm3/cm3/common.h>
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
||||
void flash_set_ws(uint32_t ws);
|
||||
|
||||
END_DECLS
|
||||
@@ -62,6 +62,8 @@
|
||||
|
||||
#define FLASH_ACR_PRFTBS (1 << 5)
|
||||
#define FLASH_ACR_PRFTBE (1 << 4)
|
||||
/** Compatibility define */
|
||||
#define FLASH_ACR_PRFTEN FLASH_ACR_PRFTBE
|
||||
|
||||
/* --- FLASH_SR values ----------------------------------------------------- */
|
||||
|
||||
@@ -97,9 +99,6 @@
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void flash_set_ws(uint32_t ws);
|
||||
void flash_prefetch_enable(void);
|
||||
void flash_prefetch_disable(void);
|
||||
void flash_unlock(void);
|
||||
void flash_lock(void);
|
||||
void flash_clear_pgerr_flag(void);
|
||||
|
||||
@@ -74,7 +74,6 @@
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void flash_set_ws(uint32_t ws);
|
||||
void flash_unlock(void);
|
||||
void flash_lock(void);
|
||||
void flash_clear_pgperr_flag(void);
|
||||
|
||||
@@ -124,8 +124,6 @@ void flash_dcache_enable(void);
|
||||
void flash_dcache_disable(void);
|
||||
void flash_icache_enable(void);
|
||||
void flash_icache_disable(void);
|
||||
void flash_prefetch_enable(void);
|
||||
void flash_prefetch_disable(void);
|
||||
void flash_dcache_reset(void);
|
||||
void flash_icache_reset(void);
|
||||
void flash_erase_all_sectors(uint32_t program_size);
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#define LIBOPENCM3_FLASH_COMMON_L01_H
|
||||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
|
||||
/* --- FLASH registers ----------------------------------------------------- */
|
||||
|
||||
#define FLASH_ACR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00)
|
||||
@@ -110,9 +112,6 @@
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void flash_prefetch_enable(void);
|
||||
void flash_prefetch_disable(void);
|
||||
void flash_set_ws(uint32_t ws);
|
||||
void flash_unlock_pecr(void);
|
||||
void flash_lock_pecr(void);
|
||||
void flash_unlock_progmem(void);
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#define LIBOPENCM3_FLASH_H
|
||||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f01.h>
|
||||
|
||||
/* --- FLASH_OPTION values ------------------------------------------------- */
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f01.h>
|
||||
|
||||
/* --- FLASH_OPTION bytes ------------------------------------------------- */
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#ifndef LIBOPENCM3_FLASH_H
|
||||
#define LIBOPENCM3_FLASH_H
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f24.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#define LIBOPENCM3_FLASH_H
|
||||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f234.h>
|
||||
|
||||
/* --- FLASH registers ----------------------------------------------------- */
|
||||
@@ -44,6 +45,8 @@
|
||||
|
||||
#define FLASH_ACR_PRFTBS (1 << 5)
|
||||
#define FLASH_ACR_PRFTBE (1 << 4)
|
||||
/** Compatibility alias */
|
||||
#define FLASH_ACR_PRFTEN FLASH_ACR_PRFTBE
|
||||
#define FLASH_ACR_HLFCYA (1 << 3)
|
||||
|
||||
/* --- FLASH_SR values ----------------------------------------------------- */
|
||||
@@ -70,8 +73,6 @@
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void flash_prefetch_enable(void);
|
||||
void flash_prefetch_disable(void);
|
||||
|
||||
END_DECLS
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#ifndef LIBOPENCM3_FLASH_H
|
||||
#define LIBOPENCM3_FLASH_H
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f24.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
/*
|
||||
* For details see:
|
||||
* PM0081 Programming manual: STM32F40xxx and STM32F41xxx Flash programming
|
||||
@@ -151,7 +152,6 @@
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void flash_set_ws(uint32_t ws);
|
||||
void flash_unlock(void);
|
||||
void flash_lock(void);
|
||||
void flash_clear_pgperr_flag(void);
|
||||
@@ -165,8 +165,6 @@ void flash_clear_wrperr_flag(void);
|
||||
void flash_clear_pgaerr_flag(void);
|
||||
void flash_art_enable(void);
|
||||
void flash_art_disable(void);
|
||||
void flash_prefetch_enable(void);
|
||||
void flash_prefetch_disable(void);
|
||||
void flash_art_reset(void);
|
||||
void flash_clear_status_flags(void);
|
||||
void flash_erase_all_sectors(uint32_t program_size);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define LIBOPENCM3_FLASH_H
|
||||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_l01.h>
|
||||
|
||||
/* --- FLASH registers ----------------------------------------------------- */
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#define LIBOPENCM3_FLASH_H
|
||||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_l01.h>
|
||||
|
||||
/* --- FLASH registers ----------------------------------------------------- */
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#ifndef LIBOPENCM3_FLASH_H
|
||||
#define LIBOPENCM3_FLASH_H
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
|
||||
/* --- FLASH registers ----------------------------------------------------- */
|
||||
|
||||
#define FLASH_ACR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00)
|
||||
@@ -222,7 +224,6 @@
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void flash_set_ws(uint32_t ws);
|
||||
void flash_unlock(void);
|
||||
void flash_lock(void);
|
||||
void flash_clear_pgperr_flag(void);
|
||||
@@ -232,8 +233,6 @@ void flash_dcache_enable(void);
|
||||
void flash_dcache_disable(void);
|
||||
void flash_icache_enable(void);
|
||||
void flash_icache_disable(void);
|
||||
void flash_prefetch_enable(void);
|
||||
void flash_prefetch_disable(void);
|
||||
void flash_dcache_reset(void);
|
||||
void flash_icache_reset(void);
|
||||
void flash_clear_pgserr_flag(void);
|
||||
|
||||
Reference in New Issue
Block a user