From 5c21df5feefd537aa83f81564faef9b179b83c7d Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 23 Oct 2019 13:50:18 +0200 Subject: [PATCH] boards/pinetime: initial support for the PINE64 PineTime smartwatch --- boards/pinetime/Makefile | 3 ++ boards/pinetime/Makefile.dep | 3 ++ boards/pinetime/Makefile.features | 8 +++ boards/pinetime/Makefile.include | 7 +++ boards/pinetime/board.c | 48 ++++++++++++++++++ boards/pinetime/doc.txt | 14 +++++ boards/pinetime/include/board.h | 73 +++++++++++++++++++++++++++ boards/pinetime/include/periph_conf.h | 71 ++++++++++++++++++++++++++ 8 files changed, 227 insertions(+) create mode 100644 boards/pinetime/Makefile create mode 100644 boards/pinetime/Makefile.dep create mode 100644 boards/pinetime/Makefile.features create mode 100644 boards/pinetime/Makefile.include create mode 100644 boards/pinetime/board.c create mode 100644 boards/pinetime/doc.txt create mode 100644 boards/pinetime/include/board.h create mode 100644 boards/pinetime/include/periph_conf.h diff --git a/boards/pinetime/Makefile b/boards/pinetime/Makefile new file mode 100644 index 0000000000..f8fcbb53a0 --- /dev/null +++ b/boards/pinetime/Makefile @@ -0,0 +1,3 @@ +MODULE = board + +include $(RIOTBASE)/Makefile.base diff --git a/boards/pinetime/Makefile.dep b/boards/pinetime/Makefile.dep new file mode 100644 index 0000000000..d699116749 --- /dev/null +++ b/boards/pinetime/Makefile.dep @@ -0,0 +1,3 @@ +# include common nrf52 dependencies +include $(RIOTBOARD)/common/nrf52/nrf52832/Makefile.dep +include $(RIOTBOARD)/common/nrf52/Makefile.dep diff --git a/boards/pinetime/Makefile.features b/boards/pinetime/Makefile.features new file mode 100644 index 0000000000..53a8d3d1a0 --- /dev/null +++ b/boards/pinetime/Makefile.features @@ -0,0 +1,8 @@ +CPU_MODEL = nrf52832xxaa + +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_i2c +FEATURES_PROVIDED += periph_spi +#FEATURES_PROVIDED += periph_uart + +include $(RIOTBOARD)/common/nrf52/Makefile.features diff --git a/boards/pinetime/Makefile.include b/boards/pinetime/Makefile.include new file mode 100644 index 0000000000..8d7bb8eeeb --- /dev/null +++ b/boards/pinetime/Makefile.include @@ -0,0 +1,7 @@ +# for this board, we are using Segger's RTT as default terminal interface +USEMODULE += stdio_rtt +TERMPROG = $(RIOTTOOLS)/jlink/jlink.sh +TERMFLAGS = term-rtt + +# use shared Makefile.include +include $(RIOTBOARD)/common/nrf52/Makefile.include diff --git a/boards/pinetime/board.c b/boards/pinetime/board.c new file mode 100644 index 0000000000..466fda34e9 --- /dev/null +++ b/boards/pinetime/board.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2017 Freie Universität Berlin + * 2020 Inria + * 2020 Kaspar Schleiser + * + * 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_pinetime + * @{ + * + * @file + * @brief Board initialization for the PineTime + * + * @author Hauke Petersen + * @author Kaspar Schleiser + * + * @} + */ + +#include "cpu.h" +#include "board.h" +#include "periph/gpio.h" + +void board_init(void) +{ + /* initialize the CPU */ + cpu_init(); + + /* initialize pins */ + gpio_init(VCC33, GPIO_OUT); + gpio_init(BUTTON0_ENABLE, GPIO_OUT); + gpio_init(BUTTON0, GPIO_IN); + gpio_init(VIBRATOR, GPIO_OUT); + gpio_init(LCD_BACKLIGHT_LOW, GPIO_OUT); + gpio_init(LCD_BACKLIGHT_MID, GPIO_OUT); + gpio_init(LCD_BACKLIGHT_HIGH, GPIO_OUT); + + gpio_set(VCC33); + gpio_set(BUTTON0_ENABLE); + gpio_set(VIBRATOR); + gpio_set(LCD_BACKLIGHT_LOW); + gpio_set(LCD_BACKLIGHT_MID); + gpio_set(LCD_BACKLIGHT_HIGH); +} diff --git a/boards/pinetime/doc.txt b/boards/pinetime/doc.txt new file mode 100644 index 0000000000..072258daa5 --- /dev/null +++ b/boards/pinetime/doc.txt @@ -0,0 +1,14 @@ +/** +@defgroup boards_pinetime PineTime +@ingroup boards +@brief Support for the Pinetime + +### General information + +"The PINE64 SmartWatch, dubbed "PineTime", is a product of a community effort +for an open source smartwatch in collaboration with wearable RTOS and Linux app +developers & communities." + +See https://wiki.pine64.org/index.php/PineTime for more information. + + */ diff --git a/boards/pinetime/include/board.h b/boards/pinetime/include/board.h new file mode 100644 index 0000000000..66de809085 --- /dev/null +++ b/boards/pinetime/include/board.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2019 Inria + * 2019 Freie Universität Berlin + * 2019 Kaspar Schleiser + * + * 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_pinetime + * @{ + * + * @file + * @brief Board specific configuration for the PineTime + * + * @author Kaspar Schleiser + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "cpu.h" +#include "board_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name GPIO pin defines + * @{ + */ +#define LCD_RS GPIO_PIN(0, 18) +#define LCD_DET GPIO_PIN(0, 9) +#define LCD_CS GPIO_PIN(0, 25) +#define LCD_RESET GPIO_PIN(0, 26) + +#define LCD_BACKLIGHT_LOW GPIO_PIN(0, 14) +#define LCD_BACKLIGHT_MID GPIO_PIN(0, 22) +#define LCD_BACKLIGHT_HIGH GPIO_PIN(0, 23) + +#define BUTTON0_ENABLE GPIO_PIN(0, 13) +#define BUTTON0 GPIO_PIN(0, 15) +#define VIBRATOR GPIO_PIN(0, 16) + +#define VCC33 GPIO_PIN(0, 24) +#define POWER_PRESENCE GPIO_PIN(0, 19) +#define CHARGING_ACTIVE GPIO_PIN(0, 12) +#define BATTERY_ADC NRF52 +/** @} */ + +/** + * @name LCD configuration + * @{ + */ +#define ILI9341_PARAM_SPI SPI_DEV(0) +#define ILI9341_PARAM_SPI_CLK SPI_CLK_10MHZ +#define ILI9341_PARAM_SPI_MODE SPI_MODE_3 +#define ILI9341_PARAM_CS LCD_CS +#define ILI9341_PARAM_DCX LCD_RS +#define ILI9341_PARAM_RST LCD_RESET +#define ILI9341_PARAM_RGB 1 +#define ILI9341_PARAM_INVERTED 1 +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/pinetime/include/periph_conf.h b/boards/pinetime/include/periph_conf.h new file mode 100644 index 0000000000..cfd3dd57cf --- /dev/null +++ b/boards/pinetime/include/periph_conf.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2019 Inria + * 2019 Freie Universität Berlin + * 2019 Kaspar Schleiser + * + * 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_pinetime + * @{ + * + * @file + * @brief Peripheral configuration for the PineTime + * + * @author Kaspar Schleiser + * + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#include "periph_cpu.h" +#include "cfg_clock_32_1.h" +#include "cfg_rtt_default.h" +#include "cfg_timer_default.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name SPI configuration + * @{ + */ +static const spi_conf_t spi_config[] = { + { + .dev = NRF_SPI0, + .sclk = GPIO_PIN(0, 2), + .mosi = GPIO_PIN(0, 3), + .miso = GPIO_PIN(0, 4), + } +}; + +#define SPI_NUMOF ARRAY_SIZE(spi_config) +/** @} */ + +/** + * @name I2C configuration + * @{ + */ +static const i2c_conf_t i2c_config[] = { + { + .dev = NRF_TWIM1, + .scl = GPIO_PIN(0, 7), + .sda = GPIO_PIN(0, 6), + .speed = I2C_SPEED_FAST + } +}; + +#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0])) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* PERIPH_CONF_H */ +/** @} */