stm32l4: add gpio support
Just the basic core common functionality gained for free by being a common peripheral. Enough for a miniblink. Fixes some errors in the GPIO memory map. ST's naming of AHB2 vs AHB3 is confusing.
This commit is contained in:
parent
8afc983f3e
commit
f14c678ccb
@ -19,10 +19,15 @@ INPUT = ../../include/libopencm3/license.dox
|
|||||||
INPUT +=../../include/libopencm3/stm32/l4
|
INPUT +=../../include/libopencm3/stm32/l4
|
||||||
#INPUT +=../../include/libopencm3/stm32/common
|
#INPUT +=../../include/libopencm3/stm32/common
|
||||||
INPUT +=../../include/libopencm3/stm32/common/rcc_common_all.h
|
INPUT +=../../include/libopencm3/stm32/common/rcc_common_all.h
|
||||||
|
INPUT +=../../include/libopencm3/stm32/common/gpio_common_all.h
|
||||||
|
INPUT +=../../include/libopencm3/stm32/common/gpio_common_f234.h
|
||||||
|
INPUT +=../../include/libopencm3/stm32/common/gpio_common_f24.h
|
||||||
|
|
||||||
INPUT +=../../lib/stm32/l4
|
INPUT +=../../lib/stm32/l4
|
||||||
#INPUT +=../../lib/stm32/common
|
#INPUT +=../../lib/stm32/common
|
||||||
INPUT +=../../lib/stm32/common/rcc_common_all.c
|
INPUT +=../../lib/stm32/common/rcc_common_all.c
|
||||||
|
INPUT +=../../lib/stm32/common/gpio_common_all.c
|
||||||
|
INPUT +=../../lib/stm32/common/gpio_common_f0234.c
|
||||||
|
|
||||||
# No headers to exclude until we include some!
|
# No headers to exclude until we include some!
|
||||||
EXCLUDE =
|
EXCLUDE =
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
# include <libopencm3/stm32/l0/gpio.h>
|
# include <libopencm3/stm32/l0/gpio.h>
|
||||||
#elif defined(STM32L1)
|
#elif defined(STM32L1)
|
||||||
# include <libopencm3/stm32/l1/gpio.h>
|
# include <libopencm3/stm32/l1/gpio.h>
|
||||||
|
#elif defined(STM32L4)
|
||||||
|
# include <libopencm3/stm32/l4/gpio.h>
|
||||||
#else
|
#else
|
||||||
# error "stm32 family not defined."
|
# error "stm32 family not defined."
|
||||||
#endif
|
#endif
|
||||||
|
89
include/libopencm3/stm32/l4/gpio.h
Normal file
89
include/libopencm3/stm32/l4/gpio.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/** @defgroup gpio_defines GPIO Defines
|
||||||
|
*
|
||||||
|
* @brief <b>Defined Constants and Types for the STM32L4xx General Purpose I/O</b>
|
||||||
|
*
|
||||||
|
* @ingroup STM32L4xx_defines
|
||||||
|
*
|
||||||
|
* @version 1.0.0
|
||||||
|
*
|
||||||
|
* @date 12 November 2015
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LIBOPENCM3_GPIO_H
|
||||||
|
#define LIBOPENCM3_GPIO_H
|
||||||
|
|
||||||
|
#include <libopencm3/stm32/common/gpio_common_f24.h>
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Module definitions */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Register definitions */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define GPIO_BRR(port) MMIO32((port) + 0x28)
|
||||||
|
#define GPIOA_BRR GPIO_BRR(GPIOA)
|
||||||
|
#define GPIOB_BRR GPIO_BRR(GPIOB)
|
||||||
|
#define GPIOC_BRR GPIO_BRR(GPIOC)
|
||||||
|
#define GPIOD_BRR GPIO_BRR(GPIOD)
|
||||||
|
#define GPIOE_BRR GPIO_BRR(GPIOE)
|
||||||
|
#define GPIOF_BRR GPIO_BRR(GPIOF)
|
||||||
|
#define GPIOG_BRR GPIO_BRR(GPIOG)
|
||||||
|
#define GPIOH_BRR GPIO_BRR(GPIOH)
|
||||||
|
|
||||||
|
#define GPIO_ASC(port) MMIO32((port) + 0x2c)
|
||||||
|
#define GPIOA_ASC GPIO_ASC(GPIOA)
|
||||||
|
#define GPIOB_ASC GPIO_ASC(GPIOB)
|
||||||
|
#define GPIOC_ASC GPIO_ASC(GPIOC)
|
||||||
|
#define GPIOD_ASC GPIO_ASC(GPIOD)
|
||||||
|
#define GPIOE_ASC GPIO_ASC(GPIOE)
|
||||||
|
#define GPIOF_ASC GPIO_ASC(GPIOF)
|
||||||
|
#define GPIOG_ASC GPIO_ASC(GPIOG)
|
||||||
|
#define GPIOH_ASC GPIO_ASC(GPIOH)
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Register values */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/** @defgroup gpio_speed GPIO Output Pin Speed
|
||||||
|
@ingroup gpio_defines
|
||||||
|
@{*/
|
||||||
|
#define GPIO_OSPEED_LOW 0x0
|
||||||
|
#define GPIO_OSPEED_MED 0x1
|
||||||
|
#define GPIO_OSPEED_FAST 0x2
|
||||||
|
#define GPIO_OSPEED_HIGH 0x3
|
||||||
|
/**@}*/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* API definitions */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* API Functions */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
BEGIN_DECLS
|
||||||
|
|
||||||
|
END_DECLS
|
||||||
|
|
||||||
|
#endif
|
@ -32,7 +32,7 @@
|
|||||||
#define PERIPH_BASE_APB1 (PERIPH_BASE + 0x00000)
|
#define PERIPH_BASE_APB1 (PERIPH_BASE + 0x00000)
|
||||||
#define PERIPH_BASE_APB2 (PERIPH_BASE + 0x10000)
|
#define PERIPH_BASE_APB2 (PERIPH_BASE + 0x10000)
|
||||||
#define PERIPH_BASE_AHB1 (PERIPH_BASE + 0x20000)
|
#define PERIPH_BASE_AHB1 (PERIPH_BASE + 0x20000)
|
||||||
#define PERIPH_BASE_AHB2 (PERIPH_BASE + 0x80000)
|
#define PERIPH_BASE_AHB2 (0x48000000U)
|
||||||
|
|
||||||
/* Register boundary addresses */
|
/* Register boundary addresses */
|
||||||
|
|
||||||
@ -93,10 +93,10 @@
|
|||||||
#define TSC_BASE (PERIPH_BASE_AHB1 + 0x4000)
|
#define TSC_BASE (PERIPH_BASE_AHB1 + 0x4000)
|
||||||
|
|
||||||
/* AHB2 */
|
/* AHB2 */
|
||||||
#define GPIO_PORT_A_BASE (PERIPH_BASE_AHB2 + 0x00000)
|
#define GPIO_PORT_A_BASE (PERIPH_BASE_AHB2 + 0x0000)
|
||||||
#define GPIO_PORT_B_BASE (PERIPH_BASE_AHB2 + 0x00000)
|
#define GPIO_PORT_B_BASE (PERIPH_BASE_AHB2 + 0x0400)
|
||||||
#define GPIO_PORT_C_BASE (PERIPH_BASE_AHB2 + 0x00000)
|
#define GPIO_PORT_C_BASE (PERIPH_BASE_AHB2 + 0x0800)
|
||||||
#define GPIO_PORT_D_BASE (PERIPH_BASE_AHB2 + 0x00000)
|
#define GPIO_PORT_D_BASE (PERIPH_BASE_AHB2 + 0x0c00)
|
||||||
#define GPIO_PORT_E_BASE (PERIPH_BASE_AHB2 + 0x1000)
|
#define GPIO_PORT_E_BASE (PERIPH_BASE_AHB2 + 0x1000)
|
||||||
#define GPIO_PORT_F_BASE (PERIPH_BASE_AHB2 + 0x1400)
|
#define GPIO_PORT_F_BASE (PERIPH_BASE_AHB2 + 0x1400)
|
||||||
#define GPIO_PORT_G_BASE (PERIPH_BASE_AHB2 + 0x1800)
|
#define GPIO_PORT_G_BASE (PERIPH_BASE_AHB2 + 0x1800)
|
||||||
|
@ -41,6 +41,7 @@ OBJS =
|
|||||||
|
|
||||||
# common/shared objs
|
# common/shared objs
|
||||||
OBJS += rcc_common_all.o
|
OBJS += rcc_common_all.o
|
||||||
|
OBJS += gpio_common_all.o gpio_common_f0234.o
|
||||||
|
|
||||||
VPATH += ../../usb:../:../../cm3:../common
|
VPATH += ../../usb:../:../../cm3:../common
|
||||||
VPATH += ../../ethernet
|
VPATH += ../../ethernet
|
||||||
|
Loading…
x
Reference in New Issue
Block a user