From 74eb5ab84a20cb88abaf5bf3b00fc4b9e0177ef4 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Thu, 4 Jul 2013 18:10:42 -0700 Subject: [PATCH] [STM32F3] Split out F3 specific exti definitions. --- .../libopencm3/stm32/common/exti_common_all.h | 83 +++++++++++++++++ .../libopencm3/stm32/common/exti_common_f24.h | 40 +++++++++ include/libopencm3/stm32/exti.h | 89 ++++--------------- include/libopencm3/stm32/f1/exti.h | 26 ++++++ include/libopencm3/stm32/f2/exti.h | 26 ++++++ include/libopencm3/stm32/f3/exti.h | 34 +++++++ include/libopencm3/stm32/f4/exti.h | 26 ++++++ include/libopencm3/stm32/l1/exti.h | 26 ++++++ 8 files changed, 276 insertions(+), 74 deletions(-) create mode 100644 include/libopencm3/stm32/common/exti_common_all.h create mode 100644 include/libopencm3/stm32/common/exti_common_f24.h create mode 100644 include/libopencm3/stm32/f1/exti.h create mode 100644 include/libopencm3/stm32/f2/exti.h create mode 100644 include/libopencm3/stm32/f3/exti.h create mode 100644 include/libopencm3/stm32/f4/exti.h create mode 100644 include/libopencm3/stm32/l1/exti.h diff --git a/include/libopencm3/stm32/common/exti_common_all.h b/include/libopencm3/stm32/common/exti_common_all.h new file mode 100644 index 00000000..ff402790 --- /dev/null +++ b/include/libopencm3/stm32/common/exti_common_all.h @@ -0,0 +1,83 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2010 Mark Butler + * + * 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 . + */ + +/** @cond */ +#if defined(LIBOPENCM3_EXTI_H) +/** @endcond */ +#ifndef LIBOPENCM3_EXTI_COMMON_ALL_H +#define LIBOPENCM3_EXTI_COMMON_ALL_H + +#include +#include + +/* --- EXTI registers ------------------------------------------------------ */ + +#define EXTI_IMR MMIO32(EXTI_BASE + 0x00) +#define EXTI_EMR MMIO32(EXTI_BASE + 0x04) +#define EXTI_RTSR MMIO32(EXTI_BASE + 0x08) +#define EXTI_FTSR MMIO32(EXTI_BASE + 0x0c) +#define EXTI_SWIER MMIO32(EXTI_BASE + 0x10) +#define EXTI_PR MMIO32(EXTI_BASE + 0x14) + +/* EXTI number definitions */ +#define EXTI0 (1 << 0) +#define EXTI1 (1 << 1) +#define EXTI2 (1 << 2) +#define EXTI3 (1 << 3) +#define EXTI4 (1 << 4) +#define EXTI5 (1 << 5) +#define EXTI6 (1 << 6) +#define EXTI7 (1 << 7) +#define EXTI8 (1 << 8) +#define EXTI9 (1 << 9) +#define EXTI10 (1 << 10) +#define EXTI11 (1 << 11) +#define EXTI12 (1 << 12) +#define EXTI13 (1 << 13) +#define EXTI14 (1 << 14) +#define EXTI15 (1 << 15) +#define EXTI16 (1 << 16) +#define EXTI17 (1 << 17) +#define EXTI18 (1 << 18) +#define EXTI19 (1 << 19) + +/* Trigger types */ +typedef enum trigger_e { + EXTI_TRIGGER_RISING, + EXTI_TRIGGER_FALLING, + EXTI_TRIGGER_BOTH, +} exti_trigger_type; + +BEGIN_DECLS + +void exti_set_trigger(uint32_t extis, exti_trigger_type trig); +void exti_enable_request(uint32_t extis); +void exti_disable_request(uint32_t extis); +void exti_reset_request(uint32_t extis); +void exti_select_source(uint32_t exti, uint32_t gpioport); +uint32_t exti_get_flag_status(uint32_t exti); + +END_DECLS + +#endif +/** @cond */ +#else +#warning "exti_common_all.h should not be included directly, only via exti.h" +#endif +/** @endcond */ diff --git a/include/libopencm3/stm32/common/exti_common_f24.h b/include/libopencm3/stm32/common/exti_common_f24.h new file mode 100644 index 00000000..b7161159 --- /dev/null +++ b/include/libopencm3/stm32/common/exti_common_f24.h @@ -0,0 +1,40 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2010 Mark Butler + * + * 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 . + */ + +/** @cond */ +#if defined(LIBOPENCM3_EXTI_H) +/** @endcond */ +#ifndef LIBOPENCM3_EXTI_COMMON_F24_H +#define LIBOPENCM3_EXTI_COMMON_F24_H + +#include +#include +#include + +/* EXTI number definitions */ +#define EXTI20 (1 << 20) +#define EXTI21 (1 << 21) +#define EXTI22 (1 << 22) + +#endif +/** @cond */ +#else +#warning "exti_common_f24.h should not be included directly, only via exti.h" +#endif +/** @endcond */ diff --git a/include/libopencm3/stm32/exti.h b/include/libopencm3/stm32/exti.h index aa676baf..0ce9135c 100644 --- a/include/libopencm3/stm32/exti.h +++ b/include/libopencm3/stm32/exti.h @@ -1,7 +1,9 @@ +/* This provides unification of code over STM32F subfamilies */ + /* * This file is part of the libopencm3 project. * - * Copyright (C) 2010 Mark Butler + * Copyright (C) 2013 Piotr Esden-Tempski * * 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 @@ -17,78 +19,17 @@ * along with this library. If not, see . */ -#ifndef LIBOPENCM3_EXTI_H -#define LIBOPENCM3_EXTI_H - -#include -#include - -/* --- EXTI registers ------------------------------------------------------ */ - -#define EXTI_IMR MMIO32(EXTI_BASE + 0x00) -#define EXTI_EMR MMIO32(EXTI_BASE + 0x04) -#define EXTI_RTSR MMIO32(EXTI_BASE + 0x08) -#define EXTI_FTSR MMIO32(EXTI_BASE + 0x0c) -#define EXTI_SWIER MMIO32(EXTI_BASE + 0x10) -#define EXTI_PR MMIO32(EXTI_BASE + 0x14) - -#if defined (STM32F3) - -#define EXTI_IMR2 MMIO32(EXTI_BASE + 0x18) -#define EXTI_EMR2 MMIO32(EXTI_BASE + 0x1C) -#define EXTI_RTSR2 MMIO32(EXTI_BASE + 0x20) -#define EXTI_FTSR2 MMIO32(EXTI_BASE + 0x24) -#define EXTI_SWIER2 MMIO32(EXTI_BASE + 0x28) -#define EXTI_PR2 MMIO32(EXTI_BASE + 0x2C) - +#if defined(STM32F1) +# include +#elif defined(STM32F2) +# include +#elif defined(STM32F3) +# include +#elif defined(STM32F4) +# include +#elif defined(STM32L1) +# include +#else +# error "stm32 family not defined." #endif -/* EXTI number definitions */ -#define EXTI0 (1 << 0) -#define EXTI1 (1 << 1) -#define EXTI2 (1 << 2) -#define EXTI3 (1 << 3) -#define EXTI4 (1 << 4) -#define EXTI5 (1 << 5) -#define EXTI6 (1 << 6) -#define EXTI7 (1 << 7) -#define EXTI8 (1 << 8) -#define EXTI9 (1 << 9) -#define EXTI10 (1 << 10) -#define EXTI11 (1 << 11) -#define EXTI12 (1 << 12) -#define EXTI13 (1 << 13) -#define EXTI14 (1 << 14) -#define EXTI15 (1 << 15) -#define EXTI16 (1 << 16) -#define EXTI17 (1 << 17) -#define EXTI18 (1 << 18) -#define EXTI19 (1 << 19) - -#if !defined(STM32F3) - -#define EXTI20 (1 << 20) -#define EXTI21 (1 << 21) -#define EXTI22 (1 << 22) - -#endif - -/* Trigger types */ -typedef enum trigger_e { - EXTI_TRIGGER_RISING, - EXTI_TRIGGER_FALLING, - EXTI_TRIGGER_BOTH, -} exti_trigger_type; - -BEGIN_DECLS - -void exti_set_trigger(uint32_t extis, exti_trigger_type trig); -void exti_enable_request(uint32_t extis); -void exti_disable_request(uint32_t extis); -void exti_reset_request(uint32_t extis); -void exti_select_source(uint32_t exti, uint32_t gpioport); -uint32_t exti_get_flag_status(uint32_t exti); - -END_DECLS - -#endif diff --git a/include/libopencm3/stm32/f1/exti.h b/include/libopencm3/stm32/f1/exti.h new file mode 100644 index 00000000..5d730eed --- /dev/null +++ b/include/libopencm3/stm32/f1/exti.h @@ -0,0 +1,26 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Piotr Esden-Tempski + * + * 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 . + */ + +#ifndef LIBOPENCM3_EXTI_H +#define LIBOPENCM3_EXTI_H + +#include +#include + +#endif diff --git a/include/libopencm3/stm32/f2/exti.h b/include/libopencm3/stm32/f2/exti.h new file mode 100644 index 00000000..79e8ac5d --- /dev/null +++ b/include/libopencm3/stm32/f2/exti.h @@ -0,0 +1,26 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Piotr Esden-Tempski + * + * 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 . + */ + +#ifndef LIBOPENCM3_EXTI_H +#define LIBOPENCM3_EXTI_H + +#include +#include + +#endif diff --git a/include/libopencm3/stm32/f3/exti.h b/include/libopencm3/stm32/f3/exti.h new file mode 100644 index 00000000..c0b7340a --- /dev/null +++ b/include/libopencm3/stm32/f3/exti.h @@ -0,0 +1,34 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Piotr Esden-Tempski + * + * 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 . + */ + +#ifndef LIBOPENCM3_EXTI_H +#define LIBOPENCM3_EXTI_H + +#include +#include + +/* --- EXTI registers ------------------------------------------------------ */ +#define EXTI_IMR2 MMIO32(EXTI_BASE + 0x18) +#define EXTI_EMR2 MMIO32(EXTI_BASE + 0x1C) +#define EXTI_RTSR2 MMIO32(EXTI_BASE + 0x20) +#define EXTI_FTSR2 MMIO32(EXTI_BASE + 0x24) +#define EXTI_SWIER2 MMIO32(EXTI_BASE + 0x28) +#define EXTI_PR2 MMIO32(EXTI_BASE + 0x2C) + +#endif diff --git a/include/libopencm3/stm32/f4/exti.h b/include/libopencm3/stm32/f4/exti.h new file mode 100644 index 00000000..79e8ac5d --- /dev/null +++ b/include/libopencm3/stm32/f4/exti.h @@ -0,0 +1,26 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Piotr Esden-Tempski + * + * 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 . + */ + +#ifndef LIBOPENCM3_EXTI_H +#define LIBOPENCM3_EXTI_H + +#include +#include + +#endif diff --git a/include/libopencm3/stm32/l1/exti.h b/include/libopencm3/stm32/l1/exti.h new file mode 100644 index 00000000..5d730eed --- /dev/null +++ b/include/libopencm3/stm32/l1/exti.h @@ -0,0 +1,26 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Piotr Esden-Tempski + * + * 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 . + */ + +#ifndef LIBOPENCM3_EXTI_H +#define LIBOPENCM3_EXTI_H + +#include +#include + +#endif