diff --git a/boards/common/arduino-atmega/Makefile.features b/boards/common/arduino-atmega/Makefile.features index f6143f1abb..3bc938d8f6 100644 --- a/boards/common/arduino-atmega/Makefile.features +++ b/boards/common/arduino-atmega/Makefile.features @@ -1,10 +1,11 @@ # Put defined MCU peripherals here (in alphabetical order) FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_i2c +FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart # Various other features (if any) FEATURES_PROVIDED += arduino -FEATURES_PROVIDED += periph_pwm +FEATURES_PROVIDED += arduino_pwm diff --git a/boards/common/arduino-atmega/include/arduino_board.h b/boards/common/arduino-atmega/include/arduino_board.h index 25b3113250..ee7a018667 100644 --- a/boards/common/arduino-atmega/include/arduino_board.h +++ b/boards/common/arduino-atmega/include/arduino_board.h @@ -23,6 +23,7 @@ #define ARDUINO_BOARD_H #include "arduino_pinmap.h" +#include "periph/pwm.h" #ifdef __cplusplus extern "C" { @@ -141,6 +142,34 @@ static const adc_t arduino_analog_map[] = { #endif }; +/** + * @brief PWM frequency + */ +#define ARDUINO_PWM_FREQU (490U) + +/** + * @brief List of PWM GPIO mappings + */ +static const arduino_pwm_t arduino_pwm_list[] = { +#if defined(CPU_ATMEGA2560) + { .pin = 13, .dev = PWM_DEV(0), .chan = 0 }, + { .pin = 4, .dev = PWM_DEV(0), .chan = 1 }, +#elif defined(CPU_ATMEGA32U4) + { .pin = 11, .dev = PWM_DEV(0), .chan = 0 }, + { .pin = 3, .dev = PWM_DEV(0), .chan = 1 }, +#else /* CPU_ATMEGA328p */ + { .pin = 6, .dev = PWM_DEV(0), .chan = 0 }, + { .pin = 5, .dev = PWM_DEV(0), .chan = 1 }, +#endif +#if defined(CPU_ATMEGA2560) + { .pin = 10, .dev = PWM_DEV(1), .chan = 0 }, + { .pin = 9, .dev = PWM_DEV(1), .chan = 1 }, +#else /* CPU_ATMEGA328p */ + { .pin = 11, .dev = PWM_DEV(1), .chan = 0 }, + { .pin = 3, .dev = PWM_DEV(1), .chan = 1 }, +#endif +}; + #ifdef __cplusplus } #endif