diff --git a/boards/kea128ledlightrd/Makefile b/boards/kea128ledlightrd/Makefile new file mode 100644 index 0000000000000..f8fcbb53a0659 --- /dev/null +++ b/boards/kea128ledlightrd/Makefile @@ -0,0 +1,3 @@ +MODULE = board + +include $(RIOTBASE)/Makefile.base diff --git a/boards/kea128ledlightrd/Makefile.dep b/boards/kea128ledlightrd/Makefile.dep new file mode 100644 index 0000000000000..0ed44e3e8681e --- /dev/null +++ b/boards/kea128ledlightrd/Makefile.dep @@ -0,0 +1,11 @@ +ifneq (,$(filter can,$(USEMODULE))) + USEMODULE += periph_mscan + CFLAGS += -DCAN_DLL_NUMOF=1 +endif + +USEMODULE += rtt_stdio + +# setup clock to run at 40MHz +CFLAGS += -DCLOCK_SETUP=1 + +include $(RIOTCPU)/kinetis/Makefile.dep diff --git a/boards/kea128ledlightrd/Makefile.features b/boards/kea128ledlightrd/Makefile.features new file mode 100644 index 0000000000000..aee4e93482ab1 --- /dev/null +++ b/boards/kea128ledlightrd/Makefile.features @@ -0,0 +1,7 @@ +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_timer + +# The board MPU family (used for grouping by the CI system) +FEATURES_MCU_GROUP = cortex_m0+ + +include $(RIOTCPU)/kinetis/Makefile.features diff --git a/boards/kea128ledlightrd/Makefile.include b/boards/kea128ledlightrd/Makefile.include new file mode 100644 index 0000000000000..7e9bff5b11679 --- /dev/null +++ b/boards/kea128ledlightrd/Makefile.include @@ -0,0 +1,8 @@ +# define the cpu used by the KEA128LEDLIGHTRD board +export CPU = kinetis +export CPU_MODEL = s9keaz128aclh48 + +DEBUG_ADAPTER ?= arm-jtag-swd +OPENOCD_CONFIG ?= ${RIOTBOARD}/kea128ledlightrd/dist/openocd.cfg + +include ${RIOTMAKE}/tools/openocd.inc.mk diff --git a/boards/kea128ledlightrd/board.c b/boards/kea128ledlightrd/board.c new file mode 100644 index 0000000000000..ad04197665110 --- /dev/null +++ b/boards/kea128ledlightrd/board.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2014 Freie Universität Berlin + * Copyright (C) 2014 PHYTEC Messtechnik GmbH + * + * 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_kea128ledlightrd + * @{ + * + * @file + * @brief Board specific implementations for the KEA128LEDLIGHTRD + * + * @author Johann Fischer + * @author Anton Gerasimov + * + * @} + */ + +#include "board.h" +#include "periph/gpio.h" +#include "tja1042.h" + +extern void SystemInit(void); + +#ifdef MODULE_CAN_KEA_MSCAN + +static tja1042_trx_t tja1042 = { + .trx.driver = &tja1042_driver, + .stb_pin = GPIO_PIN(PORT_A, 24), +}; + +const candev_kea_conf_t candev_kea_config[] = { + { + .clock_freq = CLOCK_BUSCLOCK / 2, + .params.name = "can0", + .params.trx = (can_trx_t *)&tja1042, + }, +}; + +#endif + +void board_init(void) +{ + /* initialize clocks */ + SystemInit(); + + /* initialize the CPU core */ + cpu_init(); + + /* disable NMI on the pin used for LED2 */ + SIM->SOPT0 &= (~SIM_SOPT0_NMIE_MASK); + + /* initialize and turn off the on-board RGB-LED */ + gpio_init(LED0_PIN, GPIO_OUT); + gpio_init(LED1_PIN, GPIO_OUT); + gpio_init(LED2_PIN, GPIO_OUT); + gpio_init(LED3_PIN, GPIO_OUT); + gpio_set(LED0_PIN); + gpio_set(LED1_PIN); + gpio_set(LED2_PIN); + gpio_set(LED3_PIN); +} diff --git a/boards/kea128ledlightrd/dist/openocd.cfg b/boards/kea128ledlightrd/dist/openocd.cfg new file mode 100644 index 0000000000000..90ada01274c8a --- /dev/null +++ b/boards/kea128ledlightrd/dist/openocd.cfg @@ -0,0 +1,2 @@ +# Kinetis KE series CPUs +source [find target/ke0x.cfg] diff --git a/boards/kea128ledlightrd/include/board.h b/boards/kea128ledlightrd/include/board.h new file mode 100644 index 0000000000000..221382c54dc0c --- /dev/null +++ b/boards/kea128ledlightrd/include/board.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2014 Freie Universität Berlin + * Copyright (C) 2015 PHYTEC Messtechnik GmbH + * + * 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_kea128ledlightrd NXP/Freescale KEA128LEDLIGHTRD Board + * @ingroup boards + * @brief Support for the NXP KEA128LEDLIGHTRD + * @{ + * + * @file + * @brief Board specific definitions for the KEA128LEDLIGHTRD + * + * @author Johann Fischer + * @author Anton Gerasimov + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "cpu.h" +#include "periph_conf.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @name LED pin definitions and handlers + * @{ + */ +#define LED0_PIN GPIO_PIN(PORT_A, 10) +#define LED1_PIN GPIO_PIN(PORT_A, 11) +#define LED2_PIN GPIO_PIN(PORT_A, 12) +#define LED3_PIN GPIO_PIN(PORT_A, 13) + +#define LED0_MASK (1 << 10) +#define LED1_MASK (1 << 11) +#define LED2_MASK (1 << 12) +#define LED3_MASK (1 << 13) + +#define LED0_ON (GPIOA->PCOR = LED0_MASK) +#define LED0_OFF (GPIOA->PSOR = LED0_MASK) +#define LED0_TOGGLE (GPIOA->PTOR = LED0_MASK) + +#define LED1_ON (GPIOA->PCOR = LED1_MASK) +#define LED1_OFF (GPIOA->PSOR = LED1_MASK) +#define LED1_TOGGLE (GPIOA->PTOR = LED1_MASK) + +#define LED2_ON (GPIOA->PCOR = LED2_MASK) +#define LED2_OFF (GPIOA->PSOR = LED2_MASK) +#define LED2_TOGGLE (GPIOA->PTOR = LED2_MASK) + +#define LED3_ON (GPIOA->PCOR = LED3_MASK) +#define LED3_OFF (GPIOA->PSOR = LED3_MASK) +#define LED3_TOGGLE (GPIOA->PTOR = LED3_MASK) + +/** @} */ + +/** + * @name xtimer configuration + * @{ + */ +#define XTIMER_DEV (TIMER_PIT_DEV(0)) +#define XTIMER_CHAN (0) +/** @} */ + +/** + * @brief Initialize board specific hardware, including clock, LEDs and std-IO + */ +void board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/kea128ledlightrd/include/periph_conf.h b/boards/kea128ledlightrd/include/periph_conf.h new file mode 100644 index 0000000000000..14e6c16bf6b2b --- /dev/null +++ b/boards/kea128ledlightrd/include/periph_conf.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2014 Freie Universität Berlin + * Copyright (C) 2015 PHYTEC Messtechnik GmbH + * Copyright (C) 2018 HERE Deutschland GmbH + * + * 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_kea128ledlightrd + * @{ + * + * @file + * @name Peripheral MCU configuration for KEA128LEDLIGHTRD + * + * @author Johann Fischer + * @author Anton Gerasimov + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#include "periph_cpu.h" + +#ifdef MODULE_CAN_KEA_MSCAN +#include "mscan.h" +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define CLOCK_CORECLOCK (40000000ul) +#define CLOCK_BUSCLOCK (CLOCK_CORECLOCK / 1) +/** @} */ + +/** + * @name Timer configuration + * @{ + */ +#define PIT_NUMOF (2U) +#define LPTMR_NUMOF (0U) +#define PIT_CONFIG { \ + { \ + .prescaler_ch = 0, \ + .count_ch = 1, \ + }, \ + { \ + .prescaler_ch = 2, \ + .count_ch = 3, \ + }, \ +} +#define TIMER_NUMOF ((PIT_NUMOF)) + +#define PIT_BASECLOCK (CLOCK_BUSCLOCK) +#define PIT_ISR_0 isr_pit1 +#define PIT_ISR_1 isr_pit3 +/** @} */ + +#ifdef MODULE_CAN_KEA_MSCAN +/** + * @name CAN configuration + * @{ + */ + +extern const candev_kea_conf_t candev_kea_config[]; +#endif +#ifdef __cplusplus +} +#endif + +#endif /* PERIPH_CONF_H */ +/** @} */