From ab284959f391335b4848b576aa9a540e6f2c5967 Mon Sep 17 00:00:00 2001 From: Mateusz Myalski Date: Sun, 20 Oct 2024 12:58:33 +0200 Subject: [PATCH] Added Exti support --- include/libopencm3/stm32/exti.h | 2 + include/libopencm3/stm32/u5/exti.h | 56 +++++++++++++++++++++++++ include/libopencm3/stm32/u5/memorymap.h | 6 +-- lib/stm32/u5/Makefile | 1 + 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 include/libopencm3/stm32/u5/exti.h diff --git a/include/libopencm3/stm32/exti.h b/include/libopencm3/stm32/exti.h index 0a6df03f..f6ea39de 100644 --- a/include/libopencm3/stm32/exti.h +++ b/include/libopencm3/stm32/exti.h @@ -40,6 +40,8 @@ # include #elif defined(STM32L4) # include +#elif defined(STM32U5) +# include #elif defined(STM32G0) # include #elif defined(STM32H7) diff --git a/include/libopencm3/stm32/u5/exti.h b/include/libopencm3/stm32/u5/exti.h new file mode 100644 index 00000000..22874c05 --- /dev/null +++ b/include/libopencm3/stm32/u5/exti.h @@ -0,0 +1,56 @@ +/** @defgroup exti_defines EXTI Defines + * + * @brief Defined Constants and Types for the STM32U5xx External Interrupts + * + * + * @ingroup STM32U5xx_defines + * + * @version 1.0.0 + * + * @date 20 October 2024 + * + * LGPL License Terms @ref lgpl_license + */ +/* + * 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_EXTI_H +#define LIBOPENCM3_EXTI_H +/**@{*/ + +#include +#include + + +/** EXTI External Interrupt Selection Registers */ +#define EXTI_EXTICR(i) MMIO32(EXTI_BASE + 0x60 + (i)*4) +#define EXTI_EXTICR1 MMIO32(EXTI_BASE + 0x60) +#define EXTI_EXTICR2 MMIO32(EXTI_BASE + 0x64) +#define EXTI_EXTICR3 MMIO32(EXTI_BASE + 0x68) +#define EXTI_EXTICR4 MMIO32(EXTI_BASE + 0x6c) + +/** EXTI Rising Edge Pending Register */ +#define EXTI_RPR1 MMIO32(EXTI_BASE + 0x0c) +/** EXTI Falling Edge Pending Register */ +#define EXTI_FPR1 MMIO32(EXTI_BASE + 0x10) + + +/**@}*/ + +#endif diff --git a/include/libopencm3/stm32/u5/memorymap.h b/include/libopencm3/stm32/u5/memorymap.h index c5289ba4..507dd0f7 100644 --- a/include/libopencm3/stm32/u5/memorymap.h +++ b/include/libopencm3/stm32/u5/memorymap.h @@ -158,7 +158,7 @@ /* PERIPH_BASE_AHB2 + 0xC800 (0x4202 C800 - 0x4203 FFFF): Reserved */ #define OTG_FS_BASE (PERIPH_BASE_AHB2 + 0x20000U) #define OTG_HS_BASE (PERIPH_BASE_AHB2 + 0x20000U) -#define AES AES_BASE (PERIPH_BASE_AHB2 + 0xA0000U) +#define AES_BASE (PERIPH_BASE_AHB2 + 0xA0000U) #define HASH_BASE (PERIPH_BASE_AHB2 + 0xA0400U) #define RNG_BASE (PERIPH_BASE_AHB2 + 0xA0800U) #define SAES_BASE (PERIPH_BASE_AHB2 + 0xA0C00U) @@ -190,7 +190,7 @@ #define SYSCFG_BASE (PERIPH_BASE_APB3 + 0x0000U) /* PERIPH_BASE_APB3 + 0x0400 (0x4600 0800 - 0x4600 1FFF): Reserved */ #define SPI3_BASE (PERIPH_BASE_APB3 + 0x1C00U) -#define LPUART1_BASE PERIPH_BASE_APB3 + 0x2000U) +#define LPUART1_BASE (PERIPH_BASE_APB3 + 0x2000U) #define I2C3_BASE (PERIPH_BASE_APB3 + 0x2400U) /* PERIPH_BASE_APB3 + 0x2800 (0x4600 2C00 - 0x4600 43FF): Reserved */ #define LPTIM1_BASE (PERIPH_BASE_APB3 + 0x4000U) @@ -212,7 +212,7 @@ #define ADC4_BASE (PERIPH_BASE_AHB3 + 0x1000U) /* PERIPH_BASE_AHB3 + 0x1400 (0x4602 1400 - 0x4602 17FF): Reserved */ #define DAC1_BASE (PERIPH_BASE_AHB3 + 0x1800U) -/* PERIPH_BASE_AHB3 + 0x1C00 ( 0x4602 1C00 - 0x4602 1FFF): Reserved */ +/* PERIPH_BASE_AHB3 + 0x1C00 (0x4602 1C00 - 0x4602 1FFF): Reserved */ #define EXTI_BASE (PERIPH_BASE_AHB3 + 0x2000U) /* PERIPH_BASE_AHB3 + 0x2400 (0x4602 2400 - 0x4602 2FFF): Reserved */ #define GTZC2_TZSC_BASE (PERIPH_BASE_AHB3 + 0x3000U) diff --git a/lib/stm32/u5/Makefile b/lib/stm32/u5/Makefile index 1b0bbec2..f61f5acc 100644 --- a/lib/stm32/u5/Makefile +++ b/lib/stm32/u5/Makefile @@ -35,6 +35,7 @@ TGT_CFLAGS += $(STANDARD_FLAGS) ARFLAGS = rcs +OBJS += exti_common_all.o OBJS += iwdg_common_all.o OBJS += i2c_common_v2.o OBJS += usart_common_all.o usart_common_v2.o