Skip to content
Permalink
Browse files

boards: twr-ke18f: add support for the NXP TWR-KE18F board

Add support for the NXP TWR-KE18F development board. This board
feautures an NXP MKE18F16 MCU, a selection of user LEDs and
push-buttons, potentiometer, thermistor, CAN interface, and FlexIO
header.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
  • Loading branch information...
henrikbrixandersen authored and MaureenHelm committed May 7, 2019
1 parent 918579e commit 105aef98bf80279e9896502ad28c9d5f959a0d9e
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0

if(CONFIG_PINMUX_MCUX)
zephyr_library()
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
zephyr_library_sources(pinmux.c)
endif()
@@ -0,0 +1,15 @@
# Kconfig - TWR-KE18F board configuration
#
# Copyright (c) 2019 Vestas Wind Systems A/S
#
# SPDX-License-Identifier: Apache-2.0

if BOARD_TWR_KE18F

config BOARD_TWR_KE18F_FLEXIO_CLKOUT
bool "Enable CLKOUT signal on FlexIO header"
depends on PINMUX_MCUX_PORTE
help
Enable the CLKOUT signal on FlexIO header pin 7 (PTE10).

endif #BOARD_TWR_KE18F
@@ -0,0 +1,10 @@
# Kconfig - TWR-KE18F board configuration
#
# Copyright (c) 2019 Vestas Wind Systems A/S
#
# SPDX-License-Identifier: Apache-2.0

config BOARD_TWR_KE18F
bool "NXP TWR-KE18F"
depends on SOC_SERIES_KINETIS_KE1XF
select SOC_PART_NUMBER_MKE18F512VLL16
@@ -0,0 +1,58 @@
# Kconfig - TWR-KE18F board
#
# Copyright (c) 2019 Vestas Wind Systems A/S
#
# SPDX-License-Identifier: Apache-2.0
#

if BOARD_TWR_KE18F

config BOARD
default "twr_ke18f"

if UART_MCUX_LPUART

config UART_MCUX_LPUART_0
default y if UART_CONSOLE

endif # UART_MCUX_LPUART

if PINMUX_MCUX

config PINMUX_MCUX_PORTA
default y

config PINMUX_MCUX_PORTB
default y

config PINMUX_MCUX_PORTC
default y

config PINMUX_MCUX_PORTD
default y

config PINMUX_MCUX_PORTE
default y

endif # PINMUX_MCUX

if GPIO_MCUX

config GPIO_MCUX_PORTA
default y

config GPIO_MCUX_PORTB
default y

config GPIO_MCUX_PORTC
default y

config GPIO_MCUX_PORTD
default y

config GPIO_MCUX_PORTE
default y

endif # GPIO_MCUX

endif # BOARD_TWR_KE18F
@@ -0,0 +1,18 @@
# SPDX-License-Identifier: Apache-2.0

set_ifndef(OPENSDA_FW daplink)

if(OPENSDA_FW STREQUAL jlink)
set_ifndef(BOARD_DEBUG_RUNNER jlink)
set_ifndef(BOARD_FLASH_RUNNER jlink)
elseif(OPENSDA_FW STREQUAL daplink)
set_ifndef(BOARD_DEBUG_RUNNER pyocd)
set_ifndef(BOARD_FLASH_RUNNER pyocd)
endif()

board_runner_args(jlink "--device=MKE18F512xxx16")
board_runner_args(pyocd "--target=ke18f16")

include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
Binary file not shown.
@@ -0,0 +1,207 @@
.. _twr_ke18f:

NXP TWR-KE18F
#############

Overview
********

The TWR-KE18F is a development board for NXP Kinetis KE1xF 32-bit
MCU-based platforms. The onboard OpenSDAv2 serial and debug adapter,
running an open source bootloader, offers options for serial
communication, flash programming, and run-control debugging.

.. figure:: ./TWR-KE18F-DEVICE.jpg
:width: 800px
:align: center
:alt: TWR-KE18F

TWR-KE18F (Credit: NXP)

Hardware
********

- MKE18F512VLL16 MCU (up to 168 MHz, 512 KB flash memory, 64 KB RAM,
and 100 Low profile Quad Flat Package (LQFP))
- 3.3 V or 5 V MCU operation
- 6-axis FXOS8700CQ digital accelerometer and magnetometer
- RGB LED
- Four user LEDs
- Two user push-buttons
- Potentiometer
- Thermistor
- Infrared port (IrDA)
- CAN pin header
- Flex I/O pin header

For more information about the KE1xF SoC and the TWR-KE18F board, see
these NXP reference documents:

- `KE1xF Website`_
- `KE1xF Datasheet`_
- `KE1xF Reference Manual`_
- `TWR-KE18F Website`_
- `TWR-KE18F User Guide`_
- `TWR-KE18F Schematics`_

Supported Features
==================

The twr_ke18f board configuration supports the following hardware
features:

+-----------+------------+-------------------------------------+
| Interface | Controller | Driver/Component |
+===========+============+=====================================+
| NVIC | on-chip | nested vector interrupt controller |
+-----------+------------+-------------------------------------+
| SYSTICK | on-chip | systick |
+-----------+------------+-------------------------------------+
| PINMUX | on-chip | pinmux |
+-----------+------------+-------------------------------------+
| GPIO | on-chip | gpio |
+-----------+------------+-------------------------------------+
| UART | on-chip | serial port-polling; |
| | | serial port-interrupt |
+-----------+------------+-------------------------------------+
| FLASH | on-chip | soc flash |
+-----------+------------+-------------------------------------+

The default configuration can be found in the defconfig file:
``boards/arm/twr_ke18f/twr_ke18f_defconfig``.

Other hardware features are not currently supported by the port.

System Clock
============

The KE18 SoC is configured to use the 8 MHz external oscillator on the
board with the on-chip PLL to generate a 120 MHz system clock.

Serial Port
===========

The KE18 SoC has three UARTs. UART0 is configured for the console. The
remaining UARTs are not used.

Programming and Debugging
*************************

Build and flash applications as usual (see :ref:`build_an_application` and
:ref:`application_run` for more details).

Configuring a Debug Probe
=========================

A debug probe is used for both flashing and debugging the board. This board is
configured by default to use the :ref:`opensda-daplink-onboard-debug-probe`.

Early versions of this board have an outdated version of the OpenSDA bootloader
and require an update. Please see the `DAPLink Bootloader Update`_ page for
instructions to update from the CMSIS-DAP bootloader to the DAPLink bootloader.

Option 1: :ref:`opensda-daplink-onboard-debug-probe` (Recommended)
------------------------------------------------------------------

Install the :ref:`pyocd-debug-host-tools` and make sure they are in your search
path.

Follow the instructions in :ref:`opensda-daplink-onboard-debug-probe` to program
the `OpenSDA DAPLink TWR-KE18F Firmware`_.

Option 2: :ref:`opensda-jlink-onboard-debug-probe`
--------------------------------------------------

Install the :ref:`jlink-debug-host-tools` and make sure they are in your search
path.

Follow the instructions in :ref:`opensda-jlink-onboard-debug-probe` to program
the `OpenSDA J-Link Firmware for TWR-KE18F`_.

Add the argument ``-DOPENSDA_FW=jlink`` when you invoke ``cmake`` or ``west
build`` to override the default runner from pyOCD to J-Link:

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: twr_ke18f
:gen-args: -DOPENSDA_FW=jlink
:goals: build

Configuring a Console
=====================

Regardless of your choice in debug probe, we will use the OpenSDA
microcontroller as a usb-to-serial adapter for the serial console.

Connect a USB cable from your PC to J2.

Use the following settings with your serial terminal of choice (minicom, putty,
etc.):

- Speed: 115200
- Data: 8 bits
- Parity: None
- Stop bits: 1

Flashing
========

Here is an example for the :ref:`hello_world` application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: twr_ke18f
:goals: flash

Open a serial terminal, reset the board (press the SW1 button), and you should
see the following message in the terminal:

.. code-block:: console

***** Booting Zephyr OS v1.14.0-xxx-gxxxxxxxxxxxx *****
Hello World! twr_ke18f

Debugging
=========

Here is an example for the :ref:`hello_world` application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: twr_ke18f
:goals: debug

Open a serial terminal, step through the application in your debugger, and you
should see the following message in the terminal:

.. code-block:: console

***** Booting Zephyr OS v1.14.0-xxx-gxxxxxxxxxxxx *****
Hello World! twr_ke18f

.. _TWR-KE18F Website:
https://www.nxp.com/TWR-KE18F

.. _TWR-KE18F User Guide:
https://www.nxp.com/docs/en/user-guide/TWRKE18FUG.pdf

.. _TWR-KE18F Schematics:
https://www.nxp.com/webapp/Download?colCode=TWR-KE18F-SCH-DESIGNFILES

.. _KE1xF Website:
https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/kinetis-cortex-m-mcus/e-series5v-robustm0-plus-m4/kinetis-ke1xf-168mhz-performance-with-can-5v-microcontrollers-based-on-arm-cortex-m4:KE1xF

.. _KE1xF Datasheet:
https://www.nxp.com/docs/en/data-sheet/KE1xFP100M168SF0.pdf

.. _KE1xF Reference Manual:
https://www.nxp.com/docs/en/reference-manual/KE1xFP100M168SF0RM.pdf

.. _DAPLink Bootloader Update:
https://os.mbed.com/blog/entry/DAPLink-bootloader-update/

.. _OpenSDA DAPLink TWR-KE18F Firmware:
https://www.nxp.com/support/developer-resources/run-time-software/kinetis-developer-resources/ides-for-kinetis-mcus/opensda-serial-and-debug-adapter:OPENSDA#TWR-KE18F

.. _OpenSDA J-Link Firmware for TWR-KE18F:
https://www.segger.com/downloads/jlink/OpenSDA_TWR-KE18F
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2019 Vestas Wind Systems A/S
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <init.h>
#include <pinmux.h>
#include <fsl_port.h>

static int twr_ke18f_pinmux_init(struct device *dev)
{
ARG_UNUSED(dev);

#ifdef CONFIG_PINMUX_MCUX_PORTA
__unused struct device *porta =
device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME);
#endif
#ifdef CONFIG_PINMUX_MCUX_PORTB
__unused struct device *portb =
device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME);
#endif
#ifdef CONFIG_PINMUX_MCUX_PORTC
__unused struct device *portc =
device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME);
#endif
#ifdef CONFIG_PINMUX_MCUX_PORTD
__unused struct device *portd =
device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME);
#endif

#ifdef CONFIG_PINMUX_MCUX_PORTE
__unused struct device *porte =
device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME);
#endif

/* LEDs */
pinmux_pin_set(portb, 5, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 11, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 12, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 13, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 15, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 16, PORT_PCR_MUX(kPORT_MuxAsGpio));

/* Buttons */
pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 6, PORT_PCR_MUX(kPORT_MuxAsGpio));

#ifdef CONFIG_UART_MCUX_LPUART_0
/* UART0 RX, TX */
pinmux_pin_set(portb, 0, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portb, 1, PORT_PCR_MUX(kPORT_MuxAlt2));
#endif

#ifdef CONFIG_BOARD_TWR_KE18F_FLEXIO_CLKOUT
/* CLKOUT */
pinmux_pin_set(porte, 10, PORT_PCR_MUX(kPORT_MuxAlt2));
#endif

return 0;
}

SYS_INIT(twr_ke18f_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);

0 comments on commit 105aef9

Please sign in to comment.
You can’t perform that action at this time.