1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 06:53:52 +01:00

boards: ikea-tradfri: add support for board.

This commit is contained in:
Bas Stottelaar 2017-11-15 23:39:39 +01:00
parent db214508cb
commit c51948ce9c
8 changed files with 335 additions and 0 deletions

View File

@ -0,0 +1,4 @@
# tell the Makefile.base which module to build
MODULE = board
include $(RIOTBASE)/Makefile.base

View File

@ -0,0 +1,5 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
include $(RIOTCPU)/efr32mg1p/Makefile.dep

View File

@ -0,0 +1,12 @@
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_gpio
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_m4_2
include $(RIOTCPU)/efr32mg1p/Makefile.features

View File

@ -0,0 +1,14 @@
# define the cpu used by ikea-tradfri
export CPU = efr32mg1p
export CPU_MODEL = efr32mg1p132f256gm32
# set default port depending on operating system
PORT_LINUX ?= /dev/ttyACM0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
# setup JLink for flashing
export JLINK_DEVICE := EFR32MG1PxxxF256
include $(RIOTMAKE)/tools/jlink.inc.mk
# setup serial terminal
include $(RIOTMAKE)/tools/serial.inc.mk

View File

@ -0,0 +1,32 @@
/*
* Copyright (C) 2017 Bas Stottelaar <basstottelaar@gmail.com>
*
* 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_ikea-tradfri
* @{
*
* @file
* @brief Board specific implementations IKEA TRÅDFRI modules
*
* @author Bas Stottelaar <basstottelaar@gmail.com>
*
* @}
*/
#include "board.h"
#include "cpu.h"
void board_init(void)
{
/* initialize the CPU */
cpu_init();
/* initialize the LEDs */
gpio_init(LED0_PIN, GPIO_OUT);
gpio_init(LED1_PIN, GPIO_OUT);
}

View File

@ -0,0 +1,74 @@
/*
* Copyright (C) 2017 Bas Stottelaar <basstottelaar@gmail.com>
*
* 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_ikea-tradfri IKEA TRÅDFRI modules
* @ingroup boards
* @brief Support for the IKEA TRÅDFRI modules
* @{
*
* @file
* @brief Board specific definitions for the IKEA TRÅDFRI modules
*
* @author Bas Stottelaar <basstottelaar@gmail.com>
*/
#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 LED pin definitions
* @{
*/
#define LED0_PIN GPIO_PIN(PA, 1)
#define LED1_PIN GPIO_PIN(PB, 13)
/** @} */
/**
* @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 */
/** @} */

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2017 Bas Stottelaar <basstottelaar@gmail.com>
*
* 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_ikea-tradfri
* @{
*
* @file
* @brief Board specific configuration of direct mapped GPIOs
*
* @author Bas Stottelaar <basstottelaar@gmail.com>
*/
#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
}
};
#ifdef __cplusplus
}
#endif
#endif /* GPIO_PARAMS_H */
/** @} */

View File

@ -0,0 +1,143 @@
/*
* Copyright (C) 2017 Bas Stottelaar <basstottelaar@gmail.com>
*
* 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_ikea-tradfri
* @{
*
* @file
* @brief Configuration of CPU peripherals for the IKEA TRÅDFRI modules
*
* @author Bas Stottelaar <basstottelaar@gmail.com>
*/
#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_HFRCO
#endif
#ifndef CLOCK_CORE_DIV
#define CLOCK_CORE_DIV cmuClkDiv_1
#endif
#ifndef CLOCK_LFA
#define CLOCK_LFA cmuSelect_LFRCO
#endif
#ifndef CLOCK_LFB
#define CLOCK_LFB cmuSelect_LFRCO
#endif
#ifndef CLOCK_LFE
#define CLOCK_LFE cmuSelect_LFRCO
#endif
/** @} */
/**
* @brief RTC configuration
*/
#define RTC_NUMOF (1U)
/**
* @name RTT configuration
* @{
*/
#define RTT_NUMOF (1U)
#define RTT_MAX_VALUE (0xFFFFFFFF)
#define RTT_FREQUENCY (1U)
/** @} */
/**
* @name SPI configuration
* @{
*/
static const spi_dev_t spi_config[] = {
{
.dev = USART1,
.mosi_pin = GPIO_PIN(PD, 15),
.miso_pin = GPIO_PIN(PD, 14),
.clk_pin = GPIO_PIN(PD, 13),
.loc = USART_ROUTELOC0_RXLOC_LOC21 |
USART_ROUTELOC0_TXLOC_LOC23 |
USART_ROUTELOC0_CLKLOC_LOC19,
.cmu = cmuClock_USART1,
.irq = USART1_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 = USART0,
.rx_pin = GPIO_PIN(PB, 15),
.tx_pin = GPIO_PIN(PB, 14),
.loc = USART_ROUTELOC0_RXLOC_LOC9 |
USART_ROUTELOC0_TXLOC_LOC9,
.cmu = cmuClock_USART0,
.irq = USART0_RX_IRQn
}
};
#define UART_NUMOF PERIPH_NUMOF(uart_config)
#define UART_0_ISR_RX isr_usart0_rx
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CONF_H */
/** @} */