Skip to content

Commit

Permalink
boards/frdm-k22f: Add NXP FRDM-K22F development board
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Nohlgård committed Jul 18, 2017
1 parent 57b32f5 commit 912e497
Show file tree
Hide file tree
Showing 10 changed files with 593 additions and 0 deletions.
1 change: 1 addition & 0 deletions boards/frdm-common/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# set default port depending on operating system
PORT_LINUX ?= /dev/ttyACM0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))

export FFLAGS = flash-elf

Expand Down
3 changes: 3 additions & 0 deletions boards/frdm-k22f/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = board

include $(RIOTBASE)/Makefile.base
4 changes: 4 additions & 0 deletions boards/frdm-k22f/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
USEMODULE += saul_adc
endif
18 changes: 18 additions & 0 deletions boards/frdm-k22f/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_hwrng
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

# Various other features (if any)
FEATURES_PROVIDED += cpp

# The board MPU family (used for grouping by the CI system)
FEATURES_MCU_GROUP = cortex_m4_1
6 changes: 6 additions & 0 deletions boards/frdm-k22f/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# define the cpu used by the board
export CPU = k22f
export CPU_MODEL = mk22fn512vlh12

# Include default FRDM board config
include $(RIOTBOARD)/frdm-common/Makefile.include
68 changes: 68 additions & 0 deletions boards/frdm-k22f/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
* Copyright (C) 2014 PHYTEC Messtechnik GmbH
* Copyright (C) 2017 Eistec AB
*
* 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_frdm-k64f
* @{
*
* @file
* @brief Board specific implementations for the FRDM-K22F
*
* @author Joakim Nohlgård <[email protected]>
*
* @}
*/

#include <stdint.h>
#include "board.h"
#include "mcg.h"
#include "periph/gpio.h"

#define SIM_CLKDIV1_48MHZ (SIM_CLKDIV1_OUTDIV1(0) | \
SIM_CLKDIV1_OUTDIV2(1) | \
SIM_CLKDIV1_OUTDIV3(1) | \
SIM_CLKDIV1_OUTDIV4(1))

static void cpu_clock_init(void);

void board_init(void)
{
/* initialize the clock system */
cpu_clock_init();
/* initialize the CPU core */
cpu_init();

/* 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_set(LED0_PIN);
gpio_set(LED1_PIN);
gpio_set(LED2_PIN);
}

/**
* @brief Configure the controllers clock system
*
* | Clock name | Run mode frequency (max) | VLPR mode frequency (max) |
*
* | Core | 120 MHz | 4 MHz |
* | System | 120 MHz | 4 MHz |
* | Bus | 60 MHz | 4 MHz |
* | FlexBus | 30 MHz | 800 kHz |
* | Flash | 26.67 MHz | 4 MHz |
*/
static void cpu_clock_init(void)
{
/* setup system prescalers */
SIM->CLKDIV1 = (uint32_t)SIM_CLKDIV1_48MHZ;

kinetis_mcg_set_mode(KINETIS_MCG_PEE);
}
81 changes: 81 additions & 0 deletions boards/frdm-k22f/include/adc_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2017 Eistec AB
*
* 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_frdm-k22f
* @{
*
* @file
* @brief Board specific configuration of direct mapped ADC
*
* @author Joakim Nohlgård <[email protected]>
*/

#ifndef ADC_PARAMS_H
#define ADC_PARAMS_H

#include "board.h"
#include "saul/periph.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief ADC configuration
*/
static const saul_adc_params_t saul_adc_params[] =
{
{
.name = "ADC0_DP",
.line = ADC_LINE(0),
.res = ADC_RES_16BIT,
},
{
.name = "ADC0_DM",
.line = ADC_LINE(1),
.res = ADC_RES_16BIT,
},
{
.name = "ADC1_DP",
.line = ADC_LINE(2),
.res = ADC_RES_16BIT,
},
{
.name = "ADC1_DM",
.line = ADC_LINE(3),
.res = ADC_RES_16BIT,
},
{
.name = "A0",
.line = ADC_LINE(4),
.res = ADC_RES_16BIT,
},
{
.name = "A1",
.line = ADC_LINE(5),
.res = ADC_RES_16BIT,
},
{
.name = "A2",
.line = ADC_LINE(6),
.res = ADC_RES_16BIT,
},
{
.name = "A3",
.line = ADC_LINE(7),
.res = ADC_RES_16BIT,
},
};

#ifdef __cplusplus
}
#endif

#endif /* ADC_PARAMS_H */
/** @} */
67 changes: 67 additions & 0 deletions boards/frdm-k22f/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (C) 2017 Eistec AB
*
* 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_frdm-k22f NXP FRDM-K22F Board
* @ingroup boards
* @brief Board specific implementations for the FRDM-K22F
* @{
*
* @file
* @brief Board specific definitions for the FRDM-K22F
*
* @author Joakim Nohlgård <[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, 1)
#define LED1_PIN GPIO_PIN(PORT_A, 2)
#define LED2_PIN GPIO_PIN(PORT_D, 5)

#define LED0_MASK (1 << 1)
#define LED1_MASK (1 << 2)
#define LED2_MASK (1 << 5)

#define LED0_ON (GPIOB->PCOR = LED0_MASK)
#define LED0_OFF (GPIOB->PSOR = LED0_MASK)
#define LED0_TOGGLE (GPIOB->PTOR = LED0_MASK)

#define LED1_ON (GPIOE->PCOR = LED1_MASK)
#define LED1_OFF (GPIOE->PSOR = LED1_MASK)
#define LED1_TOGGLE (GPIOE->PTOR = LED1_MASK)

#define LED2_ON (GPIOB->PCOR = LED2_MASK)
#define LED2_OFF (GPIOB->PSOR = LED2_MASK)
#define LED2_TOGGLE (GPIOB->PTOR = LED2_MASK)
/** @} */

/**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
*/
void board_init(void);

#ifdef __cplusplus
}
#endif

#endif /* BOARD_H */
/** @} */
56 changes: 56 additions & 0 deletions boards/frdm-k22f/include/gpio_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (C) 2017 Eistec AB
*
* 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_frdm_k22f
* @{
*
* @file
* @brief Board specific configuration of direct mapped GPIOs
*
* @author Joakim Nohlgård <[email protected]>
*/

#ifndef GPIO_PARAMS_H
#define GPIO_PARAMS_H

#include "board.h"
#include "saul/periph.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief LED configuration
*/
static const saul_gpio_params_t saul_gpio_params[] =
{
{
.name = "LED(red)",
.pin = LED0_PIN,
.mode = GPIO_OUT
},
{
.name = "LED(green)",
.pin = LED1_PIN,
.mode = GPIO_OUT
},
{
.name = "LED(blue)",
.pin = LED2_PIN,
.mode = GPIO_OUT
},
};

#ifdef __cplusplus
}
#endif

#endif /* GPIO_PARAMS_H */
/** @} */
Loading

0 comments on commit 912e497

Please sign in to comment.