1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

boards/nrf9160dk: add initial support

This commit is contained in:
dylad 2021-07-14 18:19:44 +02:00
parent 5b85a5750e
commit f602c17303
7 changed files with 281 additions and 0 deletions

View File

@ -0,0 +1,3 @@
MODULE = board
include $(RIOTBASE)/Makefile.base

View File

@ -0,0 +1,6 @@
CPU_MODEL = nrf9160
CPU = nrf9160
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart

View File

@ -0,0 +1,2 @@
# include this module into the build
INCLUDES += -I$(RIOTBOARD)/nrf9160dk/include

43
boards/nrf9160dk/board.c Normal file
View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2021 Mesotic SAS
*
* 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_nrf9160dk
* @{
*
* @file
* @brief Board initialization for the nRF9160DK
*
* @author Dylan Laduranty <dylan.laduranty@mesotic.com>
*
* @}
*/
#include "cpu.h"
#include "board.h"
#include "periph/gpio.h"
void board_init(void)
{
gpio_init(LED0_PIN, GPIO_OUT);
gpio_clear(LED0_PIN);
gpio_init(LED1_PIN, GPIO_OUT);
gpio_clear(LED1_PIN);
gpio_init(LED2_PIN, GPIO_OUT);
gpio_clear(LED2_PIN);
gpio_init(LED3_PIN, GPIO_OUT);
gpio_clear(LED3_PIN);
gpio_init(BTN0_PIN, BTN0_MODE);
gpio_init(BTN1_PIN, BTN1_MODE);
gpio_init(BTN2_PIN, BTN2_MODE);
gpio_init(BTN3_PIN, BTN3_MODE);
/* initialize the CPU */
cpu_init();
}

35
boards/nrf9160dk/doc.txt Normal file
View File

@ -0,0 +1,35 @@
/**
@defgroup boards_nrf9160dk nRF9160DK
@ingroup boards
@brief Support for the nRF9160DK board
### General information
The nRF9160DK is a devboard based on nRF9160 MCU which offers LTE-M and NB-IoT
connectivity.
The board features four LEDs, four user buttons/switches and a reset button.
### Links
- [nRF9160dk web page](https://www.nordicsemi.com/Products/Development-hardware/nrf9160-dk)
- [documentation and hardware description](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf91_dk%2FUG%2Fnrf91_DK%2Fintro.html&cp=2_0_4)
### Flash the board
The board is flashed using JLink or nrfjprog software. Programs needs to
be installed.
The process is automated in the usual `make flash` target.
### Accessing STDIO via UART
The STDIO is directly accessible via the USB port. On a Linux host, it's
generally mapped to `/dev/ttyACM0`.
Use the `term` target to connect to the board serial port<br/>
```
make BOARD=nrf9160dk -C examples/hello-world term
```
*/

View File

@ -0,0 +1,98 @@
/*
* Copyright (C) 2021 Mesotic SAS
*
* 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_nrf9160dk
* @{
*
* @file
* @brief Board configuration for the nrf9160dk board
*
* @author Dylan Laduranty <dylan.laduranty@mesotic.com>
*/
#ifndef BOARD_H
#define BOARD_H
#include "cpu.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Clock configuration
*
* @note The LTE modem will only work with the high accuracy RC oscillator
*
* @{
*/
#define CLOCK_HFCLK (32U) /**< set to 0: internal RC oscillator
* 32: 32MHz crystal */
#define CLOCK_LFCLK (3) /**< set to 0: internal RC oscillator
* 3: High Accuracy oscillator */
/** @} */
/**
* @name LED pin configuration
* @{
*/
#define LED0_PIN GPIO_PIN(0, 2) /**< LED0 pin definition */
#define LED1_PIN GPIO_PIN(0, 3) /**< LED1 pin definition */
#define LED2_PIN GPIO_PIN(0, 4) /**< LED2 pin definition */
#define LED3_PIN GPIO_PIN(0, 5) /**< LED3 pin definition */
#define LED0_MASK (1 << 2) /**< LED0 PORT bitmask */
#define LED1_MASK (1 << 3) /**< LED1 PORT bitmask */
#define LED2_MASK (1 << 4) /**< LED2 PORT bitmask */
#define LED3_MASK (1 << 5) /**< LED3 PORT bitmask */
#define LED_PORT (NRF_P0_S) /**< Default LED PORT */
#define LED0_ON (LED_PORT->OUTCLR = LED0_MASK) /**< LED0 ON macro */
#define LED0_OFF (LED_PORT->OUTSET = LED0_MASK) /**< LED0 OFF macro */
#define LED0_TOGGLE (LED_PORT->OUT ^= LED0_MASK) /**< LED0 toggle macro */
#define LED1_ON (LED_PORT->OUTCLR = LED1_MASK) /**< LED1 ON macro */
#define LED1_OFF (LED_PORT->OUTSET = LED1_MASK) /**< LED1 OFF macro */
#define LED1_TOGGLE (LED_PORT->OUT ^= LED1_MASK) /**< LED1 toggle macro */
#define LED2_ON (LED_PORT->OUTCLR = LED2_MASK) /**< LED2 ON macro */
#define LED2_OFF (LED_PORT->OUTSET = LED2_MASK) /**< LED2 OFF macro */
#define LED2_TOGGLE (LED_PORT->OUT ^= LED2_MASK) /**< LED2 toggle macro */
#define LED3_ON (LED_PORT->OUTCLR = LED3_MASK) /**< LED3 ON macro */
#define LED3_OFF (LED_PORT->OUTSET = LED3_MASK) /**< LED3 OFF macro */
#define LED3_TOGGLE (LED_PORT->OUT ^= LED3_MASK) /**< LED3 toggle macro */
/** @} */
/**
* @name Button pin configuration
* @{
*/
#define BTN0_PIN GPIO_PIN(0, 6) /**< BTN0 pin definition */
#define BTN0_MODE GPIO_IN /**< BTN0 default mode */
#define BTN1_PIN GPIO_PIN(0, 7) /**< BTN1 pin definition */
#define BTN1_MODE GPIO_IN /**< BTN1 default mode */
#define BTN2_PIN GPIO_PIN(0, 8) /**< BTN2 pin definition */
#define BTN2_MODE GPIO_IN /**< BTN2 default mode */
#define BTN3_PIN GPIO_PIN(0, 9) /**< BTN3 pin definition */
#define BTN3_MODE GPIO_IN /**< BTN3 default mode */
/** @} */
/**
* @brief Initialize the platform
*/
void board_init(void);
#ifdef __cplusplus
}
#endif
#endif /* BOARD_H */
/** @} */

View File

@ -0,0 +1,94 @@
/*
* Copyright (C) 2021 Mesotic SAS
*
* 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_nrf9160dk
* @{
*
* @file
* @brief Peripheral configuration for the nRF9160DK
*
* @author Dylan Laduranty <dylan.laduranty@mesotic.com>
*
*/
#ifndef PERIPH_CONF_H
#define PERIPH_CONF_H
#include "periph_cpu.h"
#include "board.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Timer configuration
* @{
*/
static const timer_conf_t timer_config[] = {
{
.dev = NRF_TIMER0_S,
.channels = 3,
.bitmode = TIMER_BITMODE_BITMODE_32Bit,
.irqn = TIMER0_IRQn
},
{
.dev = NRF_TIMER1_S,
.channels = 3,
.bitmode = TIMER_BITMODE_BITMODE_08Bit,
.irqn = TIMER1_IRQn
},
};
#define TIMER_0_ISR isr_timer0 /**< Timer0 IRQ*/
#define TIMER_1_ISR isr_timer1 /**< Timer1 IRQ */
#define TIMER_NUMOF ARRAY_SIZE(timer_config) /**< Timer configuration NUMOF */
/** @} */
/**
* @name UART configuration
* @{
*/
static const uart_conf_t uart_config[] = {
{
.dev = NRF_UARTE0_S,
.rx_pin = GPIO_PIN(0, 28),
.tx_pin = GPIO_PIN(0, 29),
#ifdef MODULE_PERIPH_UART_HW_FC
.rts_pin = GPIO_UNDEF,
.cts_pin = GPIO_UNDEF,
#endif
.irqn = UARTE0_SPIM0_SPIS0_TWIM0_TWIS0_IRQn,
},
{
.dev = NRF_UARTE1_S,
.rx_pin = GPIO_PIN(0, 0),
.tx_pin = GPIO_PIN(0, 1),
#ifdef MODULE_PERIPH_UART_HW_FC
.rts_pin = GPIO_UNDEF,
.cts_pin = GPIO_UNDEF,
#endif
.irqn = UARTE1_SPIM1_SPIS1_TWIM1_TWIS1_IRQn,
},
};
#define UART_0_ISR (isr_uarte0_spim0_spis0_twim0_twis0) /**< UART0_IRQ */
#define UART_1_ISR (isr_uarte1_spim1_spis1_twim1_twis1) /**< UART1_IRQ */
#define UART_NUMOF ARRAY_SIZE(uart_config) /**< UART confgiguration NUMOF */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CONF_H */
/** @} */