From 2f29614133dbf34d5aa088cf8d6a1a6c74fb58c6 Mon Sep 17 00:00:00 2001 From: andrej Date: Mon, 19 Sep 2022 11:28:57 +0200 Subject: [PATCH] stm32: Support CRC, SYSCFG and USART on G4 --- include/libopencm3/stm32/crc.h | 2 + include/libopencm3/stm32/g4/crc.h | 33 +++++++++++++++++ include/libopencm3/stm32/g4/syscfg.h | 50 +++++++++++++++++++++++++ include/libopencm3/stm32/g4/usart.h | 55 ++++++++++++++++++++++++++++ include/libopencm3/stm32/syscfg.h | 2 + include/libopencm3/stm32/usart.h | 2 + lib/stm32/g4/Makefile | 2 + 7 files changed, 146 insertions(+) create mode 100644 include/libopencm3/stm32/g4/crc.h create mode 100644 include/libopencm3/stm32/g4/syscfg.h create mode 100644 include/libopencm3/stm32/g4/usart.h diff --git a/include/libopencm3/stm32/crc.h b/include/libopencm3/stm32/crc.h index 07498669..54157b18 100644 --- a/include/libopencm3/stm32/crc.h +++ b/include/libopencm3/stm32/crc.h @@ -40,6 +40,8 @@ # include #elif defined(STM32G0) # include +#elif defined(STM32G4) +# include #else # error "stm32 family not defined." #endif diff --git a/include/libopencm3/stm32/g4/crc.h b/include/libopencm3/stm32/g4/crc.h new file mode 100644 index 00000000..3b464191 --- /dev/null +++ b/include/libopencm3/stm32/g4/crc.h @@ -0,0 +1,33 @@ +/** @defgroup crc_defines CRC Defines + * + * @brief Defined Constants and Types for the STM32G4xx CRC Generator + * + * @ingroup STM32G4xx_defines + * + * @version 1.0.0 + * + * 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 . + */ + +#ifndef LIBOPENCM3_CRC_H +#define LIBOPENCM3_CRC_H + +#include + +#endif diff --git a/include/libopencm3/stm32/g4/syscfg.h b/include/libopencm3/stm32/g4/syscfg.h new file mode 100644 index 00000000..e490032f --- /dev/null +++ b/include/libopencm3/stm32/g4/syscfg.h @@ -0,0 +1,50 @@ +/** @defgroup syscfg_defines SYSCFG Defines + * + * @ingroup STM32G4xx_defines + * + * @brief Defined Constants and Types for the STM32G4xx Sysconfig + * + * @version 1.0.0 + * + * 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 . + */ + +#ifndef LIBOPENCM3_SYSCFG_H +#define LIBOPENCM3_SYSCFG_H + +#define SYSCFG_MEMRM MMIO32(SYSCFG_BASE + 0x00) + +#define SYSCFG_PMC MMIO32(SYSCFG_BASE + 0x04) + +/* External interrupt configuration registers [0..3] (SYSCFG_EXTICR[1..4]) */ +#define SYSCFG_EXTICR(i) MMIO32(SYSCFG_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_SWPR MMIO32(SYSCFG_BASE + 0x20) + +/* --- SYSCFG_EXTICR Values -------------------------------------------------*/ + +#define SYSCFG_EXTICR_FIELDSIZE 4 + +#endif diff --git a/include/libopencm3/stm32/g4/usart.h b/include/libopencm3/stm32/g4/usart.h new file mode 100644 index 00000000..a4c0474d --- /dev/null +++ b/include/libopencm3/stm32/g4/usart.h @@ -0,0 +1,55 @@ +/** @defgroup usart_defines USART Defines + * + * @brief Defined Constants and Types for the STM32G4xx USART + * + * @ingroup STM32G4xx_defines + * + * @version 1.0.0 + * + * 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 . + */ + +#ifndef LIBOPENCM3_USART_H +#define LIBOPENCM3_USART_H + +#include +#include + +/**@{*/ + +/** @defgroup usart_reg_base USART register base addresses + * Holds all the U(S)ART peripherals supported. + * @{ + */ +#define USART1 USART1_BASE +#define USART2 USART2_BASE +#define USART3 USART3_BASE +#define UART4 UART4_BASE +#define UART5 UART5_BASE +/**@}*/ + +BEGIN_DECLS + +END_DECLS + +/**@}*/ + +#endif + diff --git a/include/libopencm3/stm32/syscfg.h b/include/libopencm3/stm32/syscfg.h index a3c3bfdd..7a7d4756 100644 --- a/include/libopencm3/stm32/syscfg.h +++ b/include/libopencm3/stm32/syscfg.h @@ -38,6 +38,8 @@ # include #elif defined(STM32G0) # include +#elif defined(STM32G4) +# include #elif defined(STM32H7) # include #else diff --git a/include/libopencm3/stm32/usart.h b/include/libopencm3/stm32/usart.h index c6cb5f96..3e835598 100644 --- a/include/libopencm3/stm32/usart.h +++ b/include/libopencm3/stm32/usart.h @@ -40,6 +40,8 @@ # include #elif defined(STM32G0) # include +#elif defined(STM32G4) +# include #elif defined(STM32H7) # include #else diff --git a/lib/stm32/g4/Makefile b/lib/stm32/g4/Makefile index 38423565..bcb3166b 100644 --- a/lib/stm32/g4/Makefile +++ b/lib/stm32/g4/Makefile @@ -37,6 +37,7 @@ ARFLAGS = rcs OBJS += adc.o adc_common_v2.o adc_common_v2_multi.o OBJS += crs_common_all.o +OBJS += crc_common_all.o crc_v2.o OBJS += dac_common_all.o dac_common_v2.o OBJS += dma_common_l1f013.o OBJS += dmamux.o @@ -51,6 +52,7 @@ OBJS += rng_common_v1.o OBJS += spi_common_all.o spi_common_v2.o OBJS += timer_common_all.o timer_common_f0234.o OBJS += quadspi_common_v1.o +OBJS += usart_common_v2.o usart_common_all.o OBJS += usb.o usb_control.o usb_standard.o OBJS += usb_audio.o