From 6f39d673b29df6002f1d86073bb559a9d74bfd6d Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Mon, 5 Feb 2018 23:44:23 +0100 Subject: [PATCH] boards: stk3700: add support. --- boards/stk3700/Makefile | 5 + boards/stk3700/Makefile.dep | 8 + boards/stk3700/Makefile.features | 16 ++ boards/stk3700/Makefile.include | 22 +++ boards/stk3700/board.c | 32 ++++ boards/stk3700/include/board.h | 93 +++++++++ boards/stk3700/include/gpio_params.h | 63 +++++++ boards/stk3700/include/periph_conf.h | 272 +++++++++++++++++++++++++++ 8 files changed, 511 insertions(+) create mode 100644 boards/stk3700/Makefile create mode 100644 boards/stk3700/Makefile.dep create mode 100644 boards/stk3700/Makefile.features create mode 100644 boards/stk3700/Makefile.include create mode 100644 boards/stk3700/board.c create mode 100644 boards/stk3700/include/board.h create mode 100644 boards/stk3700/include/gpio_params.h create mode 100644 boards/stk3700/include/periph_conf.h diff --git a/boards/stk3700/Makefile b/boards/stk3700/Makefile new file mode 100644 index 0000000000..39108f4589 --- /dev/null +++ b/boards/stk3700/Makefile @@ -0,0 +1,5 @@ +MODULE = board + +DIRS = $(RIOTBOARD)/common/silabs + +include $(RIOTBASE)/Makefile.base diff --git a/boards/stk3700/Makefile.dep b/boards/stk3700/Makefile.dep new file mode 100644 index 0000000000..db6255ce96 --- /dev/null +++ b/boards/stk3700/Makefile.dep @@ -0,0 +1,8 @@ +ifneq (,$(filter saul_default,$(USEMODULE))) + USEMODULE += saul_gpio +endif + +# include board common dependencies +include $(RIOTBOARD)/common/silabs/Makefile.dep + +include $(RIOTCPU)/efm32/Makefile.dep diff --git a/boards/stk3700/Makefile.features b/boards/stk3700/Makefile.features new file mode 100644 index 0000000000..6872fee4e2 --- /dev/null +++ b/boards/stk3700/Makefile.features @@ -0,0 +1,16 @@ +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_adc +FEATURES_PROVIDED += periph_dac +FEATURES_PROVIDED += periph_gpio +FEATURES_PROVIDED += periph_i2c +FEATURES_PROVIDED += periph_pwm +FEATURES_PROVIDED += periph_rtc +FEATURES_PROVIDED += periph_rtt +FEATURES_PROVIDED += periph_spi +FEATURES_PROVIDED += periph_timer +FEATURES_PROVIDED += periph_uart + +# The board MPU family (used for grouping by the CI system) +FEATURES_MCU_GROUP = cortex_m3_2 + +include $(RIOTCPU)/efm32/Makefile.features diff --git a/boards/stk3700/Makefile.include b/boards/stk3700/Makefile.include new file mode 100644 index 0000000000..94deb04cc0 --- /dev/null +++ b/boards/stk3700/Makefile.include @@ -0,0 +1,22 @@ +# define the cpu used by STK3700 +export CPU = efm32 +export CPU_MODEL = efm32gg990f1024 + +# set default port depending on operating system +PORT_LINUX ?= /dev/ttyACM0 +PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) + +# setup serial terminal +include $(RIOTMAKE)/tools/serial.inc.mk + +# setup JLink for flashing +export JLINK_DEVICE := $(CPU_MODEL) +include $(RIOTMAKE)/tools/jlink.inc.mk + +# add board common drivers +USEMODULE += boards_common_silabs +USEMODULE += silabs_aem +USEMODULE += silabs_bc + +# include board common +include $(RIOTBOARD)/common/silabs/Makefile.include diff --git a/boards/stk3700/board.c b/boards/stk3700/board.c new file mode 100644 index 0000000000..de838de006 --- /dev/null +++ b/boards/stk3700/board.c @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2015-2018 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 boards_stk3700 + * @{ + * + * @file + * @brief Board specific implementations STK3700 board + * + * @author Hauke Petersen + * @author Bas Stottelaar + * + * @} + */ + +#include "board.h" +#include "board_common.h" + +void board_init(void) +{ + /* initialize the CPU */ + cpu_init(); + + /* perform common board initialization */ + board_common_init(); +} diff --git a/boards/stk3700/include/board.h b/boards/stk3700/include/board.h new file mode 100644 index 0000000000..403afc6b80 --- /dev/null +++ b/boards/stk3700/include/board.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2015-2018 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. + */ + +/** + * @defgroup boards_stk3700 Silicon Labs STK3700 starter kit + * @ingroup boards + * @brief Support for the Silicon Labs STK3700 starter kit + * @{ + * + * @file + * @brief Board specific definitions for the STK3700 starter kit + * + * @author Hauke Petersen + * @author Bas Stottelaar + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "cpu.h" + +#include "periph_conf.h" +#include "periph/gpio.h" +#include "periph/spi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Xtimer configuration + * + * The timer runs at 250 KHz to increase accuracy. + * @{ + */ +#define XTIMER_HZ (250000UL) +#define XTIMER_WIDTH (16) +/** @} */ + +/** + * @name Board controller configuration + * + * Define the GPIO pin to enable the BC, to allow serial communication + * via the USB port. + * @{ + */ +#define BC_PIN GPIO_PIN(PF, 7) +/** @} */ + +/** + * @name Push button pin definitions + * @{ + */ +#define PB0_PIN GPIO_PIN(PB, 9) +#define PB1_PIN GPIO_PIN(PB, 10) +/** @} */ + +/** + * @name LED pin definitions + * @{ + */ +#define LED0_PIN GPIO_PIN(PE, 2) +#define LED1_PIN GPIO_PIN(PE, 3) +/** @} */ + +/** + * @name Macros for controlling the on-board LEDs + * @{ + */ +#define LED0_ON gpio_set(LED0_PIN) +#define LED0_OFF gpio_clear(LED0_PIN) +#define LED0_TOGGLE gpio_toggle(LED0_PIN) +#define LED1_ON gpio_set(LED1_PIN) +#define LED1_OFF gpio_clear(LED1_PIN) +#define LED1_TOGGLE gpio_toggle(LED1_PIN) +/** @} */ + +/** + * @brief Initialize the board (GPIO, sensors, clocks). + */ +void board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/stk3700/include/gpio_params.h b/boards/stk3700/include/gpio_params.h new file mode 100644 index 0000000000..c577e417b7 --- /dev/null +++ b/boards/stk3700/include/gpio_params.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2016-2017 Bas Stottelaar + * + * 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 boards_stk3700 + * @{ + * + * @file + * @brief Board specific configuration of direct mapped GPIOs + * + * @author Bas Stottelaar + */ + +#ifndef GPIO_PARAMS_H +#define GPIO_PARAMS_H + +#include "board.h" +#include "saul/periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief GPIO pin configuration + */ +static const saul_gpio_params_t saul_gpio_params[] = +{ + { + .name = "LED 0", + .pin = LED0_PIN, + .mode = GPIO_OUT + }, + { + .name = "LED 1", + .pin = LED1_PIN, + .mode = GPIO_OUT + }, + { + .name = "Button 1", + .pin = PB0_PIN, + .mode = GPIO_IN_PU, + .flags = SAUL_GPIO_INVERTED + }, + { + .name = "Button 2", + .pin = PB1_PIN, + .mode = GPIO_IN_PU, + .flags = SAUL_GPIO_INVERTED + } +}; + +#ifdef __cplusplus +} +#endif + +#endif /* GPIO_PARAMS_H */ +/** @} */ diff --git a/boards/stk3700/include/periph_conf.h b/boards/stk3700/include/periph_conf.h new file mode 100644 index 0000000000..2babb66454 --- /dev/null +++ b/boards/stk3700/include/periph_conf.h @@ -0,0 +1,272 @@ +/* + * Copyright (C) 2015-2018 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 boards_stk3700 + * @{ + * + * @file + * @brief Configuration of CPU peripherals for the STK3700 starter kit + * + * @author Hauke Petersen + * @author Bas Stottelaar + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#include "cpu.h" + +#include "periph_cpu.h" + +#include "em_cmu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Internal macro to calculate *_NUMOF based on config. + */ +#define PERIPH_NUMOF(config) (sizeof(config) / sizeof(config[0])) + +/** + * @name Clock configuration + * @{ + */ +#ifndef CLOCK_HF +#define CLOCK_HF cmuSelect_HFXO +#endif +#ifndef CLOCK_CORE_DIV +#define CLOCK_CORE_DIV cmuClkDiv_1 +#endif +#ifndef CLOCK_LFA +#define CLOCK_LFA cmuSelect_LFXO +#endif +#ifndef CLOCK_LFB +#define CLOCK_LFB cmuSelect_LFXO +#endif +/** @} */ + +/** + * @name ADC configuration + * @{ + */ +static const adc_conf_t adc_config[] = { + { + .dev = ADC0, + .cmu = cmuClock_ADC0, + } +}; + +static const adc_chan_conf_t adc_channel_config[] = { + { + .dev = 0, + .input = adcSingleInputTemp, + .reference = adcRef1V25, + .acq_time = adcAcqTime8 + }, + { + .dev = 0, + .input = adcSingleInputVDDDiv3, + .reference = adcRef1V25, + .acq_time = adcAcqTime8 + } +}; + +#define ADC_DEV_NUMOF PERIPH_NUMOF(adc_config) +#define ADC_NUMOF PERIPH_NUMOF(adc_channel_config) +/** @} */ + +/** + * @name DAC configuration + * @{ + */ +static const dac_conf_t dac_config[] = { + { + .dev = DAC0, + .cmu = cmuClock_DAC0, + } +}; + +static const dac_chan_conf_t dac_channel_config[] = { + { + .dev = 0, + .index = 1, + .ref = dacRefVDD, + } +}; + +#define DAC_DEV_NUMOF PERIPH_NUMOF(dac_config) +#define DAC_NUMOF PERIPH_NUMOF(dac_channel_config) +/** @} */ + +/** + * @name I2C configuration + * @{ + */ +static const i2c_conf_t i2c_config[] = { + { + .dev = I2C0, + .sda_pin = GPIO_PIN(PD, 6), + .scl_pin = GPIO_PIN(PD, 7), + .loc = I2C_ROUTE_LOCATION_LOC1, + .cmu = cmuClock_I2C0, + .irq = I2C0_IRQn + }, + { + .dev = I2C1, + .sda_pin = GPIO_PIN(PC, 4), + .scl_pin = GPIO_PIN(PC, 5), + .loc = I2C_ROUTE_LOCATION_LOC0, + .cmu = cmuClock_I2C1, + .irq = I2C1_IRQn + } +}; + +#define I2C_NUMOF PERIPH_NUMOF(i2c_config) +#define I2C_0_ISR isr_i2c0 +#define I2C_1_ISR isr_i2c1 +/** @} */ + +/** + * @name PWM configuration + * @{ + */ +static const pwm_chan_conf_t pwm_channel_config[] = { + { + .index = 2, + .pin = GPIO_PIN(PE, 2), + .loc = TIMER_ROUTE_LOCATION_LOC1 + } +}; + +static const pwm_conf_t pwm_config[] = { + { + .dev = TIMER3, + .cmu = cmuClock_TIMER3, + .irq = TIMER3_IRQn, + .channels = 1, + .channel = pwm_channel_config + } +}; + +#define PWM_DEV_NUMOF PERIPH_NUMOF(pwm_config) +#define PWM_NUMOF PERIPH_NUMOF(pwm_channel_config) +/** @} */ + +/** + * @brief RTC configuration + */ +#define RTC_NUMOF (1U) + +/** + * @name RTT configuration + * @{ + */ +#define RTT_NUMOF (1U) + +#define RTT_MAX_VALUE (0xFFFFFF) +#define RTT_FREQUENCY (1U) +/** @} */ + +/** + * @name SPI configuration + * @{ + */ +static const spi_dev_t spi_config[] = { + { + .dev = USART1, + .mosi_pin = GPIO_PIN(PD, 0), + .miso_pin = GPIO_PIN(PD, 1), + .clk_pin = GPIO_PIN(PD, 2), + .loc = USART_ROUTE_LOCATION_LOC1, + .cmu = cmuClock_USART1, + .irq = USART1_RX_IRQn + }, + { + .dev = USART2, + .mosi_pin = GPIO_UNDEF, + .miso_pin = GPIO_PIN(PC, 3), + .clk_pin = GPIO_PIN(PC, 4), + .loc = USART_ROUTE_LOCATION_LOC0, + .cmu = cmuClock_USART2, + .irq = USART2_RX_IRQn + } +}; + +#define SPI_NUMOF PERIPH_NUMOF(spi_config) +/** @} */ + +/** + * @name Timer configuration + * + * The implementation uses two timers in cascade mode. + * @{ + */ +static const timer_conf_t timer_config[] = { + { + { + .dev = TIMER0, + .cmu = cmuClock_TIMER0 + }, + { + .dev = TIMER1, + .cmu = cmuClock_TIMER1 + }, + .irq = TIMER1_IRQn + } +}; + +#define TIMER_NUMOF PERIPH_NUMOF(timer_config) +#define TIMER_0_ISR isr_timer1 +/** @} */ + +/** + * @name UART configuration + * @{ + */ +static const uart_conf_t uart_config[] = { + { + .dev = UART0, + .rx_pin = GPIO_PIN(PE, 1), + .tx_pin = GPIO_PIN(PE, 0), + .loc = UART_ROUTE_LOCATION_LOC1, + .cmu = cmuClock_UART0, + .irq = UART0_RX_IRQn + }, + { + .dev = USART1, + .rx_pin = GPIO_PIN(PD, 1), + .tx_pin = GPIO_PIN(PD, 0), + .loc = USART_ROUTE_LOCATION_LOC1, + .cmu = cmuClock_USART1, + .irq = USART1_RX_IRQn + }, + { + .dev = LEUART0, + .rx_pin = GPIO_PIN(PD, 5), + .tx_pin = GPIO_PIN(PD, 4), + .loc = LEUART_ROUTE_LOCATION_LOC0, + .cmu = cmuClock_LEUART0, + .irq = LEUART0_IRQn + } +}; + +#define UART_NUMOF PERIPH_NUMOF(uart_config) +#define UART_0_ISR_RX isr_uart0_rx +#define UART_1_ISR_RX isr_usart1_rx +#define UART_2_ISR_RX isr_leuart0 +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* PERIPH_CONF_H */ +/** @} */