From 03d04ad10a906539cc3d058a3000b2fb1504410b Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Thu, 29 Nov 2012 19:37:45 -0600 Subject: 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 --- lib/lm4f/Makefile | 2 +- lib/lm4f/systemcontrol.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 lib/lm4f/systemcontrol.c (limited to 'lib/lm4f') 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 + * + * 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 . + */ + +#include + + +/** + * \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 -- cgit v1.2.3