aboutsummaryrefslogtreecommitdiff
path: root/lib/lm4f
diff options
context:
space:
mode:
authorAlexandru Gagniuc2012-11-29 19:37:45 -0600
committerAlexandru Gagniuc2013-01-09 00:37:50 -0600
commit03d04ad10a906539cc3d058a3000b2fb1504410b (patch)
tree7d6f6d29dd2013eb8dc00c4ffdc4ccd07d93a199 /lib/lm4f
parent61f2cb3f993c0f00504e46be48de8c535c9408b4 (diff)
lm4f: Add API for enabling/disabling peripherals clock source
The enum definitions are specified in the form 31:5 register offset from SYSCTL_BASE for the clock register 4:0 bit offset for the given peripheral The names have the form [clock_type]_[periph_type]_[periph_number] Where clock_type is RCC for run clock SCC for sleep clock DCC for deep-sleep clock Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Diffstat (limited to 'lib/lm4f')
-rw-r--r--lib/lm4f/Makefile2
-rw-r--r--lib/lm4f/systemcontrol.c41
2 files changed, 42 insertions, 1 deletions
diff --git a/lib/lm4f/Makefile b/lib/lm4f/Makefile
index 8f4c151..db4d5d4 100644
--- a/lib/lm4f/Makefile
+++ b/lib/lm4f/Makefile
@@ -28,7 +28,7 @@ CFLAGS = -Os -g -Wall -Wextra -I../../include -fno-common \
-ffunction-sections -fdata-sections -MD -DLM4F
# ARFLAGS = rcsv
ARFLAGS = rcs
-OBJS = gpio.o vector.o assert.o
+OBJS = gpio.o vector.o assert.o systemcontrol.o
VPATH += ../cm3
diff --git a/lib/lm4f/systemcontrol.c b/lib/lm4f/systemcontrol.c
new file mode 100644
index 0000000..915b628
--- /dev/null
+++ b/lib/lm4f/systemcontrol.c
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
+ *
+ * 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/lm4f/systemcontrol.h>
+
+
+/**
+ * \brief Enable the clock source for the peripheral
+ *
+ * @param[in] periph peripheral and clock type to enable @see clken_t
+ */
+void periph_clock_enable(clken_t periph)
+{
+ MMIO32(SYSCTL_BASE + (periph >> 5)) |= 1 << (periph & 0x1f);
+}
+
+/**
+ * \brief Disable the clock source for the peripheral
+ *
+ * @param[in] periph peripheral and clock type to enable @see clken_t
+ */
+void periph_clock_disable(clken_t periph)
+{
+ MMIO32(SYSCTL_BASE + (periph >> 5)) &= ~(1 << (periph & 0x1f));
+} \ No newline at end of file