diff --git a/include/libopencm3/stm32/common/gpio_common_f234.h b/include/libopencm3/stm32/common/gpio_common_f234.h index 4e9ec1ec..5d52635e 100644 --- a/include/libopencm3/stm32/common/gpio_common_f234.h +++ b/include/libopencm3/stm32/common/gpio_common_f234.h @@ -52,13 +52,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE GPIO_PORT_E_BASE #define GPIOF GPIO_PORT_F_BASE -#if !defined (STM32F3) - -#define GPIOG GPIO_PORT_G_BASE -#define GPIOH GPIO_PORT_H_BASE -#define GPIOI GPIO_PORT_I_BASE - -#endif /**@}*/ /* --- GPIO registers for STM32F2, STM32F3 and STM32F4 --------------------------- */ @@ -72,14 +65,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_MODER GPIO_MODER(GPIOE) #define GPIOF_MODER GPIO_MODER(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_MODER GPIO_MODER(GPIOG) -#define GPIOH_MODER GPIO_MODER(GPIOH) -#define GPIOI_MODER GPIO_MODER(GPIOI) - -#endif - /* Port output type register (GPIOx_OTYPER) */ #define GPIO_OTYPER(port) MMIO32(port + 0x04) #define GPIOA_OTYPER GPIO_OTYPER(GPIOA) @@ -89,14 +74,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_OTYPER GPIO_OTYPER(GPIOE) #define GPIOF_OTYPER GPIO_OTYPER(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_OTYPER GPIO_OTYPER(GPIOG) -#define GPIOH_OTYPER GPIO_OTYPER(GPIOH) -#define GPIOI_OTYPER GPIO_OTYPER(GPIOI) - -#endif - /* Port output speed register (GPIOx_OSPEEDR) */ #define GPIO_OSPEEDR(port) MMIO32(port + 0x08) #define GPIOA_OSPEEDR GPIO_OSPEEDR(GPIOA) @@ -106,14 +83,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_OSPEEDR GPIO_OSPEEDR(GPIOE) #define GPIOF_OSPEEDR GPIO_OSPEEDR(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_OSPEEDR GPIO_OSPEEDR(GPIOG) -#define GPIOH_OSPEEDR GPIO_OSPEEDR(GPIOH) -#define GPIOI_OSPEEDR GPIO_OSPEEDR(GPIOI) - -#endif - /* Port pull-up/pull-down register (GPIOx_PUPDR) */ #define GPIO_PUPDR(port) MMIO32(port + 0x0c) #define GPIOA_PUPDR GPIO_PUPDR(GPIOA) @@ -123,14 +92,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_PUPDR GPIO_PUPDR(GPIOE) #define GPIOF_PUPDR GPIO_PUPDR(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_PUPDR GPIO_PUPDR(GPIOG) -#define GPIOH_PUPDR GPIO_PUPDR(GPIOH) -#define GPIOI_PUPDR GPIO_PUPDR(GPIOI) - -#endif - /* Port input data register (GPIOx_IDR) */ #define GPIO_IDR(port) MMIO32(port + 0x10) #define GPIOA_IDR GPIO_IDR(GPIOA) @@ -140,14 +101,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_IDR GPIO_IDR(GPIOE) #define GPIOF_IDR GPIO_IDR(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_IDR GPIO_IDR(GPIOG) -#define GPIOH_IDR GPIO_IDR(GPIOH) -#define GPIOI_IDR GPIO_IDR(GPIOI) - -#endif - /* Port output data register (GPIOx_ODR) */ #define GPIO_ODR(port) MMIO32(port + 0x14) #define GPIOA_ODR GPIO_ODR(GPIOA) @@ -157,14 +110,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_ODR GPIO_ODR(GPIOE) #define GPIOF_ODR GPIO_ODR(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_ODR GPIO_ODR(GPIOG) -#define GPIOH_ODR GPIO_ODR(GPIOH) -#define GPIOI_ODR GPIO_ODR(GPIOI) - -#endif - /* Port bit set/reset register (GPIOx_BSRR) */ #define GPIO_BSRR(port) MMIO32(port + 0x18) #define GPIOA_BSRR GPIO_BSRR(GPIOA) @@ -174,14 +119,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_BSRR GPIO_BSRR(GPIOE) #define GPIOF_BSRR GPIO_BSRR(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_BSRR GPIO_BSRR(GPIOG) -#define GPIOH_BSRR GPIO_BSRR(GPIOH) -#define GPIOI_BSRR GPIO_BSRR(GPIOI) - -#endif - /* Port configuration lock register (GPIOx_LCKR) */ #define GPIO_LCKR(port) MMIO32(port + 0x1c) #define GPIOA_LCKR GPIO_LCKR(GPIOA) @@ -191,14 +128,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_LCKR GPIO_LCKR(GPIOE) #define GPIOF_LCKR GPIO_LCKR(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_LCKR GPIO_LCKR(GPIOG) -#define GPIOH_LCKR GPIO_LCKR(GPIOH) -#define GPIOI_LCKR GPIO_LCKR(GPIOI) - -#endif - /* Alternate function low register (GPIOx_AFRL) */ #define GPIO_AFRL(port) MMIO32(port + 0x20) #define GPIOA_AFRL GPIO_AFRL(GPIOA) @@ -208,14 +137,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_AFRL GPIO_AFRL(GPIOE) #define GPIOF_AFRL GPIO_AFRL(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_AFRL GPIO_AFRL(GPIOG) -#define GPIOH_AFRL GPIO_AFRL(GPIOH) -#define GPIOI_AFRL GPIO_AFRL(GPIOI) - -#endif - /* Alternate function high register (GPIOx_AFRH) */ #define GPIO_AFRH(port) MMIO32(port + 0x24) #define GPIOA_AFRH GPIO_AFRH(GPIOA) @@ -225,14 +146,6 @@ specific memorymap.h header before including this header file.*/ #define GPIOE_AFRH GPIO_AFRH(GPIOE) #define GPIOF_AFRH GPIO_AFRH(GPIOF) -#if !defined (STM32F3) - -#define GPIOG_AFRH GPIO_AFRH(GPIOG) -#define GPIOH_AFRH GPIO_AFRH(GPIOH) -#define GPIOI_AFRH GPIO_AFRH(GPIOI) - -#endif - /* --- GPIOx_MODER values -------------------------------------------------- */ #define GPIO_MODE(n, mode) (mode << (2 * (n))) diff --git a/include/libopencm3/stm32/common/gpio_common_f24.h b/include/libopencm3/stm32/common/gpio_common_f24.h new file mode 100644 index 00000000..d9f7ecf7 --- /dev/null +++ b/include/libopencm3/stm32/common/gpio_common_f24.h @@ -0,0 +1,111 @@ +/** @addtogroup gpio_defines + +@author @htmlonly © @endhtmlonly 2011 +Fergus Noble +@author @htmlonly © @endhtmlonly 2012 +Ken Sarkies + +*/ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2011 Fergus Noble + * Copyright (C) 2012 Ken Sarkies + * + * 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 . + */ + +/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA GPIO.H +The order of header inclusion is important. gpio.h includes the device +specific memorymap.h header before including this header file.*/ + +/** @cond */ +#ifdef LIBOPENCM3_GPIO_H +/** @endcond */ +#ifndef LIBOPENCM3_GPIO_COMMON_F24_H +#define LIBOPENCM3_GPIO_COMMON_F24_H + +/**@{*/ + +#include +#include + +/* GPIO port base addresses (for convenience) */ +/** @defgroup gpio_port_id GPIO Port IDs +@ingroup gpio_defines + +@{*/ +#define GPIOG GPIO_PORT_G_BASE +#define GPIOH GPIO_PORT_H_BASE +#define GPIOI GPIO_PORT_I_BASE +/**@}*/ + +/* --- GPIO registers for STM32F2, STM32F3 and STM32F4 --------------------------- */ + +/* Port mode register (GPIOx_MODER) */ +#define GPIOG_MODER GPIO_MODER(GPIOG) +#define GPIOH_MODER GPIO_MODER(GPIOH) +#define GPIOI_MODER GPIO_MODER(GPIOI) + +/* Port output type register (GPIOx_OTYPER) */ +#define GPIOG_OTYPER GPIO_OTYPER(GPIOG) +#define GPIOH_OTYPER GPIO_OTYPER(GPIOH) +#define GPIOI_OTYPER GPIO_OTYPER(GPIOI) + +/* Port output speed register (GPIOx_OSPEEDR) */ +#define GPIOG_OSPEEDR GPIO_OSPEEDR(GPIOG) +#define GPIOH_OSPEEDR GPIO_OSPEEDR(GPIOH) +#define GPIOI_OSPEEDR GPIO_OSPEEDR(GPIOI) + +/* Port pull-up/pull-down register (GPIOx_PUPDR) */ +#define GPIOG_PUPDR GPIO_PUPDR(GPIOG) +#define GPIOH_PUPDR GPIO_PUPDR(GPIOH) +#define GPIOI_PUPDR GPIO_PUPDR(GPIOI) + +/* Port input data register (GPIOx_IDR) */ +#define GPIOG_IDR GPIO_IDR(GPIOG) +#define GPIOH_IDR GPIO_IDR(GPIOH) +#define GPIOI_IDR GPIO_IDR(GPIOI) + +/* Port output data register (GPIOx_ODR) */ +#define GPIOG_ODR GPIO_ODR(GPIOG) +#define GPIOH_ODR GPIO_ODR(GPIOH) +#define GPIOI_ODR GPIO_ODR(GPIOI) + +/* Port bit set/reset register (GPIOx_BSRR) */ +#define GPIOG_BSRR GPIO_BSRR(GPIOG) +#define GPIOH_BSRR GPIO_BSRR(GPIOH) +#define GPIOI_BSRR GPIO_BSRR(GPIOI) + +/* Port configuration lock register (GPIOx_LCKR) */ +#define GPIOG_LCKR GPIO_LCKR(GPIOG) +#define GPIOH_LCKR GPIO_LCKR(GPIOH) +#define GPIOI_LCKR GPIO_LCKR(GPIOI) + +/* Alternate function low register (GPIOx_AFRL) */ +#define GPIOG_AFRL GPIO_AFRL(GPIOG) +#define GPIOH_AFRL GPIO_AFRL(GPIOH) +#define GPIOI_AFRL GPIO_AFRL(GPIOI) + +/* Alternate function high register (GPIOx_AFRH) */ +#define GPIOG_AFRH GPIO_AFRH(GPIOG) +#define GPIOH_AFRH GPIO_AFRH(GPIOH) +#define GPIOI_AFRH GPIO_AFRH(GPIOI) + +#endif +/** @cond */ +#else +#warning "gpio_common_f24.h should not be included explicitly, only via gpio.h" +#endif +/** @endcond */ \ No newline at end of file diff --git a/include/libopencm3/stm32/f2/gpio.h b/include/libopencm3/stm32/f2/gpio.h index a7a1ea11..f9f000a3 100644 --- a/include/libopencm3/stm32/f2/gpio.h +++ b/include/libopencm3/stm32/f2/gpio.h @@ -32,7 +32,7 @@ LGPL License Terms @ref lgpl_license #define LIBOPENCM3_GPIO_H #include -#include +#include #endif diff --git a/include/libopencm3/stm32/f4/gpio.h b/include/libopencm3/stm32/f4/gpio.h index 8962c424..dae8b923 100644 --- a/include/libopencm3/stm32/f4/gpio.h +++ b/include/libopencm3/stm32/f4/gpio.h @@ -32,7 +32,7 @@ LGPL License Terms @ref lgpl_license #define LIBOPENCM3_GPIO_H #include -#include +#include #endif