From 82d7368415254806154001631808dcc03a6b2ab4 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 28 Dec 2022 18:13:16 +0100 Subject: [PATCH] boards/hip-badge: add HiP Badge board definition --- boards/hip-badge/Kconfig | 21 +++++ boards/hip-badge/Makefile | 5 ++ boards/hip-badge/Makefile.dep | 9 ++ boards/hip-badge/Makefile.features | 10 +++ boards/hip-badge/Makefile.include | 3 + boards/hip-badge/doc.txt | 62 +++++++++++++ boards/hip-badge/hip-badge.config | 1 + boards/hip-badge/include/board.h | 117 +++++++++++++++++++++++++ boards/hip-badge/include/gpio_params.h | 57 ++++++++++++ boards/hip-badge/include/periph_conf.h | 74 ++++++++++++++++ 10 files changed, 359 insertions(+) create mode 100644 boards/hip-badge/Kconfig create mode 100644 boards/hip-badge/Makefile create mode 100644 boards/hip-badge/Makefile.dep create mode 100644 boards/hip-badge/Makefile.features create mode 100644 boards/hip-badge/Makefile.include create mode 100644 boards/hip-badge/doc.txt create mode 100644 boards/hip-badge/hip-badge.config create mode 100644 boards/hip-badge/include/board.h create mode 100644 boards/hip-badge/include/gpio_params.h create mode 100644 boards/hip-badge/include/periph_conf.h diff --git a/boards/hip-badge/Kconfig b/boards/hip-badge/Kconfig new file mode 100644 index 0000000000..4bc85f1674 --- /dev/null +++ b/boards/hip-badge/Kconfig @@ -0,0 +1,21 @@ +# Copyright (c) 2023 Benjamin Valentin +# +# 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 "hip-badge" if BOARD_HIP_BADGE + +config BOARD_HIP_BADGE + bool + default y + select BOARD_COMMON_ESP32C3 + select CPU_MODEL_ESP32C3 + select HAS_ESP_JTAG + select HAS_PERIPH_I2C + + select HAVE_SAUL_GPIO + select HAVE_SGP30 + +source "$(RIOTBOARD)/common/esp32c3/Kconfig" diff --git a/boards/hip-badge/Makefile b/boards/hip-badge/Makefile new file mode 100644 index 0000000000..13fe94b28b --- /dev/null +++ b/boards/hip-badge/Makefile @@ -0,0 +1,5 @@ +MODULE = board + +DIRS = $(RIOTBOARD)/common/esp32c3 + +include $(RIOTBASE)/Makefile.base diff --git a/boards/hip-badge/Makefile.dep b/boards/hip-badge/Makefile.dep new file mode 100644 index 0000000000..5c958fbbf8 --- /dev/null +++ b/boards/hip-badge/Makefile.dep @@ -0,0 +1,9 @@ +ifeq (,$(filter stdio_% slipdev_stdio,$(USEMODULE))) + USEMODULE += stdio_usb_serial_jtag +endif + +ifneq (,$(filter saul_default,$(USEMODULE))) + USEMODULE += sgp30 +endif + +include $(RIOTBOARD)/common/esp32c3/Makefile.dep diff --git a/boards/hip-badge/Makefile.features b/boards/hip-badge/Makefile.features new file mode 100644 index 0000000000..e826d141b3 --- /dev/null +++ b/boards/hip-badge/Makefile.features @@ -0,0 +1,10 @@ +CPU_MODEL = esp32c3 + +# common board and CPU features +include $(RIOTBOARD)/common/esp32c3/Makefile.features + +# additional features provided by the board +FEATURES_PROVIDED += periph_i2c + +# unique features provided by the board +FEATURES_PROVIDED += esp_jtag diff --git a/boards/hip-badge/Makefile.include b/boards/hip-badge/Makefile.include new file mode 100644 index 0000000000..d1bfece841 --- /dev/null +++ b/boards/hip-badge/Makefile.include @@ -0,0 +1,3 @@ +PORT_LINUX ?= /dev/ttyACM0 + +include $(RIOTBOARD)/common/esp32c3/Makefile.include diff --git a/boards/hip-badge/doc.txt b/boards/hip-badge/doc.txt new file mode 100644 index 0000000000..5d559da5c6 --- /dev/null +++ b/boards/hip-badge/doc.txt @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2023 Benjamin Valentin + * + * 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. + */ + +/** + * @defgroup boards_hip_badge HiP Badge + * @ingroup boards_esp32c3 + * @brief Support for the Hacking in Parallel Badge + * @author Benjamin Valentin + */ + +The HiP Badge is a board that was given to participants of the 2022 *Hacking in Parallel* event. + +![Image of the HiP badge with custom frame and SAO (I2C) expander](https://camo.githubusercontent.com/834dbee4ed9a9a90480bd1a239e54718f3a9613b694d0a2e26a3b25e55ce2d82/68747470733a2f2f6d61747269782d636c69656e742e6d61747269782e6f72672f5f6d61747269782f6d656469612f72302f646f776e6c6f61642f6d6f6e65726f2e736f6369616c2f757351777a4f656957516e6671546247416845734b684a76) + +# Features + + - ESP32-C3FH4AZ SoC + - I2C via SAO headers + - UART via pin headers + - 16 WS2812B LEDs + - USB-C Serial/JTAG + - 3 User button / 1 Reset button + - ST25DV04K NFC/I2C EEPROM (TODO: driver) + +# Flashing the device + +The device can be programmed using the USB-C Serial/JTAG feature. +Just plug in a cable to your computer and flash the device with + + make BOARD=hip-badge flash + +This should automatically reset the ESP32C3 into bootloader mode and start the download process. +If for some reason this gets stuck or the badge does not register as a /dev/ttyACMx device, you +can manually force it into bootloader mode by pressing the reset button (SW3/blue) while holding +the BOOT button (SW4). +When doing this, the device will still be in bootloader mode after flashing, you have to press +the reset button (SW3/blue) again to start your application. + +There is currently still a bug in the USB Serial stdio implementation: After flashing or a reboot, +there is no output. Do a manual reset (press the reset button) to restore output. + +# Bugs + +The event (and badge) were organized on short notice (6 Weeks), so there are some hardware issues: + + - No WiFi/BLE antenna. There is a pad on the back of the PCB where a socket was supposed to be, but + nothing is connected. You can try solder something onto it yourself, but the trace is already long + and winded. + BLE works with the existing trace alone (on short range), WiFi/ESP Now does not. + - IR transceiver broken. Can be fixed with a steady hand? + - SGP30 air quality sensor is only populated on some boards (red case) + - MAX17048 fuel gauge not populated + +# Resources + + - [Badge Clinic](https://wiki.hip-berlin.de/index.php?title=Badge_Clinic) + - [Design files](https://gitlab.com/tidklaas/hip-badge/) diff --git a/boards/hip-badge/hip-badge.config b/boards/hip-badge/hip-badge.config new file mode 100644 index 0000000000..0ebba57f03 --- /dev/null +++ b/boards/hip-badge/hip-badge.config @@ -0,0 +1 @@ +CONFIG_MODULE_STDIO_USB_SERIAL_JTAG=y diff --git a/boards/hip-badge/include/board.h b/boards/hip-badge/include/board.h new file mode 100644 index 0000000000..63c0736052 --- /dev/null +++ b/boards/hip-badge/include/board.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2023 Benjamin Valentin + * + * 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_hip_badge + * @brief Board definitions for the HiP Badge + * @{ + * + * @file + * @author Benjamin Valentin + */ + +#ifndef BOARD_H +#define BOARD_H + +#include + +/** + * @name Button pin definitions + * @{ + */ + +/** + * @brief Tact A GPIO pin definition + */ +#define BTN0_PIN GPIO2 + +/** + * @brief button GPIO mode definition + * + * Since the GPIO of the button is pulled up with an external resistor, the + * mode for the GPIO pin has to be GPIO_IN. + */ +#define BTN0_MODE GPIO_IN + +/** + * @brief Default interrupt flank definition for the button GPIO + */ +#ifndef BTN0_INT_FLANK +#define BTN0_INT_FLANK GPIO_FALLING +#endif + +/** + * @brief Tact B GPIO pin definition + */ +#define BTN1_PIN GPIO8 + +/** + * @brief Default button GPIO mode definition + * + * Since the GPIO of the button is pulled up with an external resistor, the + * mode for the GPIO pin has to be GPIO_IN. + */ +#define BTN1_MODE GPIO_IN + +/** + * @brief Default interrupt flank definition for the button GPIO + */ +#ifndef BTN1_INT_FLANK +#define BTN1_INT_FLANK GPIO_FALLING +#endif + +/** + * @brief BOOT button GPIO pin definition + * + * The HiP-Badge has a BOOT button connected to GPIO9, which can be + * used as button during normal operation. Since the GPIO9 pin is pulled up, + * the button signal is inverted, i.e., pressing the button will give a + * low signal. + */ +#define BTN2_PIN GPIO9 + +/** + * @brief Default button GPIO mode definition + */ +#define BTN2_MODE GPIO_IN_PU + +/** + * @brief Default interrupt flank definition for the button GPIO + */ +#ifndef BTN2_INT_FLANK +#define BTN2_INT_FLANK GPIO_FALLING +#endif +/** @} */ + +/** + * @brief WS281x LEDs are connected to GPIO10 + */ +#ifndef WS281X_PARAM_PIN +#define WS281X_PARAM_PIN GPIO10 +#endif + +/** + * @brief There are 16 WS281x LEDs + */ +#ifndef WS281X_PARAM_NUMOF +#define WS281X_PARAM_NUMOF 16 +#endif + +/* include common board definitions as last step */ +#include "board_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} /* end extern "C" */ +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/hip-badge/include/gpio_params.h b/boards/hip-badge/include/gpio_params.h new file mode 100644 index 0000000000..75d83cd271 --- /dev/null +++ b/boards/hip-badge/include/gpio_params.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2023 Benjamin Valentin + * + * 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_hip_badge + * @brief Board specific configuration of direct mapped GPIOs + * @file + * @author Benjamin Valentin + * @{ + */ + +#ifndef GPIO_PARAMS_H +#define GPIO_PARAMS_H + +#include "board.h" +#include "saul/periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief LED and Button configuration + */ +static const saul_gpio_params_t saul_gpio_params[] = +{ + { + .name = "SW1", + .pin = BTN0_PIN, + .mode = BTN0_MODE, + .flags = SAUL_GPIO_INVERTED + }, + { + .name = "SW2", + .pin = BTN1_PIN, + .mode = BTN1_MODE, + .flags = SAUL_GPIO_INVERTED + }, + { + .name = "Boot", + .pin = BTN2_PIN, + .mode = BTN2_MODE, + .flags = SAUL_GPIO_INVERTED + }, +}; + +#ifdef __cplusplus +} +#endif + +#endif /* GPIO_PARAMS_H */ +/** @} */ diff --git a/boards/hip-badge/include/periph_conf.h b/boards/hip-badge/include/periph_conf.h new file mode 100644 index 0000000000..38c995a93e --- /dev/null +++ b/boards/hip-badge/include/periph_conf.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2023 Benjamin Valentin + * + * 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_hip_badge + * @brief Peripheral configurations for the HiP Badge + * @{ + * + * @file + * @author Benjamin Valentin + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name I2C configuration + * + * One I2C interface I2C_DEV(0) is defined and available via the SAO headers. + * + * The GPIOs listed in the configuration are only initialized as I2C signals + * when module `periph_i2c` is used. Otherwise they are not allocated and + * can be used for other purposes. + * + * @{ + */ +#ifndef I2C0_SPEED +#define I2C0_SPEED I2C_SPEED_FAST /**< I2C bus speed of I2C_DEV(0) */ +#endif +#ifndef I2C0_SCL +#define I2C0_SCL GPIO6 /**< SCL signal of I2C_DEV(0) */ +#endif +#ifndef I2C0_SDA +#define I2C0_SDA GPIO5 /**< SDA signal of I2C_DEV(0) */ +#endif +/** @} */ + +/** + * @name UART configuration + * + * ESP32-C3 provides 2 UART interfaces at maximum: + * + * UART_DEV(0) uses fixed standard configuration.
+ * UART_DEV(1) is used for IrDA (untested).
+ * + * @{ + */ +#define UART0_TXD GPIO21 /**< direct I/O pin for UART_DEV(0) TxD, can't be changed */ +#define UART0_RXD GPIO20 /**< direct I/O pin for UART_DEV(0) RxD, can't be changed */ + +#define UART1_TXD GPIO7 /**< IrDA TX - Bad Choice? */ +#define UART1_RXD GPIO3 /**< IrDA RX - Bad Choice? */ +/** @} */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif + +/* include common peripheral definitions as last step */ +#include "periph_conf_common.h" + +#endif /* PERIPH_CONF_H */ +/** @} */