boards/arduino-atmega-common: support for PWM
This commit is contained in:
parent
2ebb187ca9
commit
8ff8aefb72
@ -9,6 +9,7 @@ FEATURES_PROVIDED += periph_uart
|
||||
# Various other features (if any)
|
||||
ifeq (,$(filter jiminy-mega256rfr2,$(BOARD)))
|
||||
FEATURES_PROVIDED += arduino
|
||||
FEATURES_PROVIDED += periph_pwm
|
||||
endif
|
||||
|
||||
# The board MPU family (used for grouping by the CI system)
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
#ifndef PERIPH_CONF_H
|
||||
#define PERIPH_CONF_H
|
||||
|
||||
#include "periph_cpu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -163,6 +165,46 @@ extern "C" {
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name PWM configuration
|
||||
*
|
||||
* The current implementation supports only 8-bit timers for PWM generation.
|
||||
* These timers are typically timer 0 and timer 2 in Atmega2560/1281/328p.
|
||||
*
|
||||
* Setting the first channel to GPIO_UNDEF allows multiple resolutions for the
|
||||
* PWM channel. Otherwise the resolution is fixed to 256, allowing duty cycle
|
||||
* values ranging from 0 to 255.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#if defined(CPU_ATMEGA328P)
|
||||
#define PWM_PINS_CH0 { GPIO_PIN(PORT_D, 6), GPIO_PIN(PORT_D, 5) }
|
||||
#define PWM_PINS_CH1 { GPIO_PIN(PORT_B, 3), GPIO_PIN(PORT_D, 3) }
|
||||
|
||||
#elif defined(CPU_ATMEGA2560)
|
||||
#define PWM_PINS_CH0 { GPIO_PIN(PORT_B, 7), GPIO_PIN(PORT_G, 5) }
|
||||
#define PWM_PINS_CH1 { GPIO_PIN(PORT_B, 4), GPIO_PIN(PORT_H, 6) }
|
||||
|
||||
#elif defined(CPU_ATMEGA1281)
|
||||
#define PWM_PINS_CH0 { GPIO_PIN(PORT_B, 7), GPIO_PIN(PORT_G, 5) }
|
||||
#define PWM_PINS_CH1 { GPIO_PIN(PORT_B, 4), GPIO_UNDEF }
|
||||
#endif
|
||||
|
||||
static const pwm_conf_t pwm_conf[] = {
|
||||
{
|
||||
.dev = MINI_TIMER0,
|
||||
.pin_ch = PWM_PINS_CH0,
|
||||
.div = MINI_TIMER0_DIV,
|
||||
},
|
||||
{
|
||||
.dev = MINI_TIMER2,
|
||||
.pin_ch = PWM_PINS_CH1,
|
||||
.div = MINI_TIMER2_DIV,
|
||||
}
|
||||
};
|
||||
#define PWM_NUMOF (sizeof(pwm_conf) / sizeof(pwm_conf[0]))
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
BOARD ?= samr21-xpro
|
||||
include ../Makefile.tests_common
|
||||
|
||||
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno
|
||||
|
||||
FEATURES_REQUIRED = periph_pwm
|
||||
|
||||
USEMODULE += xtimer
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user