From 4894bf9763430c805566f40c371b13340a40becd Mon Sep 17 00:00:00 2001 From: iosabi Date: Sat, 28 Nov 2020 23:44:15 +0000 Subject: [PATCH] boards/qn9080dk: New board for the QN908x The QN9080DK is the developer board reference from NXP for the QN908x CPUs. The developer kit comes with two boards: a larger PCB with many peripherals and a much smaller "USB dongle". This board adds initial support for the larger "DK board". At the moment, with the minimal CPU support this board only configures the GPIOs available in the board, namely the RGB LED and the two user buttons. --- boards/qn9080dk/Kconfig | 22 ++++++++ boards/qn9080dk/Makefile | 6 +++ boards/qn9080dk/Makefile.dep | 3 ++ boards/qn9080dk/Makefile.features | 8 +++ boards/qn9080dk/Makefile.include | 2 + boards/qn9080dk/board.c | 37 ++++++++++++++ boards/qn9080dk/doc.txt | 62 ++++++++++++++++++++++ boards/qn9080dk/include/board.h | 69 +++++++++++++++++++++++++ boards/qn9080dk/include/gpio_params.h | 71 ++++++++++++++++++++++++++ boards/qn9080dk/include/periph_conf.h | 49 ++++++++++++++++++ cpu/qn908x/include/vendor/fsl_common.h | 44 ++++++++++++++++ 11 files changed, 373 insertions(+) create mode 100644 boards/qn9080dk/Kconfig create mode 100644 boards/qn9080dk/Makefile create mode 100644 boards/qn9080dk/Makefile.dep create mode 100644 boards/qn9080dk/Makefile.features create mode 100644 boards/qn9080dk/Makefile.include create mode 100644 boards/qn9080dk/board.c create mode 100644 boards/qn9080dk/doc.txt create mode 100644 boards/qn9080dk/include/board.h create mode 100644 boards/qn9080dk/include/gpio_params.h create mode 100644 boards/qn9080dk/include/periph_conf.h create mode 100644 cpu/qn908x/include/vendor/fsl_common.h diff --git a/boards/qn9080dk/Kconfig b/boards/qn9080dk/Kconfig new file mode 100644 index 0000000000000..4612fdc8a644b --- /dev/null +++ b/boards/qn9080dk/Kconfig @@ -0,0 +1,22 @@ +# Copyright (c) 2020 iosabi +# +# 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. +# + +config BOARD + default "qn9080dk" if BOARD_QN9080DK + +config BOARD_QN9080DK + bool + default y + select BOARD_COMMON_QN908X + select CPU_MODEL_QN9080XHN + + # Put defined MCU peripherals here (in alphabetical order) + select BOARD_HAS_XTAL + #select BOARD_XTAL + select BOARD_HAS_XTAL32K + +source "$(RIOTBOARD)/common/qn908x/Kconfig" diff --git a/boards/qn9080dk/Makefile b/boards/qn9080dk/Makefile new file mode 100644 index 0000000000000..f25f4d547bd23 --- /dev/null +++ b/boards/qn9080dk/Makefile @@ -0,0 +1,6 @@ +MODULE = board + +# Use the common qn908x board. +DIRS += $(RIOTBOARD)/common/qn908x + +include $(RIOTBASE)/Makefile.base diff --git a/boards/qn9080dk/Makefile.dep b/boards/qn9080dk/Makefile.dep new file mode 100644 index 0000000000000..5472bf8b8d8fd --- /dev/null +++ b/boards/qn9080dk/Makefile.dep @@ -0,0 +1,3 @@ +ifneq (,$(filter saul_default,$(USEMODULE))) + USEMODULE += saul_gpio +endif diff --git a/boards/qn9080dk/Makefile.features b/boards/qn9080dk/Makefile.features new file mode 100644 index 0000000000000..e79116aff73cd --- /dev/null +++ b/boards/qn9080dk/Makefile.features @@ -0,0 +1,8 @@ +CPU = qn908x +CPU_MODEL = qn9080xhn + +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_gpio periph_gpio_irq + +# Include the common qn908x board features. +include $(RIOTBOARD)/common/qn908x/Makefile.features diff --git a/boards/qn9080dk/Makefile.include b/boards/qn9080dk/Makefile.include new file mode 100644 index 0000000000000..6c7465ed81bbd --- /dev/null +++ b/boards/qn9080dk/Makefile.include @@ -0,0 +1,2 @@ +# Include default QN908x board config +include $(RIOTBOARD)/common/qn908x/Makefile.include diff --git a/boards/qn9080dk/board.c b/boards/qn9080dk/board.c new file mode 100644 index 0000000000000..d74d9ddf8257e --- /dev/null +++ b/boards/qn9080dk/board.c @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 iosabi + * + * 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_qn9080dk + * @{ + * + * @file + * @brief Board specific implementations for the QN9080DK base board + * + * @author iosabi + * + * @} + */ + +#include "cpu.h" +#include "board.h" + +#include "periph/gpio.h" + +void board_init(void) +{ + /* Initialize LEDs and Buttons. */ + gpio_init(LED_RED_PIN, GPIO_OUT); + gpio_init(LED_GREEN_PIN, GPIO_OUT); + gpio_init(LED_BLUE_PIN, GPIO_OUT); + gpio_init(BTN1_PIN, BTN1_MODE); + gpio_init(BTN2_PIN, BTN2_MODE); + + /* initialize the CPU */ + cpu_init(); +} diff --git a/boards/qn9080dk/doc.txt b/boards/qn9080dk/doc.txt new file mode 100644 index 0000000000000..faf0de5aa10ea --- /dev/null +++ b/boards/qn9080dk/doc.txt @@ -0,0 +1,62 @@ +/** +@defgroup boards_qn9080dk QN9080DK base board +@ingroup boards +@brief Support for the QN9080DK base board. + +### General information + +The QN9080DK is the developer board reference from NXP for the QN908x CPUs. +The developer kit comes with two boards: a larger PCB with a QFN "module" +including a QN9080DHN soldered onto it, altogether referred as the "base +board"; and separately a much smaller USB dongle with another QN9080 cpu. +This board module supports the "base board" only, including the definitions +of the gpio, buttons and LEDs specific to this board. + +This board packs a few peripherals and many GPIOs: + + * MMA8652FC, a 12-bit accelerometer + * + +The board also features a dedicated programmer hardware implemented using NXP's +LPC4322, with its dedicated USB port for connecting to a computer on one end +and the SWD port and one UART RX/TX pair connected to the QN9080 on the other +end. The LPC4322 also has a fast (50 ksps) ADC ADC122S021 connected to a +current sense amplifier to monitor the QN9080 current profile directly on +the board. + +For more information visit NXP's product description page for the +[QN9080-DK](https://www.nxp.com/QN9080DK) where you can find the User's +Guide. + +### User Interface + +Buttons: + +| Label | RIOT OS macro | MCU PIN | Function | +|:----- |:------------- |:-------- |:--------- | +| SW1 | BTN1_PIN | PA24 | User defined | +| SW2 | BTN2_PIN | PA19 | User defined | +| SW3 | | nRESET | QN9080 reset | + + +One RGB led, controlled by three GPIOs + +| Label | RIOT OS macro | MCU PIN | +|:----- |:------------- |:-------- | +| red | LED_RED_PIN | PA31 | +| green | LED_GREEN_PIN | PA25 | +| blue | LED_BLUE_PIN | PA13 | + +### Pinout + +Button1: + +### Flash the board + +The board can be flashed using the internal LPC4322 JTAG/SWD debugger or an +external debugger connected to P1, selected using JP2. + +OpenOCD support for the QN908x is experimental and available as pending +[patch](http://openocd.zylin.com/#/c/5584/). + + */ diff --git a/boards/qn9080dk/include/board.h b/boards/qn9080dk/include/board.h new file mode 100644 index 0000000000000..421536c7c77f0 --- /dev/null +++ b/boards/qn9080dk/include/board.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2020 iosabi + * + * 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_qn9080dk + * @{ + * + * @file + * @brief Board specific definitions for the QN9080DK base board + * + * @author iosabi + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "cpu.h" +#include "periph_conf.h" +#include "periph_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Clock configuration + * @{ + */ +#ifndef CLOCK_CORECLOCK +/* Using 32MHz internal oscillator as default clock source */ +#define CLOCK_CORECLOCK (32000000ul) +#endif +/** @} */ + +/** + * @name LED configuration + * @{ + */ +#define LED_RED_PIN GPIO_PIN(PORT_A, 31) +#define LED_GREEN_PIN GPIO_PIN(PORT_A, 25) +#define LED_BLUE_PIN GPIO_PIN(PORT_A, 13) +/** @} */ + +/** + * @name User buttons + * @{ + */ +#define BTN1_PIN GPIO_PIN(PORT_A, 24) +#define BTN1_MODE GPIO_IN_PU +#define BTN2_PIN GPIO_PIN(PORT_A, 19) +#define BTN2_MODE GPIO_IN_PU +/** @} */ + +/** + * @brief Initialize board specific hardware + */ +void board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/qn9080dk/include/gpio_params.h b/boards/qn9080dk/include/gpio_params.h new file mode 100644 index 0000000000000..365a33d8d5375 --- /dev/null +++ b/boards/qn9080dk/include/gpio_params.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2020 iosabi + * + * 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_qn9080dk + * @{ + * + * @file + * @brief Board specific configuration of direct mapped GPIOs + * + * @author iosabi + */ + +#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 red", + .pin = LED_RED_PIN, + .mode = GPIO_OUT, + .flags = SAUL_GPIO_INIT_CLEAR, + }, + { + .name = "LED green", + .pin = LED_GREEN_PIN, + .mode = GPIO_OUT, + .flags = SAUL_GPIO_INIT_CLEAR, + }, + { + .name = "LED blue", + .pin = LED_BLUE_PIN, + .mode = GPIO_OUT, + .flags = SAUL_GPIO_INIT_CLEAR, + }, + { + .name = "Button(SW1)", + .pin = BTN1_PIN, + .mode = BTN1_MODE, + .flags = SAUL_GPIO_INVERTED, + }, + { + .name = "Button(SW2)", + .pin = BTN2_PIN, + .mode = BTN2_MODE, + .flags = SAUL_GPIO_INVERTED, + }, +}; + +#ifdef __cplusplus +} +#endif + +#endif /* GPIO_PARAMS_H */ +/** @} */ diff --git a/boards/qn9080dk/include/periph_conf.h b/boards/qn9080dk/include/periph_conf.h new file mode 100644 index 0000000000000..a028149990404 --- /dev/null +++ b/boards/qn9080dk/include/periph_conf.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2020 iosabi + * + * 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_qn9080dk + * @{ + * + * @file + * @brief Configuration of CPU peripherals for QN9080DK base board board + * + * @author iosabi + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#include + +#include "cpu.h" +#include "periph_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* put here the board peripherals definitions: + - Available clocks + - Timers + - UARTs + - PWMs + - SPIs + - I2C + - ADC + - RTC + - RTT + etc + */ + +#ifdef __cplusplus +} +#endif + +#endif /* PERIPH_CONF_H */ +/** @} */ diff --git a/cpu/qn908x/include/vendor/fsl_common.h b/cpu/qn908x/include/vendor/fsl_common.h new file mode 100644 index 0000000000000..0d5f9d04bca38 --- /dev/null +++ b/cpu/qn908x/include/vendor/fsl_common.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 iosabi + * + * 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 cpu_qn908x + * @{ + * + * @file + * @brief Wrapper header for SDK drivers. + * + * Vendor SDK drivers include "fsl_common.h" with many definitions and extra + * dependencies on more headers that are not used in the RIOT-OS port. This + * header is a wrapper intended to keep the SDK headers unchanged and provide + * the essential definitions needed by other SDK modules. + * + * @author iosabi + */ + +#ifndef FSL_COMMON_H +#define FSL_COMMON_H + +#include +#include +#include + +#include "irq.h" +#include "vectors_cortexm.h" + +#include "QN908XC.h" +#include "QN908XC_features.h" + +/* RIOT-OS equivalent functions. */ +#define DisableGlobalIRQ irq_disable +#define EnableGlobalIRQ irq_restore + +#define __Vectors cortex_vector_base + +#endif /* FSL_COMMON_H */ +/** @} */