Skip to content

Commit

Permalink
boards: support for KEA128LEDLIGHTRD board
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Gerasimov <[email protected]>
  • Loading branch information
Anton Gerasimov authored and OYTIS committed Aug 5, 2018
1 parent 1c4ee98 commit 1c92821
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 0 deletions.
3 changes: 3 additions & 0 deletions boards/kea128ledlightrd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = board

include $(RIOTBASE)/Makefile.base
11 changes: 11 additions & 0 deletions boards/kea128ledlightrd/Makefile.dep
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions boards/kea128ledlightrd/Makefile.features
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions boards/kea128ledlightrd/Makefile.include
Original file line number Diff line number Diff line change
@@ -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
66 changes: 66 additions & 0 deletions boards/kea128ledlightrd/board.c
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
* @author Anton Gerasimov <[email protected]>
*
* @}
*/

#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);
}
2 changes: 2 additions & 0 deletions boards/kea128ledlightrd/dist/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Kinetis KE series CPUs
source [find target/ke0x.cfg]
84 changes: 84 additions & 0 deletions boards/kea128ledlightrd/include/board.h
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
* @author Anton Gerasimov <[email protected]>
*/

#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 */
/** @} */
76 changes: 76 additions & 0 deletions boards/kea128ledlightrd/include/periph_conf.h
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
* @author Anton Gerasimov <[email protected]>
*/

#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 */
/** @} */

0 comments on commit 1c92821

Please sign in to comment.