diff --git a/boards/samr21-xpro/Makefile.features b/boards/samr21-xpro/Makefile.features index 266ab83dda..064eed1bd8 100644 --- a/boards/samr21-xpro/Makefile.features +++ b/boards/samr21-xpro/Makefile.features @@ -1,11 +1,15 @@ FEATURES_PROVIDED += transceiver + +FEATURES_PROVIDED += cpp + FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_spi -FEATURES_PROVIDED += cpp FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_cpuid +FEATURES_PROVIDED += periph_pwm + FEATURES_MCU_GROUP = cortex_m0 diff --git a/boards/samr21-xpro/include/periph_conf.h b/boards/samr21-xpro/include/periph_conf.h index 9fd0850aa1..ef2daf0bcc 100644 --- a/boards/samr21-xpro/include/periph_conf.h +++ b/boards/samr21-xpro/include/periph_conf.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Freie Universität Berlin + * Copyright (C) 2014-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 @@ -15,12 +15,16 @@ * Pro board * * @author Thomas Eichinger - * @author Hauke Petersen s + * @author Hauke Petersen + * @author Peter Kietzmann */ #ifndef __PERIPH_CONF_H #define __PERIPH_CONF_H +#include +#include "cpu.h" + #ifdef __cplusplus extern "C" { #endif @@ -112,6 +116,60 @@ extern "C" { #define UART_0_PINS (PORT_PA04 | PORT_PA05) /** @} */ +/** + * @name PWM configuration + * @{ + */ +#define PWM_NUMOF (PWM_0_EN + PWM_1_EN) +#define PWM_0_EN 1 +#define PWM_1_EN 1 +#define PWM_MAX_CHANNELS 2 +/* for compatibility with test application */ +#define PWM_0_CHANNELS PWM_MAX_CHANNELS +#define PWM_1_CHANNELS PWM_MAX_CHANNELS + +/** + * @brief PWM channel configuration data structure + * + * TODO: this should be moved into the CPU folder + */ +typedef struct { + PortGroup *port; /**< GPIO port */ + uint8_t pin; /**< GPIO pin */ + uint8_t fnct; /**< pin function multiplex value */ + uint8_t chan; /**< TCC channel to use */ +} pwm_conf_chan_t; + +/** + * @brief PWM device configuration data structure + * + * TODO: this should be moved into the CPU folder + */ +typedef struct { + Tcc *dev; /*< TCC device to use */ + pwm_conf_chan_t chan[2]; /**< channel configuration */ +} pwm_conf_t; + +/* PWM device configuration */ +#if PWM_NUMOF +static const pwm_conf_t pwm_config[] = { +#if PWM_0_EN + {TCC1, { + /* port , pin, AF, chan */ + {(PortGroup *)0x41004400, 6, 4, 0}, + {(PortGroup *)0x41004400, 7, 4, 1} + }}, +#endif +#if PWM_1_EN + {TCC0, { + /* port , pin, AF, chan */ + {(PortGroup *)0x41004400, 18, 5, 2}, + {(PortGroup *)0x41004400, 19, 5, 3} + }}, +#endif +}; +#endif +/** @} */ /** * @name SPI configuration @@ -241,8 +299,8 @@ extern "C" { #define GPIO_2_PIN (15) #define GPIO_2_EXTINT (15) /* GPIO channel 3 config */ -#define GPIO_3_DEV PORT->Group[0] -#define GPIO_3_PIN (19) +#define GPIO_3_DEV PORT->Group[1] +#define GPIO_3_PIN (3) #define GPIO_3_EXTINT (3) /* GPIO 4-7 Internal radio pins*/ /* GPIO channel 4 config radio CS*/