From 8fa7727b09c3ce5ef2ef93d1e3f8ba4959555783 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Thu, 17 Jul 2014 09:52:06 +0000 Subject: [PATCH] stm32f3: drop redundant gpio.c All methods in this file are in either * common/gpio_common_all.c * common/gpio_common_f0234.c Those other files have better doxygen commentary, this file should never have been added. --- lib/stm32/f3/Makefile | 2 +- lib/stm32/f3/gpio.c | 166 ------------------------------------------ 2 files changed, 1 insertion(+), 167 deletions(-) delete mode 100644 lib/stm32/f3/gpio.c diff --git a/lib/stm32/f3/Makefile b/lib/stm32/f3/Makefile index 1d5d8e66..5ef282ad 100644 --- a/lib/stm32/f3/Makefile +++ b/lib/stm32/f3/Makefile @@ -35,7 +35,7 @@ CFLAGS = -Os -g \ ARFLAGS = rcs -OBJS = rcc.o gpio.o adc.o i2c.o usart.o dma.o flash.o +OBJS = rcc.o adc.o i2c.o usart.o dma.o flash.o OBJS += gpio_common_all.o gpio_common_f0234.o \ dac_common_all.o usart_common_all.o crc_common_all.o\ diff --git a/lib/stm32/f3/gpio.c b/lib/stm32/f3/gpio.c deleted file mode 100644 index 7ec4f1d5..00000000 --- a/lib/stm32/f3/gpio.c +++ /dev/null @@ -1,166 +0,0 @@ -/** @defgroup gpio_file GPIO - * - * @ingroup STM32F3xx - * - * @brief libopencm3 STM32F3xx General Purpose I/O - * - * @version 1.0.0 - * - * @date 11 July 2013 - * - * LGPL License Terms @ref lgpl_license - */ -/* - * This file is part of the libopencm3 project. - * - * Copyright (C) 2011 Fergus Noble - * Modified by 2013 Fernando Cortes (stm32f3) - * Modified by 2013 Guillermo Rivera (stm32f3) - * - * 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 - -void gpio_mode_setup(uint32_t gpioport, uint8_t mode, uint8_t pull_up_down, - uint16_t gpios) -{ - uint16_t i; - uint32_t moder, pupd; - - /* - * We want to set the config only for the pins mentioned in gpios, - * but keeping the others, so read out the actual config first. - */ - moder = GPIO_MODER(gpioport); - pupd = GPIO_PUPDR(gpioport); - - for (i = 0; i < 16; i++) { - if (!((1 << i) & gpios)) { - continue; - } - - moder &= ~GPIO_MODE_MASK(i); - moder |= GPIO_MODE(i, mode); - pupd &= ~GPIO_PUPD_MASK(i); - pupd |= GPIO_PUPD(i, pull_up_down); - } - - /* Set mode and pull up/down control registers. */ - GPIO_MODER(gpioport) = moder; - GPIO_PUPDR(gpioport) = pupd; -} - -void gpio_set_output_options(uint32_t gpioport, uint8_t otype, uint8_t speed, - uint16_t gpios) -{ - uint16_t i; - uint32_t ospeedr; - - if (otype == 0x1) { - GPIO_OTYPER(gpioport) |= gpios; - } else { - GPIO_OTYPER(gpioport) &= ~gpios; - } - - ospeedr = GPIO_OSPEEDR(gpioport); - - for (i = 0; i < 16; i++) { - if (!((1 << i) & gpios)) { - continue; - } - ospeedr &= ~GPIO_OSPEED_MASK(i); - ospeedr |= GPIO_OSPEED(i, speed); - } - - GPIO_OSPEEDR(gpioport) = ospeedr; -} - -void gpio_set_af(uint32_t gpioport, uint8_t alt_func_num, uint16_t gpios) -{ - uint16_t i; - uint32_t afrl, afrh; - - afrl = GPIO_AFRL(gpioport); - afrh = GPIO_AFRH(gpioport); - - for (i = 0; i < 8; i++) { - if (!((1 << i) & gpios)) { - continue; - } - afrl &= ~GPIO_AFR_MASK(i); - afrl |= GPIO_AFR(i, alt_func_num); - } - - for (i = 8; i < 16; i++) { - if (!((1 << i) & gpios)) { - continue; - } - afrl &= ~GPIO_AFR_MASK(i - 8); - afrh |= GPIO_AFR(i - 8, alt_func_num); - } - - GPIO_AFRL(gpioport) = afrl; - GPIO_AFRH(gpioport) = afrh; -} - -void gpio_set(uint32_t gpioport, uint16_t gpios) -{ - GPIO_BSRR(gpioport) = gpios; -} - -void gpio_clear(uint32_t gpioport, uint16_t gpios) -{ - GPIO_BSRR(gpioport) = gpios << 16; -} - -uint16_t gpio_get(uint32_t gpioport, uint16_t gpios) -{ - return gpio_port_read(gpioport) & gpios; -} - -void gpio_toggle(uint32_t gpioport, uint16_t gpios) -{ - GPIO_ODR(gpioport) ^= gpios; -} - -uint16_t gpio_port_read(uint32_t gpioport) -{ - return (uint16_t)GPIO_IDR(gpioport); -} - -void gpio_port_write(uint32_t gpioport, uint16_t data) -{ - GPIO_ODR(gpioport) = data; -} - -void gpio_port_config_lock(uint32_t gpioport, uint16_t gpios) -{ - uint32_t reg32; - - /* Special "Lock Key Writing Sequence", see datasheet. */ - GPIO_LCKR(gpioport) = GPIO_LCKK | gpios; /* Set LCKK. */ - GPIO_LCKR(gpioport) = ~GPIO_LCKK & gpios; /* Clear LCKK. */ - GPIO_LCKR(gpioport) = GPIO_LCKK | gpios; /* Set LCKK. */ - reg32 = GPIO_LCKR(gpioport); /* Read LCKK. */ - reg32 = GPIO_LCKR(gpioport); /* Read LCKK again. */ - - /* - * Tell the compiler the variable is actually used. - * It will get optimized out anyways. - */ - reg32 = reg32; - - /* If (reg32 & GPIO_LCKK) is true, the lock is now active. */ -}