From 07868ad8b6d8086e77c0e2e1b4e2b837a54f7431 Mon Sep 17 00:00:00 2001 From: Oliver Meier Date: Sat, 11 May 2019 03:14:54 +0200 Subject: [PATCH] stm32f7: enable existing dma2d headers --- .../stm32/common/dma2d_common_f47.h | 187 ++++++++++++++++++ include/libopencm3/stm32/dma2d.h | 2 + include/libopencm3/stm32/f4/dma2d.h | 167 +--------------- include/libopencm3/stm32/f7/dma2d.h | 30 +++ lib/stm32/common/dma2d_common_f47.c | 33 ++++ lib/stm32/f4/Makefile | 1 + lib/stm32/f7/Makefile | 1 + 7 files changed, 259 insertions(+), 162 deletions(-) create mode 100644 include/libopencm3/stm32/common/dma2d_common_f47.h create mode 100644 include/libopencm3/stm32/f7/dma2d.h create mode 100644 lib/stm32/common/dma2d_common_f47.c diff --git a/include/libopencm3/stm32/common/dma2d_common_f47.h b/include/libopencm3/stm32/common/dma2d_common_f47.h new file mode 100644 index 00000000..d8ba0375 --- /dev/null +++ b/include/libopencm3/stm32/common/dma2d_common_f47.h @@ -0,0 +1,187 @@ +/** @addtogroup dma2d_defines + * + * @version 1.0.0 + * + * @date 15 August 2016 + * + * This library supports the DMA2D Peripheral in the STM32F4xx and STM32F7xx + * series of ARM Cortex Microcontrollers by ST Microelectronics. + * + * LGPL License Terms @ref lgpl_license + */ + +/* + * STM32F4xx/STM32F7xx DMA2D Register defines + * + * Copyright (C) 2016, Chuck McManis + * + * This file is part of the libopencm3 project. + * + * 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 +#include + +#ifndef DMA2D_H +#define DMA2D_H + +/**@{*/ + +/** DMA2D Control Register */ +#define DMA2D_CR MMIO32(DMA2D_BASE + 0x0U) +#define DMA2D_CR_MODE_SHIFT 16 +#define DMA2D_CR_MODE_MASK 0x3 +#define DMA2D_CR_MODE_M2M 0 /* memory to memory */ +#define DMA2D_CR_MODE_M2MWPFC 1 /* memory to memory with pix convert */ +#define DMA2D_CR_MODE_M2MWB 2 /* memory to memory with blend */ +#define DMA2D_CR_MODE_R2M 3 /* register to memory */ +#define DMA2D_CR_CEIE (1 << 13) +#define DMA2D_CR_CTCIE (1 << 12) +#define DMA2D_CR_CAEIE (1 << 11) +#define DMA2D_CR_TWIE (1 << 10) +#define DMA2D_CR_TCIE (1 << 9) +#define DMA2D_CR_TEIE (1 << 8) +#define DMA2D_CR_ABORT (1 << 2) +#define DMA2D_CR_SUSP (1 << 1) +#define DMA2D_CR_START (1 << 0) + +/** DMA2D Interrupt Status Register */ +#define DMA2D_ISR MMIO32(DMA2D_BASE + 0x4U) +#define DMA2D_ISR_CEIF (1 << 5) +#define DMA2D_ISR_CTCIF (1 << 4) +#define DMA2D_ISR_CAEIF (1 << 3) +#define DMA2D_ISR_TWIF (1 << 2) +#define DMA2D_ISR_TCIF (1 << 1) +#define DMA2D_ISR_TEIF (1 << 0) + +/** DMA2D Interrupt Flag Clear Register */ +#define DMA2D_IFCR MMIO32(DMA2D_BASE + 0x8U) +#define DMA2D_IFCR_CCEIF (1 << 5) +#define DMA2D_IFCR_CCTCIF (1 << 4) +#define DMA2D_IFCR_CCAEIF (1 << 3) +#define DMA2D_IFCR_CTWIF (1 << 2) +#define DMA2D_IFCR_CTCIF (1 << 1) +#define DMA2D_IFCR_CTEIF (1 << 0) + +/** DMA2D Foreground Memory Address Register */ +#define DMA2D_FGMAR MMIO32(DMA2D_BASE + 0xCU) + +/** DMA2D Foreground Offset Register */ +#define DMA2D_FGOR MMIO32(DMA2D_BASE + 0x10U) +#define DMA2D_FGOR_LO_SHIFT 0 +#define DMA2D_FGOR_LO_MASK 0x3fff + +/** DMA2D Background Memory Address Register */ +#define DMA2D_BGMAR MMIO32(DMA2D_BASE + 0x14U) + +/** DMA2D Background Offset Register */ +#define DMA2D_BGOR MMIO32(DMA2D_BASE + 0x18U) +#define DMA2D_BGOR_LO_SHIFT 0 +#define DMA2D_BGOR_LO_MASK 0x3fff + +/** DMA2D Foreground and Background PFC Control Register */ +#define DMA2D_FGPFCCR MMIO32(DMA2D_BASE + 0x1cU) +#define DMA2D_BGPFCCR MMIO32(DMA2D_BASE + 0x24U) + +#define DMA2D_xPFCCR_ALPHA_SHIFT 24 +#define DMA2D_xPFCCR_ALPHA_MASK 0xff +#define DMA2D_xPFCCR_AM_SHIFT 16 +#define DMA2D_xPFCCR_AM_MASK 0x3 +#define DMA2D_xPFCCR_AM_NONE 0 +#define DMA2D_xPFCCR_AM_FORCE 1 +#define DMA2D_xPFCCR_AM_PRODUCT 2 +#define DMA2D_xPFCCR_CS_SHIFT 8 +#define DMA2D_xPFCCR_CS_MASK 0xff +#define DMA2D_xPFCCR_START (1 << 5) +#define DMA2D_xPFCCR_CCM_ARGB8888 (0 << 4) +#define DMA2D_xPFCCR_CCM_RGB888 (1 << 4) +#define DMA2D_xPFCCR_CM_SHIFT 0 +#define DMA2D_xPFCCR_CM_MASK 0xf +#define DMA2D_xPFCCR_CM_ARGB8888 0 +#define DMA2D_xPFCCR_CM_RGB888 1 +#define DMA2D_xPFCCR_CM_RGB565 2 +#define DMA2D_xPFCCR_CM_ARGB1555 3 +#define DMA2D_xPFCCR_CM_ARGB4444 4 +#define DMA2D_xPFCCR_CM_L8 5 +#define DMA2D_xPFCCR_CM_AL44 6 +#define DMA2D_xPFCCR_CM_AL88 7 +#define DMA2D_xPFCCR_CM_L4 8 +#define DMA2D_xPFCCR_CM_A8 9 +#define DMA2D_xPFCCR_CM_A4 10 + +/** DMA2D Foreground and Background Color Register */ +#define DMA2D_FGCOLR MMIO32(DMA2D_BASE + 0x20U) +#define DMA2D_BGCOLR MMIO32(DMA2D_BASE + 0x28U) +#define DMA2D_xCOLR_RED_SHIFT 16 +#define DMA2D_xCOLR_RED_MASK 0xff +#define DMA2D_xCOLR_GREEN_SHIFT 8 +#define DMA2D_xCOLR_GREEN_MASK 0xff +#define DMA2D_xCOLR_BLUE_SHIFT 0 +#define DMA2D_xCOLR_BLUE_MASK 0xff + +/** DMA2D Foreground CLUT Memory Address Register */ +#define DMA2D_FGCMAR MMIO32(DMA2D_BASE + 0x2CU) + +/** DMA2D Background CLUT Memory Address Register */ +#define DMA2D_BGCMAR MMIO32(DMA2D_BASE + 0x30U) + +/** DMA2D Output PFC Control Register */ +#define DMA2D_OPFCCR MMIO32(DMA2D_BASE + 0x34U) +#define DMA2D_OPFCCR_CM_SHIFT 0 +#define DMA2D_OPFCCR_CM_MASK 0x3 +#define DMA2D_OPFCCR_CM_ARGB8888 0 +#define DMA2D_OPFCCR_CM_RGB888 1 +#define DMA2D_OPFCCR_CM_RGB565 2 +#define DMA2D_OPFCCR_CM_ARGB4444 3 + +/** DMA2D Output Color Register */ +/* The format of this register depends on PFC control above */ +#define DMA2D_OCOLR MMIO32(DMA2D_BASE + 0x38U) + +/** DMA2D Output Memory Address Register */ +#define DMA2D_OMAR MMIO32(DMA2D_BASE + 0x3CU) + +/** DMA2D Output offset Register */ +#define DMA2D_OOR MMIO32(DMA2D_BASE + 0x40U) +#define DMA2D_OOR_LO_SHIFT 0 +#define DMA2D_OOR_LO_MASK 0x3fff + +/** DMA2D Number of Lines Register */ +#define DMA2D_NLR MMIO32(DMA2D_BASE + 0x44U) +#define DMA2D_NLR_PL_SHIFT 16 +#define DMA2D_NLR_PL_MASK 0x3fff +#define DMA2D_NLR_NL_SHIFT 0 +#define DMA2D_NLR_NL_MASK 0xffff + +/** DMA2D Line Watermark Register */ +#define DMA2D_LWR MMIO32(DMA2D_BASE + 0x48U) +#define DMA2D_LWR_LW_SHIFT 0 +#define DMA2D_LWR_LW_MASK 0xffff + +/** DMA2D AHB Master Timer Config Register */ +#define DMA2D_AMTCR MMIO32(DMA2D_BASE + 0x4CU) +#define DMA2D_AMTCR_DT_SHIFT 8 +#define DMA2D_AMTCR_DT_MASK 0xff +#define DMA2D_AMTCR_EN (1 << 0) + +/** DMA2D Foreground Color Lookup table */ +#define DMA2D_FG_CLUT (uint32_t *)(DMA2D_BASE + 0x400U) + +/** DMA2D Background Color Lookup table */ +#define DMA2D_BG_CLUT (uint32_t *)(DMA2D_BASE + 0x800U) + +/**@}*/ +#endif diff --git a/include/libopencm3/stm32/dma2d.h b/include/libopencm3/stm32/dma2d.h index 178c1b07..ab4e1f28 100644 --- a/include/libopencm3/stm32/dma2d.h +++ b/include/libopencm3/stm32/dma2d.h @@ -22,6 +22,8 @@ #if defined(STM32F4) # include +#elif defined(STM32F7) +# include #else # error "dma2d.h not available for this family." #endif diff --git a/include/libopencm3/stm32/f4/dma2d.h b/include/libopencm3/stm32/f4/dma2d.h index 7d6e1abc..80c23599 100644 --- a/include/libopencm3/stm32/f4/dma2d.h +++ b/include/libopencm3/stm32/f4/dma2d.h @@ -1,20 +1,8 @@ /** @defgroup dma2d_defines DMA2D Defines - * + * @brief Defined Constants and Types for the STM32F4xx DMA2D Peripheral * @ingroup STM32F4xx_defines - * - * @brief Defined Constants and Macros for the STM32x4xx DMA2D Peripheral - * - * @version 1.0.0 - * - * @date 15 August 2016 - * LGPL License Terms @ref lgpl_license */ - /* - * STM32F4 DMA2D Register defines - * - * Copyright (C) 2016, Chuck McManis - * * This file is part of the libopencm3 project. * * This library is free software: you can redistribute it and/or modify @@ -29,159 +17,14 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . - * */ - -#include -#include - -#ifndef DMA2D_H -#define DMA2D_H - /**@{*/ -/** DMA2D Control Register */ -#define DMA2D_CR MMIO32(DMA2D_BASE + 0x0U) -#define DMA2D_CR_MODE_SHIFT 16 -#define DMA2D_CR_MODE_MASK 0x3 -#define DMA2D_CR_MODE_M2M 0 /* memory to memory */ -#define DMA2D_CR_MODE_M2MWPFC 1 /* memory to memory with pix convert */ -#define DMA2D_CR_MODE_M2MWB 2 /* memory to memory with blend */ -#define DMA2D_CR_MODE_R2M 3 /* register to memory */ -#define DMA2D_CR_CEIE (1 << 13) -#define DMA2D_CR_CTCIE (1 << 12) -#define DMA2D_CR_CAEIE (1 << 11) -#define DMA2D_CR_TWIE (1 << 10) -#define DMA2D_CR_TCIE (1 << 9) -#define DMA2D_CR_TEIE (1 << 8) -#define DMA2D_CR_ABORT (1 << 2) -#define DMA2D_CR_SUSP (1 << 1) -#define DMA2D_CR_START (1 << 0) +#ifndef LIBOPENCM3_STM32_F4_DMA2D_H_ +#define LIBOPENCM3_STM32_F4_DMA2D_H_ -/** DMA2D Interrupt Status Register */ -#define DMA2D_ISR MMIO32(DMA2D_BASE + 0x4U) -#define DMA2D_ISR_CEIF (1 << 5) -#define DMA2D_ISR_CTCIF (1 << 4) -#define DMA2D_ISR_CAEIF (1 << 3) -#define DMA2D_ISR_TWIF (1 << 2) -#define DMA2D_ISR_TCIF (1 << 1) -#define DMA2D_ISR_TEIF (1 << 0) +#include -/** DMA2D Interrupt Flag Clear Register */ -#define DMA2D_IFCR MMIO32(DMA2D_BASE + 0x8U) -#define DMA2D_IFCR_CCEIF (1 << 5) -#define DMA2D_IFCR_CCTCIF (1 << 4) -#define DMA2D_IFCR_CCAEIF (1 << 3) -#define DMA2D_IFCR_CTWIF (1 << 2) -#define DMA2D_IFCR_CTCIF (1 << 1) -#define DMA2D_IFCR_CTEIF (1 << 0) - -/** DMA2D Foreground Memory Address Register */ -#define DMA2D_FGMAR MMIO32(DMA2D_BASE + 0xCU) - -/** DMA2D Foreground Offset Register */ -#define DMA2D_FGOR MMIO32(DMA2D_BASE + 0x10U) -#define DMA2D_FGOR_LO_SHIFT 0 -#define DMA2D_FGOR_LO_MASK 0x3fff - -/** DMA2D Background Memory Address Register */ -#define DMA2D_BGMAR MMIO32(DMA2D_BASE + 0x14U) - -/** DMA2D Background Offset Register */ -#define DMA2D_BGOR MMIO32(DMA2D_BASE + 0x18U) -#define DMA2D_BGOR_LO_SHIFT 0 -#define DMA2D_BGOR_LO_MASK 0x3fff - -/** DMA2D Foreground and Background PFC Control Register */ -#define DMA2D_FGPFCCR MMIO32(DMA2D_BASE + 0x1cU) -#define DMA2D_BGPFCCR MMIO32(DMA2D_BASE + 0x24U) - -#define DMA2D_xPFCCR_ALPHA_SHIFT 24 -#define DMA2D_xPFCCR_ALPHA_MASK 0xff -#define DMA2D_xPFCCR_AM_SHIFT 16 -#define DMA2D_xPFCCR_AM_MASK 0x3 -#define DMA2D_xPFCCR_AM_NONE 0 -#define DMA2D_xPFCCR_AM_FORCE 1 -#define DMA2D_xPFCCR_AM_PRODUCT 2 -#define DMA2D_xPFCCR_CS_SHIFT 8 -#define DMA2D_xPFCCR_CS_MASK 0xff -#define DMA2D_xPFCCR_START (1 << 5) -#define DMA2D_xPFCCR_CCM_ARGB8888 (0 << 4) -#define DMA2D_xPFCCR_CCM_RGB888 (1 << 4) -#define DMA2D_xPFCCR_CM_SHIFT 0 -#define DMA2D_xPFCCR_CM_MASK 0xf -#define DMA2D_xPFCCR_CM_ARGB8888 0 -#define DMA2D_xPFCCR_CM_RGB888 1 -#define DMA2D_xPFCCR_CM_RGB565 2 -#define DMA2D_xPFCCR_CM_ARGB1555 3 -#define DMA2D_xPFCCR_CM_ARGB4444 4 -#define DMA2D_xPFCCR_CM_L8 5 -#define DMA2D_xPFCCR_CM_AL44 6 -#define DMA2D_xPFCCR_CM_AL88 7 -#define DMA2D_xPFCCR_CM_L4 8 -#define DMA2D_xPFCCR_CM_A8 9 -#define DMA2D_xPFCCR_CM_A4 10 - -/** DMA2D Foreground and Background Color Register */ -#define DMA2D_FGCOLR MMIO32(DMA2D_BASE + 0x20U) -#define DMA2D_BGCOLR MMIO32(DMA2D_BASE + 0x28U) -#define DMA2D_xCOLR_RED_SHIFT 16 -#define DMA2D_xCOLR_RED_MASK 0xff -#define DMA2D_xCOLR_GREEN_SHIFT 8 -#define DMA2D_xCOLR_GREEN_MASK 0xff -#define DMA2D_xCOLR_BLUE_SHIFT 0 -#define DMA2D_xCOLR_BLUE_MASK 0xff - -/** DMA2D Foreground CLUT Memory Address Register */ -#define DMA2D_FGCMAR MMIO32(DMA2D_BASE + 0x2CU) - -/** DMA2D Background CLUT Memory Address Register */ -#define DMA2D_BGCMAR MMIO32(DMA2D_BASE + 0x30U) - -/** DMA2D Output PFC Control Register */ -#define DMA2D_OPFCCR MMIO32(DMA2D_BASE + 0x34U) -#define DMA2D_OPFCCR_CM_SHIFT 0 -#define DMA2D_OPFCCR_CM_MASK 0x3 -#define DMA2D_OPFCCR_CM_ARGB8888 0 -#define DMA2D_OPFCCR_CM_RGB888 1 -#define DMA2D_OPFCCR_CM_RGB565 2 -#define DMA2D_OPFCCR_CM_ARGB4444 3 - -/** DMA2D Output Color Register */ -/* The format of this register depends on PFC control above */ -#define DMA2D_OCOLR MMIO32(DMA2D_BASE + 0x38U) - -/** DMA2D Output Memory Address Register */ -#define DMA2D_OMAR MMIO32(DMA2D_BASE + 0x3CU) - -/** DMA2D Output offset Register */ -#define DMA2D_OOR MMIO32(DMA2D_BASE + 0x40U) -#define DMA2D_OOR_LO_SHIFT 0 -#define DMA2D_OOR_LO_MASK 0x3fff - -/** DMA2D Number of Lines Register */ -#define DMA2D_NLR MMIO32(DMA2D_BASE + 0x44U) -#define DMA2D_NLR_PL_SHIFT 16 -#define DMA2D_NLR_PL_MASK 0x3fff -#define DMA2D_NLR_NL_SHIFT 0 -#define DMA2D_NLR_NL_MASK 0xffff - -/** DMA2D Line Watermark Register */ -#define DMA2D_LWR MMIO32(DMA2D_BASE + 0x48U) -#define DMA2D_LWR_LW_SHIFT 0 -#define DMA2D_LWR_LW_MASK 0xffff - -/** DMA2D AHB Master Timer Config Register */ -#define DMA2D_AMTCR MMIO32(DMA2D_BASE + 0x4CU) -#define DMA2D_AMTCR_DT_SHIFT 8 -#define DMA2D_AMTCR_DT_MASK 0xff -#define DMA2D_AMTCR_EN (1 << 0) - -/** DMA2D Foreground Color Lookup table */ -#define DMA2D_FG_CLUT (uint32_t *)(DMA2D_BASE + 0x400U) - -/** DMA2D Background Color Lookup table */ -#define DMA2D_BG_CLUT (uint32_t *)(DMA2D_BASE + 0x800U) +#endif /* LIBOPENCM3_STM32_F4_DMA2D_H_ */ /**@}*/ -#endif diff --git a/include/libopencm3/stm32/f7/dma2d.h b/include/libopencm3/stm32/f7/dma2d.h new file mode 100644 index 00000000..47b26478 --- /dev/null +++ b/include/libopencm3/stm32/f7/dma2d.h @@ -0,0 +1,30 @@ +/** @defgroup dma2d_defines DMA2D Defines + * @brief Defined Constants and Types for the STM32F7xx DMA2D Peripheral + * @ingroup STM32F7xx_defines + */ +/* + * This file is part of the libopencm3 project. + * + * 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_STM32_F7_DMA2D_H_ +#define LIBOPENCM3_STM32_F7_DMA2D_H_ + +#include + +#endif /* LIBOPENCM3_STM32_F7_DMA2D_H_ */ + +/**@}*/ diff --git a/lib/stm32/common/dma2d_common_f47.c b/lib/stm32/common/dma2d_common_f47.c new file mode 100644 index 00000000..013292a0 --- /dev/null +++ b/lib/stm32/common/dma2d_common_f47.c @@ -0,0 +1,33 @@ +/** @defgroup dma2d_file DMA2D peripheral API + * + * @ingroup peripheral_apis + * + * @version 1.0.0 + * + * This library supports the DMA2D Peripheral in the STM32F4xx and STM32F7xx + * series of ARM Cortex Microcontrollers by ST Microelectronics. + * + * LGPL License Terms @ref lgpl_license + */ +/* + * This file is part of the libopencm3 project. + * + * 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 + +/**@{*/ + +/**@}*/ diff --git a/lib/stm32/f4/Makefile b/lib/stm32/f4/Makefile index 671effc5..9728e3be 100644 --- a/lib/stm32/f4/Makefile +++ b/lib/stm32/f4/Makefile @@ -46,6 +46,7 @@ OBJS += crypto_common_f24.o crypto.o OBJS += dac_common_all.o OBJS += desig.o OBJS += dma_common_f24.o +OBJS += dma2d_common_f47.o OBJS += dsi_common_f47.o OBJS += exti_common_all.o OBJS += flash.o flash_common_all.o flash_common_f.o flash_common_f24.o diff --git a/lib/stm32/f7/Makefile b/lib/stm32/f7/Makefile index fdf45b53..466ca351 100644 --- a/lib/stm32/f7/Makefile +++ b/lib/stm32/f7/Makefile @@ -48,6 +48,7 @@ OBJS += crc_common_all.o crc_v2.o OBJS += dac_common_all.o OBJS += desig.o OBJS += dma_common_f24.o +OBJS += dma2d_common_f47.o OBJS += dsi_common_f47.o OBJS += exti_common_all.o OBJS += flash_common_all.o flash_common_f.o flash_common_f24.o flash.o