Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/qn908x: Initial minimal support for NXP QN908x CPUs. #13855

Merged
merged 4 commits into from Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions boards/common/qn908x/Kconfig
@@ -0,0 +1,10 @@
# 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_COMMON_QN908X
bool
depends on CPU_FAM_QN908X
# Add common board support here.
3 changes: 3 additions & 0 deletions boards/common/qn908x/Makefile
@@ -0,0 +1,3 @@
MODULE = boards_common_qn908x

include $(RIOTBASE)/Makefile.base
3 changes: 3 additions & 0 deletions boards/common/qn908x/Makefile.features
@@ -0,0 +1,3 @@
CPU ?= qn908x

# Put defined MCU peripherals here (in alphabetical order)
26 changes: 26 additions & 0 deletions boards/common/qn908x/Makefile.include
@@ -0,0 +1,26 @@
# Using dap or jlink depends on which firmware the OpenSDA debugger is running
#DEBUG_ADAPTER ?= dap
DEBUG_ADAPTER ?= jlink

# Use the shared OpenOCD configuration
OPENOCD_CONFIG ?= $(RIOTBOARD)/common/qn908x/dist/openocd.cfg

# Disable the watchdog when flashing. OpenOCD runs a CRC program in RAM to
# verify the image, which needs to have the WDT disabled but it is normally
# enabled after a 'reset halt' command.
OPENOCD_PRE_FLASH_CMDS += "-c qn908x disable_wdog"

# Set default port depending on operating system
PORT_LINUX ?= /dev/ttyACM0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))

# OpenOCD is able to handle .elf files and is the preferred way.
FLASHFILE ?= $(ELFFILE)

# Setup serial terminal
include $(RIOTMAKE)/tools/serial.inc.mk

# This board uses OpenOCD. Note that support for QN908x in OpenOCD at the time
# of writing has not been merged in the tree and is only available at
# http://openocd.zylin.com/#/c/5584/ .
include $(RIOTMAKE)/tools/openocd.inc.mk
12 changes: 12 additions & 0 deletions boards/common/qn908x/dist/openocd.cfg
@@ -0,0 +1,12 @@
# Generic configuration for a qn908x-based board.

# QN908X only supports SWD
transport select swd

# NXP QN908x.
source [find target/qn908x.cfg]

$TARGETNAME configure -event gdb-attach {
halt
}
$TARGETNAME configure -rtos auto
21 changes: 21 additions & 0 deletions boards/qn9080dk/Kconfig
@@ -0,0 +1,21 @@
# 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_XTAL32K
select BOARD_HAS_XTAL_32M

source "$(RIOTBOARD)/common/qn908x/Kconfig"
6 changes: 6 additions & 0 deletions boards/qn9080dk/Makefile
@@ -0,0 +1,6 @@
MODULE = board

# Use the common qn908x board.
DIRS += $(RIOTBOARD)/common/qn908x

include $(RIOTBASE)/Makefile.base
3 changes: 3 additions & 0 deletions boards/qn9080dk/Makefile.dep
@@ -0,0 +1,3 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
8 changes: 8 additions & 0 deletions 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
8 changes: 8 additions & 0 deletions boards/qn9080dk/Makefile.include
@@ -0,0 +1,8 @@
CFLAGS += \
-DCONFIG_BOARD_HAS_XTAL \
-DCONFIG_BOARD_HAS_XTAL32K \
-DCONFIG_BOARD_HAS_XTAL_32M \
#

# Include default QN908x board config
include $(RIOTBOARD)/common/qn908x/Makefile.include
37 changes: 37 additions & 0 deletions 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 <iosabi@protonmail.com>
*
* @}
*/

#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();
}
62 changes: 62 additions & 0 deletions 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/).

*/
69 changes: 69 additions & 0 deletions 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 <iosabi@protonmail.com>
*/

#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 */
/** @} */
71 changes: 71 additions & 0 deletions 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 <iosabi@protonmail.com>
*/

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