From b5a8e0386d5134839bf23e82110d2f1926201202 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Fri, 27 Jan 2012 21:01:59 -0500 Subject: Clean up Flash interface; add flash_enable_features(). Make a single function, flash_enable_features(), to control the access characteristics of Flash memory (i.e. to write to the non-latency bits of ACR). In so doing, make everybody pretend to allow instruction and data caching. On STM32F1, trying to turn these on simply has no effect. This allows unconditionally trying to turn them on, which will simplify users' lives. This has the ancillary benefit of making the stm32f2- and stm32f1-specific flash.c files unnecessary; delete these. Signed-off-by: Marti Bolivar --- libmaple/stm32f2/flash.c | 39 --------------------------------- libmaple/stm32f2/include/series/flash.h | 7 ++++++ libmaple/stm32f2/rules.mk | 1 - 3 files changed, 7 insertions(+), 40 deletions(-) delete mode 100644 libmaple/stm32f2/flash.c (limited to 'libmaple/stm32f2') diff --git a/libmaple/stm32f2/flash.c b/libmaple/stm32f2/flash.c deleted file mode 100644 index d239940..0000000 --- a/libmaple/stm32f2/flash.c +++ /dev/null @@ -1,39 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f2/flash.c - * @brief Flash management functions - */ - -#include - -/** - * @brief Turn on the instruction prefetcher. - */ -void flash_enable_prefetch(void) { - FLASH_BASE->ACR |= FLASH_ACR_PRFTEN; -} diff --git a/libmaple/stm32f2/include/series/flash.h b/libmaple/stm32f2/include/series/flash.h index 73cbe14..f48eea3 100644 --- a/libmaple/stm32f2/include/series/flash.h +++ b/libmaple/stm32f2/include/series/flash.h @@ -189,6 +189,13 @@ typedef struct flash_reg_map { /* Note that this value depends on a 2.7V--3.6V supply voltage */ #define FLASH_SAFE_WAIT_STATES FLASH_WAIT_STATE_3 +/* Flash memory features available via ACR. */ +enum { + FLASH_PREFETCH = 0x100, + FLASH_ICACHE = 0x200, + FLASH_DCACHE = 0x400, +}; + #ifdef __cplusplus } #endif diff --git a/libmaple/stm32f2/rules.mk b/libmaple/stm32f2/rules.mk index 0743f4f..83ab043 100644 --- a/libmaple/stm32f2/rules.mk +++ b/libmaple/stm32f2/rules.mk @@ -11,7 +11,6 @@ CFLAGS_$(d) = -I$(d) $(LIBMAPLE_INCLUDES) $(LIBMAPLE_PRIVATE_INCLUDES) -Wall -We sSRCS_$(d) := isrs.S vector_table.S cSRCS_$(d) := rcc.c cSRCS_$(d) += gpio.c -cSRCS_$(d) += flash.c sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -- cgit v1.2.3