aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorUwe Hermann2010-01-15 01:05:22 +0100
committerUwe Hermann2010-01-15 01:05:22 +0100
commit4fdb7f08fd8fe1a3b037d02f87b02ab3e1cc2b2a (patch)
treedb90c47252653b2eca1e1da03a0ff66d18ec18d2 /lib
parent1b73ccdd7a2691c01fbcdaddd4b7df8ca79f2e82 (diff)
Add initial flash memory register support.
Thanks Thomas Otto <tommi@viadmin.org> for the patch!
Diffstat (limited to 'lib')
-rw-r--r--lib/flash.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/flash.c b/lib/flash.c
new file mode 100644
index 0000000..1c13a9b
--- /dev/null
+++ b/lib/flash.c
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the libopenstm32 project.
+ *
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopenstm32.h>
+
+void flash_prefetch_buffer_enable(void)
+{
+ FLASH_ACR |= PRFTBE;
+}
+
+void flash_prefetch_buffer_disable(void)
+{
+ FLASH_ACR &= ~PRFTBE;
+}
+
+void flash_halfcycle_enable(void)
+{
+ FLASH_ACR |= HLFCYA;
+}
+
+void flash_halfcycle_disable(void)
+{
+ FLASH_ACR &= ~HLFCYA;
+}
+
+void flash_set_ws(u32 ws)
+{
+ u32 reg32;
+
+ reg32 = FLASH_ACR;
+ reg32 &= ~((1 << 0) | (1 << 1) | (1 << 2));
+ reg32 |= ws;
+ FLASH_ACR = reg32;
+}