aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/include
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple/include')
-rw-r--r--libmaple/include/libmaple/flash.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/libmaple/include/libmaple/flash.h b/libmaple/include/libmaple/flash.h
index 97bfa26..bacbbda 100644
--- a/libmaple/include/libmaple/flash.h
+++ b/libmaple/include/libmaple/flash.h
@@ -47,18 +47,40 @@ extern "C"{
#define FLASH_WAIT_STATE_6 0x6
#define FLASH_WAIT_STATE_7 0x7
-/* The series header must define FLASH_SAFE_WAIT_STATES, the smallest
- * number of wait states that it is safe to use when the MCU clock is
- * at its fastest rate (not considering overclocking). */
+/* The series header must define:
+ *
+ * - FLASH_SAFE_WAIT_STATES, the smallest number of wait states that
+ * it is safe to use when SYSCLK is at its fastest documented rate
+ * and the MCU is powered at 3.3V (i.e. this doesn't consider
+ * overclocking or low voltage operation).
+ *
+ * - The following bit flags, for flash_enable_features():
+ *
+ * -- FLASH_PREFETCH: prefetcher
+ * -- FLASH_ICACHE: instruction cache
+ * -- FLASH_DCACHE: data cache
+ *
+ * If the target doesn't provide a feature (e.g. instruction and
+ * data caches on the STM32F1), the flag should be set to some no-op
+ * value. This allows using these flags unconditionally, with the
+ * desired effect taking place on series that support them.
+ */
#include <series/flash.h>
/*
- * Setup routines
+ * Flash routines
*/
-void flash_enable_prefetch(void);
void flash_set_latency(uint32 wait_states);
+static inline void flash_enable_features(uint32 feature_flags) {
+ FLASH_BASE->ACR |= feature_flags;
+}
+
+static inline void flash_enable_prefetch(void) {
+ flash_enable_features(FLASH_PREFETCH);
+}
+
#ifdef __cplusplus
}
#endif