1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-27 15:31:17 +01:00

cpu/stm32l1: adjusted to changed GPIO interface

This commit is contained in:
Hauke Petersen 2015-06-03 18:26:20 +02:00
parent 6284bbbbe4
commit 480d3c68d8
2 changed files with 47 additions and 31 deletions

View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2015 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup cpu_stm32l1
* @{
*
* @file
* @brief CPU specific definitions for internal peripheral handling
*
* @author Hauke Petersen <hauke.peterse@fu-berlin.de>
*/
#ifndef PERIPH_CPU_H_
#define PERIPH_CPU_H_
#include "periph/dev_enums.h"
#ifdef __cplusplus
extern "C" {
#endif
/* nothing defined here, yet */
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CPU_H_ */
/** @} */

View File

@ -24,9 +24,6 @@
#include "periph/gpio.h"
#include "periph_conf.h"
/* guard file in case no GPIO devices are defined */
#if GPIO_NUMOF
typedef struct {
gpio_cb_t cb;
void *arg;
@ -190,7 +187,7 @@ static const IRQn_Type gpio_irq_map[GPIO_NUMOF] = {
#endif
};
int gpio_init_out(gpio_t dev, gpio_pp_t pullup)
int gpio_init(gpio_t dev, gpio_dir_t dir, gpio_pp_t pullup)
{
GPIO_TypeDef *port;
uint8_t pin;
@ -202,36 +199,22 @@ int gpio_init_out(gpio_t dev, gpio_pp_t pullup)
port = gpio_port_map[dev];
pin = gpio_pin_map[dev];
port->MODER &= ~(2 << (2 * pin)); /* set pin to output mode */
port->MODER |= (1 << (2 * pin));
port->OTYPER &= ~(1 << pin); /* set to push-pull configuration */
port->OSPEEDR |= (3 << (2 * pin)); /* set to high speed */
if (dir == GPIO_DIR_OUT) {
port->MODER &= ~(2 << (2 * pin)); /* set pin to output mode */
port->MODER |= (1 << (2 * pin));
port->OTYPER &= ~(1 << pin); /* set to push-pull configuration */
port->OSPEEDR |= (3 << (2 * pin)); /* set to high speed */
port->ODR &= ~(1 << pin); /* set pin to low signal */
}
else {
port->MODER &= ~(3 << (2 * pin)); /* configure pin as input */
}
port->PUPDR &= ~(3 << (2 * pin)); /* configure push-pull resistors */
port->PUPDR |= (pullup << (2 * pin));
port->ODR &= ~(1 << pin); /* set pin to low signal */
return 0; /* all OK */
}
int gpio_init_in(gpio_t dev, gpio_pp_t pullup)
{
GPIO_TypeDef *port;
uint8_t pin;
if (dev >= GPIO_NUMOF) {
return -1;
}
port = gpio_port_map[dev];
pin = gpio_pin_map[dev];
port->MODER &= ~(3 << (2 * pin)); /* configure pin as input */
port->PUPDR &= ~(3 << (2 * pin)); /* configure push-pull resistors */
port->PUPDR |= (pullup << (2 * pin));
return 0; /* everything alright here */
}
int gpio_init_int(gpio_t dev, gpio_pp_t pullup, gpio_flank_t flank, gpio_cb_t cb, void *arg)
{
int res;
@ -244,7 +227,7 @@ int gpio_init_int(gpio_t dev, gpio_pp_t pullup, gpio_flank_t flank, gpio_cb_t cb
pin = gpio_pin_map[dev];
/* configure pin as input */
res = gpio_init_in(dev, pullup);
res = gpio_init(dev, GPIO_DIR_IN, pullup);
if (res < 0) {
return res;
}
@ -583,5 +566,3 @@ void isr_exti15_10(void)
}
}
#endif
#endif /* GPIO_NUMOF */