From cd9ba870732ba156213de48403ffbd711b1cbe90 Mon Sep 17 00:00:00 2001 From: BuFran Date: Wed, 10 Jul 2013 18:18:40 +0200 Subject: [PATCH] [STM32F0:SYSCFG] Add support for SYSCFG. Old file moved to common directory for L1 and F234 --- .../stm32/common/syscfg_common_l1f234.h | 60 ++++++++++++++ include/libopencm3/stm32/f0/syscfg.h | 78 +++++++++++++++++++ include/libopencm3/stm32/f2/syscfg.h | 26 +++++++ include/libopencm3/stm32/f3/syscfg.h | 26 +++++++ include/libopencm3/stm32/f4/syscfg.h | 26 +++++++ include/libopencm3/stm32/l1/syscfg.h | 26 +++++++ include/libopencm3/stm32/syscfg.h | 41 ++++------ 7 files changed, 256 insertions(+), 27 deletions(-) create mode 100644 include/libopencm3/stm32/common/syscfg_common_l1f234.h create mode 100644 include/libopencm3/stm32/f0/syscfg.h create mode 100644 include/libopencm3/stm32/f2/syscfg.h create mode 100644 include/libopencm3/stm32/f3/syscfg.h create mode 100644 include/libopencm3/stm32/f4/syscfg.h create mode 100644 include/libopencm3/stm32/l1/syscfg.h diff --git a/include/libopencm3/stm32/common/syscfg_common_l1f234.h b/include/libopencm3/stm32/common/syscfg_common_l1f234.h new file mode 100644 index 00000000..41e501ee --- /dev/null +++ b/include/libopencm3/stm32/common/syscfg_common_l1f234.h @@ -0,0 +1,60 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2011 Fergus Noble + * + * 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 SPI.H +The order of header inclusion is important. spi.h includes the device +specific memorymap.h header before including this header file.*/ + +/** @cond */ +#if defined(LIBOPENCM3_SYSCFG_H) +/** @endcond */ +#ifndef LIBOPENCM3_SYSCFG_COMMON_L1F234_H +#define LIBOPENCM3_SYSCFG_COMMON_L1F234_H + + +#include + + +/* --- SYSCFG registers ---------------------------------------------------- */ + +#define SYSCFG_MEMRM MMIO32(SYSCFG_BASE + 0x00) + +#define SYSCFG_PMC MMIO32(SYSCFG_BASE + 0x04) + +/* External interrupt configuration register 1 (SYSCFG_EXTICR1) */ +#define SYSCFG_EXTICR1 MMIO32(SYSCFG_BASE + 0x08) + +/* External interrupt configuration register 2 (SYSCFG_EXTICR2) */ +#define SYSCFG_EXTICR2 MMIO32(SYSCFG_BASE + 0x0c) + +/* External interrupt configuration register 3 (SYSCFG_EXTICR3) */ +#define SYSCFG_EXTICR3 MMIO32(SYSCFG_BASE + 0x10) + +/* External interrupt configuration register 4 (SYSCFG_EXTICR4) */ +#define SYSCFG_EXTICR4 MMIO32(SYSCFG_BASE + 0x14) + +#define SYSCFG_CMPCR MMIO32(SYSCFG_BASE + 0x20) + +#endif + +/** @cond */ +#else +#warning "syscfg_common_l1f234.h should not be included explicitly, only via syscfg.h" +#endif +/** @endcond */ diff --git a/include/libopencm3/stm32/f0/syscfg.h b/include/libopencm3/stm32/f0/syscfg.h new file mode 100644 index 00000000..3b79d9a0 --- /dev/null +++ b/include/libopencm3/stm32/f0/syscfg.h @@ -0,0 +1,78 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Frantisek Burian + * + * 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_SYSCFG_H +#define LIBOPENCM3_SYSCFG_H + +#include +#include + +/* --- SYSCFG registers ---------------------------------------------------- */ + +#define SYSCFG_CFGR1 MMIO32(SYSCFG_COMP_BASE + 0x00) +#define SYSCFG_EXTICR(i) MMIO32(SYSCFG_COMP_BASE + 0x08 + (i)*4) +#define SYSCFG_EXTICR1 SYSCFG_EXTICR(0) +#define SYSCFG_EXTICR2 SYSCFG_EXTICR(1) +#define SYSCFG_EXTICR3 SYSCFG_EXTICR(2) +#define SYSCFG_EXTICR4 SYSCFG_EXTICR(3) +#define SYSCFG_CFGR2 MMIO32(SYSCFG_COMP_BASE + 0x18) + +/* Register values ----------------------------------------------------------*/ + +/* SYSCFG_CFGR1 Values -- ---------------------------------------------------*/ + +#define SYSCFG_CFGR1_MEM_MODE_SHIFT 0 +#define SYSCFG_CFGR1_MEM_MODE (3 << SYSCFG_CFGR1_MEM_MODE_SHIFT) +#define SYSCFG_CFGR1_MEM_MODE_FLASH (0 << SYSCFG_CFGR1_MEM_MODE_SHIFT) +#define SYSCFG_CFGR1_MEM_MODE_SYSTEM (1 << SYSCFG_CFGR1_MEM_MODE_SHIFT) +#define SYSCFG_CFGR1_MEM_MODE_SRAM (3 << SYSCFG_CFGR1_MEM_MODE_SHIFT) + +#define SYSCFG_CFGR1_ADC_DMA_RMP (1 << 8) +#define SYSCFG_CFGR1_USART1_TX_DMA_RMP (1 << 9) +#define SYSCFG_CFGR1_USART1_RX_DMA_RMP (1 << 10) +#define SYSCFG_CFGR1_TIM16_DMA_RMP (1 << 11) +#define SYSCFG_CFGR1_TIM17_DMA_RMP (1 << 12) + +#define SYSCFG_CFGR1_I2C_PB6_FMPLUS (1 << 16) +#define SYSCFG_CFGR1_I2C_PB7_FMPLUS (1 << 17) +#define SYSCFG_CFGR1_I2C_PB8_FMPLUS (1 << 18) +#define SYSCFG_CFGR1_I2C_PB9_FMPLUS (1 << 19) +#define SYSCFG_CFGR1_I2C1_FMPLUS (1 << 20) +#define SYSCFG_CFGR1_I2C_PA9_FMPLUS (1 << 22) +#define SYSCFG_CFGR1_I2C_PA10_FMPLUS (1 << 23) + +#define SYSCFG_EXTICR_SKIP 4 +#define SYSCFG_EXTICR_GPIOA 0 +#define SYSCFG_EXTICR_GPIOB 1 +#define SYSCFG_EXTICR_GPIOC 2 +#define SYSCFG_EXTICR_GPIOD 3 +#define SYSCFG_EXTICR_GPIOF 5 + +#define SYSCFG_CFGR2_LOCKUP_LOCK (1 << 0) +#define SYSCFG_CFGR2_SRAM_PARITY_LOCK (1 << 1) +#define SYSCFG_CFGR2_PVD_LOCK (1 << 2) +#define SYSCFG_CFGR2_SRAM_PEF (1 << 8) + +/* API values ---------------------------------------------------------------*/ + +BEGIN_DECLS + +END_DECLS + +#endif diff --git a/include/libopencm3/stm32/f2/syscfg.h b/include/libopencm3/stm32/f2/syscfg.h new file mode 100644 index 00000000..aef85f3a --- /dev/null +++ b/include/libopencm3/stm32/f2/syscfg.h @@ -0,0 +1,26 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Frantisek Burian + * + * 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_SYSCFG_H +#define LIBOPENCM3_SYSCFG_H + +#include +#include + +#endif diff --git a/include/libopencm3/stm32/f3/syscfg.h b/include/libopencm3/stm32/f3/syscfg.h new file mode 100644 index 00000000..aef85f3a --- /dev/null +++ b/include/libopencm3/stm32/f3/syscfg.h @@ -0,0 +1,26 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Frantisek Burian + * + * 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_SYSCFG_H +#define LIBOPENCM3_SYSCFG_H + +#include +#include + +#endif diff --git a/include/libopencm3/stm32/f4/syscfg.h b/include/libopencm3/stm32/f4/syscfg.h new file mode 100644 index 00000000..aef85f3a --- /dev/null +++ b/include/libopencm3/stm32/f4/syscfg.h @@ -0,0 +1,26 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Frantisek Burian + * + * 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_SYSCFG_H +#define LIBOPENCM3_SYSCFG_H + +#include +#include + +#endif diff --git a/include/libopencm3/stm32/l1/syscfg.h b/include/libopencm3/stm32/l1/syscfg.h new file mode 100644 index 00000000..aef85f3a --- /dev/null +++ b/include/libopencm3/stm32/l1/syscfg.h @@ -0,0 +1,26 @@ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2013 Frantisek Burian + * + * 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_SYSCFG_H +#define LIBOPENCM3_SYSCFG_H + +#include +#include + +#endif diff --git a/include/libopencm3/stm32/syscfg.h b/include/libopencm3/stm32/syscfg.h index ceba5a61..2428e58a 100644 --- a/include/libopencm3/stm32/syscfg.h +++ b/include/libopencm3/stm32/syscfg.h @@ -1,8 +1,8 @@ +/* This provides unification of code over STM32F subfamilies */ + /* * This file is part of the libopencm3 project. * - * Copyright (C) 2011 Fergus Noble - * * 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 @@ -17,30 +17,17 @@ * along with this library. If not, see . */ -#ifndef LIBOPENCM3_SYSCFG_H -#define LIBOPENCM3_SYSCFG_H - -#include - -/* --- SYSCFG registers ---------------------------------------------------- */ - -#define SYSCFG_MEMRM MMIO32(SYSCFG_BASE + 0x00) - -#define SYSCFG_PMC MMIO32(SYSCFG_BASE + 0x04) - -/* External interrupt configuration register 1 (SYSCFG_EXTICR1) */ -#define SYSCFG_EXTICR1 MMIO32(SYSCFG_BASE + 0x08) - -/* External interrupt configuration register 2 (SYSCFG_EXTICR2) */ -#define SYSCFG_EXTICR2 MMIO32(SYSCFG_BASE + 0x0c) - -/* External interrupt configuration register 3 (SYSCFG_EXTICR3) */ -#define SYSCFG_EXTICR3 MMIO32(SYSCFG_BASE + 0x10) - -/* External interrupt configuration register 4 (SYSCFG_EXTICR4) */ -#define SYSCFG_EXTICR4 MMIO32(SYSCFG_BASE + 0x14) - -#define SYSCFG_CMPCR MMIO32(SYSCFG_BASE + 0x20) - +#if defined(STM32F0) +# include +#elif defined(STM32F2) +# include +#elif defined(STM32F3) +# include +#elif defined(STM32F4) +# include +#elif defined(STM32L1) +# include +#else +# error "stm32 family not defined." #endif