From 12efead7992bfacc97a1e731170727a553d4ac29 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 18 Mar 2015 18:03:56 +0100 Subject: [PATCH] nucleo-f334: add GPIO support --- boards/nucleo-f334/Makefile.features | 1 + boards/nucleo-f334/include/periph_conf.h | 53 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/boards/nucleo-f334/Makefile.features b/boards/nucleo-f334/Makefile.features index 6d5c4c629f..a283c65cbe 100644 --- a/boards/nucleo-f334/Makefile.features +++ b/boards/nucleo-f334/Makefile.features @@ -1,4 +1,5 @@ FEATURES_PROVIDED += periph_cpuid +FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += cpp diff --git a/boards/nucleo-f334/include/periph_conf.h b/boards/nucleo-f334/include/periph_conf.h index 891efd49ef..9168aaf099 100644 --- a/boards/nucleo-f334/include/periph_conf.h +++ b/boards/nucleo-f334/include/periph_conf.h @@ -108,6 +108,59 @@ extern "C" { #define SPI_0_MOSI_PORT_CLKEN() (RCC->AHBENR |= RCC_AHBENR_GPIOAEN) /** @} */ +/** + * @brief GPIO configuration + * @{ + */ +#define GPIO_NUMOF 3 +#define GPIO_0_EN 1 +#define GPIO_1_EN 1 +#define GPIO_2_EN 1 +#define GPIO_IRQ_PRIO 1 + +/* IRQ config */ +#define GPIO_IRQ_0 (-1) /* not configured */ +#define GPIO_IRQ_1 (-1) /* not configured */ +#define GPIO_IRQ_2 GPIO_2 +#define GPIO_IRQ_3 (-1) /* not configured */ +#define GPIO_IRQ_4 (-1) /* not configured */ +#define GPIO_IRQ_5 (-1) /* not configured */ +#define GPIO_IRQ_6 (-1) /* not configured */ +#define GPIO_IRQ_7 (-1) /* not configured */ +#define GPIO_IRQ_8 (-1) /* not configured */ +#define GPIO_IRQ_9 (-1) /* not configured */ +#define GPIO_IRQ_10 GPIO_1 +#define GPIO_IRQ_11 (-1) /* not configured */ +#define GPIO_IRQ_12 (-1) /* not configured */ +#define GPIO_IRQ_13 GPIO_0 +#define GPIO_IRQ_14 (-1) /* not configured */ +#define GPIO_IRQ_15 (-1) /* not configured */ + +/* GPIO channel 0 config */ +#define GPIO_0_PORT GPIOC /* Used for user button 1 */ +#define GPIO_0_PIN 13 +#define GPIO_0_CLKEN() (RCC->AHBENR |= RCC_AHBENR_GPIOCEN) +#define GPIO_0_EXTI_CFG1() (SYSCFG->EXTICR[3] &= ~(SYSCFG_EXTICR4_EXTI13)) +#define GPIO_0_EXTI_CFG2() (SYSCFG->EXTICR[3] |= SYSCFG_EXTICR4_EXTI13_PC) +#define GPIO_0_IRQ EXTI15_10_IRQn + +/* GPIO channel 1 config */ +#define GPIO_1_PORT GPIOC +#define GPIO_1_PIN 10 +#define GPIO_1_CLKEN() (RCC->AHBENR |= RCC_AHBENR_GPIOCEN) +#define GPIO_1_EXTI_CFG1() (SYSCFG->EXTICR[2] &= ~(SYSCFG_EXTICR3_EXTI10)) +#define GPIO_1_EXTI_CFG2() (SYSCFG->EXTICR[2] |= SYSCFG_EXTICR3_EXTI10_PC) +#define GPIO_1_IRQ EXTI15_10_IRQn + +/* GPIO channel 2 config */ +#define GPIO_2_PORT GPIOD +#define GPIO_2_PIN 2 +#define GPIO_2_CLKEN() (RCC->AHBENR |= RCC_AHBENR_GPIODEN) +#define GPIO_2_EXTI_CFG1() (SYSCFG->EXTICR[0] &= ~(SYSCFG_EXTICR1_EXTI2)) +#define GPIO_2_EXTI_CFG2() (SYSCFG->EXTICR[0] |= SYSCFG_EXTICR1_EXTI2_PD) +#define GPIO_2_IRQ EXTI2_TSC_IRQn + +/** @} */ #ifdef __cplusplus }