├── .gitignore ├── boards └── esp32-ttgo-lora32-v1 │ ├── Makefile │ ├── Makefile.include │ ├── Makefile.features │ ├── include │ ├── arduino_board.h │ ├── gpio_params.h │ ├── arduino_pinmap.h │ ├── board.h │ └── periph_conf.h │ ├── Makefile.dep │ └── doc.txt ├── examples ├── RIOT_TTGO_Leds │ ├── main.c │ └── Makefile ├── RIOT_TTGO_OLED │ ├── Makefile │ ├── README.md │ └── main.c └── RIOT_TTGO_TTN │ ├── Makefile │ └── main.c └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | bin/ 3 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/Makefile: -------------------------------------------------------------------------------- 1 | MODULE = board 2 | 3 | DIRS = $(RIOTBOARD)/common/esp32 4 | 5 | include $(RIOTBASE)/Makefile.base 6 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/Makefile.include: -------------------------------------------------------------------------------- 1 | USEMODULE += boards_common_esp32 2 | 3 | include $(RIOTBOARD)/common/esp32/Makefile.include 4 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/Makefile.features: -------------------------------------------------------------------------------- 1 | # common board and CPU features 2 | include $(RIOTBOARD)/common/esp32/Makefile.features 3 | 4 | # additional features provided by the board 5 | FEATURES_PROVIDED += periph_adc 6 | FEATURES_PROVIDED += periph_dac 7 | FEATURES_PROVIDED += periph_i2c 8 | FEATURES_PROVIDED += periph_pwm 9 | FEATURES_PROVIDED += periph_spi 10 | 11 | FEATURES_PROVIDED += arduino 12 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/include/arduino_board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Gunar Schorcht 3 | * 4 | * This file is subject to the terms and conditions of the GNU Lesser 5 | * General Public License v2.1. See the file LICENSE in the top level 6 | * directory for more details. 7 | */ 8 | 9 | /** 10 | * @ingroup boards_esp32_wroom-32 11 | * @{ 12 | * 13 | * @file 14 | * @brief Board specific configuration for the Arduino API 15 | * 16 | * @author Gunar Schorcht 17 | */ 18 | 19 | #ifndef ARDUINO_BOARD_H 20 | #define ARDUINO_BOARD_H 21 | 22 | #include "arduino_board_common.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * @brief The on-board LED is on pin 2 30 | */ 31 | #define ARDUINO_LED (2) 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* ARDUINO_BOARD_H */ 38 | /** @} */ 39 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/include/gpio_params.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Gunar Schorcht 3 | * 4 | * This file is subject to the terms and conditions of the GNU Lesser 5 | * General Public License v2.1. See the file LICENSE in the top level 6 | * directory for more details. 7 | */ 8 | 9 | #ifndef GPIO_PARAMS_H 10 | #define GPIO_PARAMS_H 11 | 12 | /** 13 | * @ingroup boards_esp32_wroom-32 14 | * @brief Board specific configuration of direct mapped GPIOs 15 | * @file 16 | * @author Gunar Schorcht 17 | * @{ 18 | */ 19 | 20 | #include "board.h" 21 | #include "saul/periph.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * @brief LED and Button configuration 29 | */ 30 | static const saul_gpio_params_t saul_gpio_params[] = 31 | { 32 | { 33 | .name = "BOOT", 34 | .pin = BUTTON0_PIN, 35 | .mode = GPIO_IN, 36 | .flags = 0 37 | }, 38 | }; 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* GPIO_PARAMS_H */ 45 | /** @} */ 46 | -------------------------------------------------------------------------------- /examples/RIOT_TTGO_Leds/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "thread.h" 6 | #include "shell.h" 7 | #include "shell_commands.h" 8 | #include "xtimer.h" 9 | #include "led.h" 10 | #include "periph/gpio.h" 11 | 12 | #ifdef MODULE_NETIF 13 | #include "net/gnrc/pktdump.h" 14 | #include "net/gnrc.h" 15 | #endif 16 | 17 | // The TTGO ESP32 Lora OLED pins 18 | 19 | static int led_cmd(int argc, char **argv) { 20 | if ( argc != 2 ) { 21 | (void) puts("Usage: led [on|off]"); 22 | return 1; 23 | } 24 | if ( strcmp( argv[1] , "on" ) == 0 ) { 25 | LED_ON(0); 26 | return 0; 27 | } 28 | 29 | if ( strcmp( argv[1] , "off" ) == 0 ) { 30 | LED_OFF(0); 31 | return 0; 32 | } 33 | 34 | puts("led: Invalid command"); 35 | return 1; 36 | } 37 | 38 | const shell_command_t shell_commands[] = { 39 | {"led", "Turns on the onboard led.", led_cmd }, 40 | {NULL, NULL, NULL} 41 | }; 42 | 43 | 44 | int main(void) 45 | { 46 | 47 | (void) puts("Welcome to RIOT!"); 48 | gpio_t pinled = GPIO_PIN( 0 , 2); 49 | gpio_init( pinled , GPIO_OUT); 50 | gpio_set( pinled ); 51 | 52 | char line_buf[SHELL_DEFAULT_BUFSIZE]; 53 | shell_run( shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /examples/RIOT_TTGO_OLED/Makefile: -------------------------------------------------------------------------------- 1 | # name of your application 2 | APPLICATION = ttgo_oled_test 3 | 4 | # If no BOARD is found in the environment, use this default: 5 | BOARD ?= esp32-ttgo-lora32-v1 6 | 7 | # This has to be the absolute path to the RIOT base directory: 8 | #RIOTBASE ?= $(CURDIR)/../.. 9 | RIOTBASE ?= $(RIOT_BASE) 10 | 11 | # Uncomment these lines if you want to use platform support from external 12 | # repositories: 13 | #RIOTCPU ?= $(CURDIR)/../../RIOT/thirdparty_cpu 14 | #RIOTBOARD ?= $(CURDIR)/../../RIOT/thirdparty_boards 15 | 16 | # Uncomment this to enable scheduler statistics for ps: 17 | #USEMODULE += schedstatistics 18 | 19 | # If you want to use native with valgrind, you should recompile native 20 | # with the target all-valgrind instead of all: 21 | # make -B clean all-valgrind 22 | 23 | # Comment this out to disable code in RIOT that does safety checking 24 | # which is not needed in a production environment but helps in the 25 | # development process: 26 | DEVELHELP ?= 1 27 | 28 | # Change this to 0 show compiler invocation lines by default: 29 | QUIET ?= 1 30 | 31 | # Modules to include: 32 | USEMODULE += shell 33 | USEMODULE += shell_commands 34 | USEMODULE += ps 35 | 36 | # Packages to include 37 | USEPKG += u8g2 38 | 39 | FEATURES_REQUIRED += periph_gpio periph_i2c 40 | 41 | include $(RIOTBASE)/Makefile.include 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RIOT_TTGOESP32_LORA_V1 2 | 3 | This repository contains a RIOT-OS board definition for the TTGO ESP32 board, Version 1, that has support for LORA through the SX127X transceiver and a SSD1306 OLED. 4 | 5 | The board definition is not yet totally complete. Only the following points are correctly implemented/checked: 6 | 7 | - ESP32 clock frequency: Necessary for correct serial output. 8 | - On board led PIN definition 9 | - SX1276 transceiver pin definitions 10 | - SSD1306 pin definitions 11 | - I2C pins definitions 12 | - SPI pins definitions 13 | 14 | Other pins are probably not corrected and where not checked yet. 15 | 16 | # What is working? 17 | 18 | The following peripheral devices work: 19 | 20 | - SSD1306 OLed 21 | - LORA SX1276 works but several issues connecting to lorawan/TTN do exist (timing issues). 22 | 23 | Under the examples directory there are examples for each peripheral. 24 | 25 | # How to use it? 26 | 27 | The following steps are required: 28 | 29 | - Checkout the RIOT-OS repository to a local machine. 30 | - I recommend to install the docker RIOT-OS BUILD container: https://hub.docker.com/r/riot/riotbuild/ for building RIOT based applications 31 | - Checkout this repository 32 | - Copy this repository board definition to the boards directory of the cloned RIOT-OS repository 33 | - Enter the example directoy application. 34 | - Execute make flash term 35 | 36 | -------------------------------------------------------------------------------- /examples/RIOT_TTGO_Leds/Makefile: -------------------------------------------------------------------------------- 1 | # name of your application 2 | APPLICATION = esp32_leds 3 | 4 | # If no BOARD is found in the environment, use this default: 5 | BOARD ?= esp32-ttgo-lora32-v1 6 | 7 | # This has to be the absolute path to the RIOT base directory: 8 | RIOTBASE ?= $(RIOT_BASE) 9 | 10 | # Uncomment these lines if you want to use platform support from external 11 | # repositories: 12 | #RIOTCPU ?= $(CURDIR)/../../RIOT/thirdparty_cpu 13 | #RIOTBOARD ?= $(CURDIR)/../../RIOT/thirdparty_boards 14 | 15 | # Uncomment this to enable scheduler statistics for ps: 16 | #USEMODULE += schedstatistics 17 | 18 | # If you want to use native with valgrind, you should recompile native 19 | # with the target all-valgrind instead of all: 20 | # make -B clean all-valgrind 21 | 22 | # Comment this out to disable code in RIOT that does safety checking 23 | # which is not needed in a production environment but helps in the 24 | # development process: 25 | DEVELHELP ?= 1 26 | 27 | # Change this to 0 show compiler invocation lines by default: 28 | QUIET ?= 1 29 | 30 | # Modules to include: 31 | USEMODULE += shell 32 | USEMODULE += shell_commands 33 | USEMODULE += ps 34 | #USEMODULE += posix 35 | USEMODULE += xtimer 36 | # include and auto-initialize all available sensors 37 | #USEMODULE += saul_default 38 | 39 | FEATURES_OPTIONAL += periph_rtc, periph_gpio 40 | 41 | include $(RIOTBASE)/Makefile.include 42 | -------------------------------------------------------------------------------- /examples/RIOT_TTGO_OLED/README.md: -------------------------------------------------------------------------------- 1 | TTGO SSD1306 OLED 2 | ================= 3 | 4 | This example contains a simple code to test the TTGO ESP32 LORA V1 board OLed screen. 5 | The screen is based on the SSD1306 chip, and is connected to the ESP32 cpu by I2C (Address 0x3C). 6 | 7 | The screen only works when the I2C speed is set to NORMAL (see the board peripheral definition). 8 | Other speeds do not work. 9 | 10 | Usage 11 | ===== 12 | 13 | Copy the TTGO board definition to the RIOT boards subdirectory. 14 | If not wanting to mess with your RIOT installation, the TTGO Board definition can be 15 | accessed by defining a path for the Third-party boards. 16 | 17 | The ESP-IDF SDK also needs to be installed, so that flashing is possible. 18 | I'm using the DOCKER image that has all the required frameworks for compiling RIOT applications. 19 | If not using DOCKER, remove the export for BUILD_IN_DOCKER 20 | 21 | Build, flash and start the application: 22 | ``` 23 | export BOARD=esp32_ttgo_lora_v1 24 | export RIOT_BASE=/opt/RIOT 25 | export ESP32_SDK_DIR=/opt/esp-idf 26 | export BUILD_IN_DOCKER=1 27 | make flash term 28 | ``` 29 | 30 | The `term` make target starts a terminal emulator for your board. It 31 | connects to a default port so you can interact with the shell, usually 32 | that is `/dev/ttyUSB0`. If your port is named differently, the 33 | `PORT=/dev/yourport` variable can be used to override this. 34 | 35 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/Makefile.dep: -------------------------------------------------------------------------------- 1 | include $(RIOTBOARD)/common/esp32/Makefile.dep 2 | 3 | # default parameter definitions when module enc28j60 is used 4 | ifneq (, $(filter enc28j60, $(USEMODULE))) 5 | 6 | # avoid multiple definitions when package depenedencies are resolved recursively 7 | ifndef ENC28J60_PARAM_DEFINED 8 | export ENC28J60_PARAM_DEFINED = 1 9 | 10 | # default definitions 11 | ENC28J60_PARAM_SPI ?= SPI_DEV\(0\) 12 | ENC28J60_PARAM_CS ?= GPIO32 13 | ENC28J60_PARAM_INT ?= GPIO35 14 | ENC28J60_PARAM_RESET ?= GPIO33 15 | CFLAGS += -DENC28J60_PARAM_SPI=$(ENC28J60_PARAM_SPI) 16 | CFLAGS += -DENC28J60_PARAM_CS=$(ENC28J60_PARAM_CS) 17 | CFLAGS += -DENC28J60_PARAM_INT=$(ENC28J60_PARAM_INT) 18 | CFLAGS += -DENC28J60_PARAM_RESET=$(ENC28J60_PARAM_RESET) 19 | 20 | # to satisfy variable defintions in tests/driver_enc28j60/Makefile 21 | ENC_SPI = $(ENC28J60_PARAM_SPI) 22 | ENC_CS = $(ENC28J60_PARAM_CS) 23 | ENC_INT = $(ENC28J60_PARAM_INT) 24 | ENC_RST = $(ENC28J60_PARAM_RESET) 25 | 26 | endif 27 | endif 28 | 29 | # default parameter definitions when module mfr24j40 is used 30 | ifneq (, $(filter mrf24j40, $(USEMODULE))) 31 | 32 | # avoid multiple definitions when package depenedencies are resolved recursively 33 | ifndef MRF24J40_PARAM_DEFINED 34 | export MRF24J40_PARAM_DEFINED = 1 35 | 36 | # default definitions 37 | MRF24J40_PARAM_SPI = SPI_DEV\(0\) 38 | MRF24J40_PARAM_SPI_CLK = SPI_CLK_1MHZ 39 | MRF24J40_PARAM_CS ?= GPIO16 40 | MRF24J40_PARAM_INT ?= GPIO34 41 | MRF24J40_PARAM_RESET ?= GPIO17 42 | CFLAGS += -DMRF24J40_PARAM_SPI=$(MRF24J40_PARAM_SPI) 43 | CFLAGS += -DMRF24J40_PARAM_SPI_CLK=$(MRF24J40_PARAM_SPI_CLK) 44 | CFLAGS += -DMRF24J40_PARAM_CS=$(MRF24J40_PARAM_CS) 45 | CFLAGS += -DMRF24J40_PARAM_INT=$(MRF24J40_PARAM_INT) 46 | CFLAGS += -DMRF24J40_PARAM_RESET=$(MRF24J40_PARAM_RESET) 47 | 48 | endif 49 | endif 50 | -------------------------------------------------------------------------------- /examples/RIOT_TTGO_TTN/Makefile: -------------------------------------------------------------------------------- 1 | # name of your application 2 | APPLICATION = TTN_DemoApp 3 | 4 | # Use the TTGO ESP32 Lora V1 board: 5 | BOARD ?= esp32_ttgo_lora_v1 6 | 7 | # Define here the type of node activation OTAA or ABP: ABP=0, OTAA=1 8 | NODEACTIVATION ?= 0 9 | # NODEACTIVATION ?= 1 10 | 11 | # This has to be the absolute path to the RIOT base directory: 12 | # This variable is defined at shell level in my case, uncomment to point to your RIOT-OS install directory 13 | #RIOTBASE ?= $(CURDIR)/../.. 14 | RIOTBASE ?= $(RIOT_BASE) 15 | 16 | BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6 nucleo-f042k6 nucleo-l031k6 17 | 18 | # Pre-set this information so when the board boots up, a set of default parameters are already set 19 | # TTN information for OTTA activation. 20 | # WARNING: Make sure there are NO trailing spaces. 21 | DEVEUI ?= 0000000000000000 22 | APPEUI ?= 0000000000000000 23 | APPKEY ?= 00000000000000000000000000000000 24 | 25 | # TTN information for ABP activation. 26 | DEVADDR ?= 00000000 27 | NWKSKEY ?= 00000000000000000000000000000000 28 | APPSKEY ?= 00000000000000000000000000000000 29 | 30 | # Default radio driver is Semtech SX1276 31 | DRIVER ?= sx1276 32 | 33 | # Default region is Europe and default band is 868MHz 34 | REGION ?= EU868 35 | 36 | # Include the Semtech-loramac package 37 | USEPKG += semtech-loramac 38 | #USEPKG += u8g2 39 | 40 | FEATURES_REQUIRED += periph_gpio periph_i2c 41 | 42 | USEMODULE += $(DRIVER) 43 | USEMODULE += fmt 44 | 45 | # include the shell: 46 | USEMODULE += shell 47 | USEMODULE += shell_commands 48 | # additional modules for debugging: 49 | USEMODULE += ps 50 | 51 | FEATURES_REQUIRED += periph_rtc 52 | 53 | CFLAGS += -DREGION_$(REGION) 54 | CFLAGS += -DDEVEUI=\"$(DEVEUI)\" -DAPPEUI=\"$(APPEUI)\" -DAPPKEY=\"$(APPKEY)\" 55 | CFLAGS += -DDEVADDR=\"$(DEVADDR)\" -DAPPSKEY=\"$(APPSKEY)\" -DNWKSKEY=\"$(NWKSKEY)\" 56 | CFLAGS += -DNODEACTIVATION=$(NODEACTIVATION) 57 | CFLAGS += -DLORAMAC_ACTIVE_REGION=LORAMAC_REGION_$(REGION) 58 | 59 | # Comment this out to disable code in RIOT that does safety checking 60 | # which is not needed in a production environment but helps in the 61 | # development process: 62 | DEVELHELP ?= 1 63 | 64 | # Change this to 0 show compiler invocation lines by default: 65 | QUIET ?= 1 66 | 67 | include $(RIOTBASE)/Makefile.include 68 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/include/arduino_pinmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Gunar Schorcht 3 | * 4 | * This file is subject to the terms and conditions of the GNU Lesser 5 | * General Public License v2.1. See the file LICENSE in the top level 6 | * directory for more details. 7 | */ 8 | 9 | /** 10 | * @ingroup boards_esp32_wroom-32 11 | * @{ 12 | * 13 | * @file 14 | * @brief Mapping from MCU pins to Arduino pins 15 | * 16 | * @author Gunar Schorcht 17 | */ 18 | 19 | #ifndef ARDUINO_PINMAP_H 20 | #define ARDUINO_PINMAP_H 21 | 22 | #include "periph/gpio.h" 23 | #include "periph/adc.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /** 30 | * @name Mapping of MCU pins to Arduino pins 31 | * @{ 32 | */ 33 | #define ARDUINO_PIN_0 GPIO3 /**< Arduino Uno pin 0 (RxD) */ 34 | #define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ 35 | 36 | #define ARDUINO_PIN_2 GPIO12 /**< Arduino Uno pin 2 */ 37 | #define ARDUINO_PIN_3 GPIO27 /**< Arduino Uno pin 3 (PWM) */ 38 | #define ARDUINO_PIN_4 GPIO2 /**< Arduino Uno pin 4 */ 39 | #define ARDUINO_PIN_5 GPIO32 /**< Arduino Uno pin 5 (PWM) */ 40 | #define ARDUINO_PIN_6 GPIO33 /**< Arduino Uno pin 6 (PWM) */ 41 | #define ARDUINO_PIN_7 GPIO13 /**< Arduino Uno pin 7 */ 42 | #define ARDUINO_PIN_8 GPIO14 /**< Arduino Uno pin 8 */ 43 | #define ARDUINO_PIN_9 GPIO0 /**< Arduino Uno pin 9 (PWM) */ 44 | 45 | #define ARDUINO_PIN_10 GPIO5 /**< Arduino Uno pin 10 (CS0 / PWM) */ 46 | #define ARDUINO_PIN_11 GPIO23 /**< Arduino Uno pin 11 (MOSI / PWM) */ 47 | #define ARDUINO_PIN_12 GPIO19 /**< Arduino Uno pin 12 (MISO) */ 48 | #define ARDUINO_PIN_13 GPIO18 /**< Arduino Uno pin 13 (SCK) */ 49 | 50 | #define ARDUINO_PIN_A0 GPIO25 /**< Arduino Uno pin A0 */ 51 | #define ARDUINO_PIN_A1 GPIO26 /**< Arduino Uno pin A1 */ 52 | #define ARDUINO_PIN_A2 GPIO4 /**< Arduino Uno pin A2 */ 53 | #define ARDUINO_PIN_A3 GPIO15 /**< Arduino Uno pin A3 */ 54 | 55 | #define ARDUINO_PIN_A4 GPIO21 /**< Arduino Uno pin A4 (SDA) */ 56 | #define ARDUINO_PIN_A5 GPIO22 /**< Arduino Uno pin A5 (SCL) */ 57 | /** @ */ 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* ARDUINO_PINMAP_H */ 64 | /** @} */ 65 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/include/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Gunar Schorcht 3 | * 4 | * Changed by FcGDAM (2018) for supporting the TTGO V1 ESP32 LORA OLED board 5 | * 6 | * This file is subject to the terms and conditions of the GNU Lesser 7 | * General Public License v2.1. See the file LICENSE in the top level 8 | * directory for more details. 9 | */ 10 | 11 | /** 12 | * @ingroup boards_esp32_TTGO_LORA_V1 13 | * @brief Board specific definition for TTGO ESP32 LORA OLED V1 board 14 | * @{ 15 | * 16 | * For detailed information about the configuration of ESP32 boards, see 17 | * section \ref esp32_comm_periph "Common Peripherals". 18 | * 19 | * @note 20 | * Most definitions can be overridden by an \ref esp32_app_spec_conf 21 | * "application-specific board configuration". 22 | * 23 | * @file 24 | * @author Gunar Schorcht 25 | */ 26 | 27 | #ifndef BOARD_H 28 | #define BOARD_H 29 | 30 | /* The TTGO ESP32 LORA board uses 26MHz crystal instead of 40Mhz */ 31 | #define ESP32_XTAL_FREQ (26) 32 | 33 | #include 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #ifdef __cplusplus 40 | } /* end extern "C" */ 41 | #endif 42 | 43 | /** 44 | * @name Button pin definitions 45 | * @{ 46 | */ 47 | /** 48 | * Generic ESP32 boards have a BOOT button, which can be used as normal button 49 | * during normal operation. Since the GPIO0 pin is pulled up, the button 50 | * signal is inverted, i.e., pressing the button will give a low signal. 51 | */ 52 | #define BUTTON0_PIN GPIO0 53 | /** @} */ 54 | 55 | /** 56 | * @name LED (on-board) configuration 57 | * 58 | * TTGO ESP32 board on-board LED. 59 | * @{ 60 | */ 61 | #define LED0_PIN GPIO2 62 | #define LED0_ACTIVE 1 63 | /** @} */ 64 | 65 | /** 66 | * @name OLED (on-board) reset pin configuration 67 | * 68 | * TTGO SSD1306 OLED Reset pin 69 | * @{ 70 | */ 71 | #define OLED_RESET_PIN GPIO16 72 | /** @} */ 73 | 74 | /** 75 | * @name OLED (on-board) I2C address 76 | * 77 | * TTGO SSD1306 OLED I2C address 78 | * @{ 79 | */ 80 | #define OLED_I2C_ADDR 0x3C 81 | /** @} */ 82 | 83 | /** 84 | * @name sx1276 (on-board) pins 85 | * 86 | * TTGO V1 sx1276 Lora transceiver pins 87 | * @{ 88 | */ 89 | #define SX127X_PARAM_SPI_NSS GPIO18 90 | #define SX127X_PARAM_SPI_RESET GPIO14 91 | #define SX127X_PARAM_DIO0 GPIO26 92 | #define SX127X_PARAM_DIO1 GPIO33 93 | #define SX127X_PARAM_DIO2 GPIO32 94 | #define SX127X_PARAM_DIO3 GPIO_UNDEF 95 | /** @} */ 96 | 97 | /* include common board definitions as last step */ 98 | #include "board_common.h" 99 | 100 | #endif /* BOARD_H */ 101 | /** @} */ 102 | -------------------------------------------------------------------------------- /examples/RIOT_TTGO_OLED/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "board.h" 5 | #include "thread.h" 6 | #include "shell.h" 7 | #include "shell_commands.h" 8 | 9 | #include "xtimer.h" 10 | 11 | #include "periph/gpio.h" 12 | #include "periph/i2c.h" 13 | #include "u8g2.h" 14 | 15 | /** 16 | * @brief RIOT-OS pin maping of U8g2 pin numbers to RIOT-OS GPIO pins. 17 | * @note To minimize the overhead, you can implement an alternative for 18 | * u8x8_gpio_and_delay_riotos. 19 | * The TTGO SSD1306 OLED screen uses I2C and has the reset pin 20 | * at GPIO 16. 21 | */ 22 | static gpio_t pins[] = { 23 | [U8X8_PIN_RESET] = OLED_RESET_PIN // See the board.h for the TTGO ESP32 Lora Oled pin reset definition 24 | }; 25 | 26 | /** 27 | * @brief Bit mapping to indicate which pins are set. 28 | */ 29 | static uint32_t pins_enabled = ( 30 | (1 << U8X8_PIN_RESET) 31 | ); 32 | 33 | u8g2_t u8g2; 34 | 35 | /** 36 | @brief RIOT-OS logo, 64x32 pixels at 8 pixels per byte. 37 | */ 38 | static const uint8_t logo[] = { 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3C, 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x1E, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x70, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x0E, 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0E, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0xF0, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x1E, 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3C, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0xF0, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0xF8, 48 | 0x30, 0x3C, 0x3F, 0xC0, 0x00, 0x0C, 0x77, 0xF0, 0x38, 0x7E, 0x3F, 0xC0, 49 | 0x00, 0x7E, 0x73, 0xC0, 0x38, 0xE7, 0x06, 0x00, 0x00, 0xFC, 0x71, 0x00, 50 | 0x38, 0xE3, 0x06, 0x00, 0x01, 0xF0, 0x70, 0x00, 0x38, 0xE3, 0x06, 0x00, 51 | 0x01, 0xC0, 0x70, 0x00, 0x38, 0xE3, 0x06, 0x00, 0x03, 0x80, 0x70, 0xC0, 52 | 0x38, 0xE3, 0x06, 0x00, 0x03, 0x80, 0x71, 0xE0, 0x38, 0xE3, 0x06, 0x00, 53 | 0x03, 0x80, 0x70, 0xE0, 0x38, 0xE3, 0x06, 0x00, 0x03, 0x80, 0x70, 0xF0, 54 | 0x38, 0xE3, 0x06, 0x00, 0x03, 0x80, 0x70, 0x70, 0x38, 0xE3, 0x06, 0x00, 55 | 0x03, 0x80, 0xF0, 0x78, 0x38, 0xE3, 0x06, 0x00, 0x03, 0xC1, 0xE0, 0x3C, 56 | 0x38, 0xE7, 0x06, 0x00, 0x01, 0xE3, 0xE0, 0x3C, 0x38, 0x7E, 0x06, 0x00, 57 | 0x01, 0xFF, 0xC0, 0x1C, 0x30, 0x3C, 0x06, 0x00, 0x00, 0x7F, 0x80, 0x00, 58 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 | 0x00, 0x00, 0x00, 0x00 61 | }; 62 | 63 | uint32_t screen = 0; 64 | 65 | void OLed_Init(void) { 66 | puts("Initializing OLED"); 67 | 68 | printf("Initializing I2C display at address 0x%02x.", OLED_I2C_ADDR); 69 | u8g2_Setup_ssd1306_i2c_128x64_noname_1(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_i2c, u8x8_gpio_and_delay_riotos); 70 | 71 | u8g2_SetPins(&u8g2, pins, pins_enabled); 72 | u8g2_SetDevice(&u8g2, I2C_DEV(0)); 73 | u8g2_SetI2CAddress(&u8g2, OLED_I2C_ADDR); 74 | 75 | /* initialize the display */ 76 | puts("Initializing display."); 77 | 78 | u8g2_InitDisplay(&u8g2); 79 | u8g2_SetPowerSave(&u8g2, 0); 80 | 81 | puts("OLED initialized"); 82 | } 83 | 84 | void OLed_Test(void) { 85 | int loop = 15; 86 | while (loop--) { 87 | puts("Drawing..."); 88 | u8g2_FirstPage(&u8g2); 89 | 90 | do { 91 | u8g2_SetDrawColor(&u8g2, 1); 92 | u8g2_SetFont(&u8g2, u8g2_font_helvB12_tf); 93 | 94 | switch (screen) { 95 | case 0: 96 | u8g2_DrawStr(&u8g2, 12, 22, "THIS"); 97 | break; 98 | case 1: 99 | u8g2_DrawStr(&u8g2, 24, 22, "IS"); 100 | break; 101 | case 2: 102 | u8g2_DrawBitmap(&u8g2, 0, 0, 8, 32, logo); 103 | break; 104 | } 105 | } 106 | while (u8g2_NextPage(&u8g2)); 107 | 108 | /* show screen in next iteration */ 109 | screen = (screen + 1) % 3; 110 | 111 | /* sleep a little */ 112 | puts("Sleeping..."); 113 | xtimer_sleep(1); 114 | } 115 | } 116 | 117 | static void oled_cmd_usage(void) { 118 | puts("Usage: oled init | test "); 119 | } 120 | 121 | static int oled_cmd(int argc, char **argv) 122 | { 123 | if ( argc < 2 ) { 124 | oled_cmd_usage(); 125 | return 1; 126 | } 127 | 128 | if ( strcmp(argv[1],"init") == 0 ) 129 | OLed_Init(); 130 | 131 | if ( strcmp(argv[1],"test") == 0 ) 132 | OLed_Test(); 133 | 134 | return 0; 135 | } 136 | 137 | static int draw_cmd(int argc, char **argv) { 138 | OLed_Test(); 139 | return 0; 140 | } 141 | 142 | static const shell_command_t shell_commands[] = { 143 | {"oled" , "Oled commands" , oled_cmd }, 144 | {"test" , "Test output on the oled" , draw_cmd }, 145 | { NULL , NULL , NULL} 146 | }; 147 | 148 | int main(void) 149 | { 150 | //gpio_t Oled_Reset = GPIO_PIN(0,16); 151 | 152 | puts("Welcome to RIOT!"); 153 | 154 | puts ("Initial Oled testing"); 155 | OLed_Init(); 156 | OLed_Test(); 157 | 158 | /*puts("Reseting OLED:"); 159 | gpio_init( Oled_Reset , GPIO_OUT); 160 | gpio_clear( Oled_Reset); 161 | xtimer_usleep(50); 162 | gpio_set(Oled_Reset) ; 163 | */ 164 | 165 | 166 | char line_buf[SHELL_DEFAULT_BUFSIZE]; 167 | shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); 168 | 169 | return 0; 170 | } 171 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/include/periph_conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Gunar Schorcht 3 | * 4 | * Modified by FCGDAM(2018) for supporting the TTGO V1 ESP32 LORA OLED board 5 | * 6 | * This file is subject to the terms and conditions of the GNU Lesser 7 | * General Public License v2.1. See the file LICENSE in the top level 8 | * directory for more details. 9 | */ 10 | 11 | /** 12 | * @ingroup boards_esp32_TTGO_LORA_V1 13 | * @brief Peripheral MCU configuration for TTGO V1 LORA OLED board 14 | * @{ 15 | * 16 | * For detailed information about the configuration of ESP32 boards, see 17 | * section \ref esp32_comm_periph "Common Peripherals". 18 | * 19 | * @note 20 | * Most definitions can be overridden by an \ref esp32_app_spec_conf 21 | * "application-specific board configuration". 22 | * 23 | * @file 24 | * @author Gunar Schorcht 25 | */ 26 | 27 | #ifndef PERIPH_CONF_H 28 | #define PERIPH_CONF_H 29 | 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /** 37 | * @name ADC and DAC channel configuration 38 | * @{ 39 | */ 40 | /** 41 | * @brief Declaration of GPIOs that can be used as ADC channels 42 | * 43 | * For generic boards, all ADC pins that have broken out are declared as ADC 44 | * channels. 45 | * 46 | * @note As long as the GPIOs listed in ADC_GPIOS are not initialized as ADC 47 | * channels with the ```adc_init``` function, they can be used for other 48 | * purposes. 49 | */ 50 | #ifndef ADC_GPIOS 51 | #define ADC_GPIOS { GPIO36, GPIO37, GPIO38, GPIO39, GPIO32, GPIO33, GPIO34, GPIO35, \ 52 | GPIO4, GPIO0, GPIO2, GPIO15, GPIO13, GPIO12, GPIO14, GPIO25, GPIO26 } 53 | #endif 54 | 55 | /** 56 | * @brief Declaration of GPIOs that can be used as DAC channels 57 | * 58 | * For generic boards the 2 DAC lines GPIO25 and GPIO26 are declared as 59 | * DAC channels. 60 | * 61 | * @note As long as the GPIOs listed in DAC_GPIOS are not initialized as DAC 62 | * channels with the ```dac_init``` function, they can be used for other 63 | * purposes. 64 | */ 65 | #ifndef DAC_GPIOS 66 | #define DAC_GPIOS { GPIO25 } 67 | #endif 68 | /** @} */ 69 | 70 | /** 71 | * @name I2C configuration 72 | * 73 | * Only one I2C interface I2C_DEV(0) is defined for the TTGO board. 74 | * The I2C Speed must be set to NORMAL, otherwise the display won't work 75 | * 76 | * The GPIOs listed in the configuration are only initialized as I2C signals 77 | * when module ```perpih_i2c``` is used. Otherwise they are not allocated and 78 | * can be used for other purposes. 79 | * 80 | * @{ 81 | */ 82 | #ifndef I2C0_SPEED 83 | #define I2C0_SPEED I2C_SPEED_NORMAL /**< I2C bus speed of I2C_DEV(0) */ 84 | #endif 85 | #ifndef I2C0_SCL 86 | #define I2C0_SCL GPIO15 /**< SCL signal of I2C_DEV(0) [UEXT1] */ 87 | #endif 88 | #ifndef I2C0_SDA 89 | #define I2C0_SDA GPIO4 /**< SDA signal of I2C_DEV(0) [UEXT1] */ 90 | #endif 91 | /** @} */ 92 | 93 | /** 94 | * @name PWM channel configuration 95 | * 96 | * For generic boards, two PWM devices are configured. These devices 97 | * contain all GPIOs that are not defined as I2C, SPI or UART for this board. 98 | * Generally, all outputs pins could be used as PWM channels. 99 | * 100 | * @note As long as the according PWM device is not initialized with 101 | * the ```pwm_init```, the GPIOs declared for this device can be used 102 | * for other purposes. 103 | * 104 | * @{ 105 | */ 106 | 107 | /** 108 | * @brief Declaration of the channels for device PWM_DEV(0), 109 | * at maximum six channels. 110 | */ 111 | #ifndef PWM0_GPIOS 112 | #define PWM0_GPIOS { GPIO0, GPIO17 } 113 | #endif 114 | 115 | /** 116 | * @brief Declaration of the channels for device PWM_DEV(1), 117 | * at maximum six channels. 118 | */ 119 | #ifndef PWM1_GPIOS 120 | #define PWM1_GPIOS { GPIO27 } 121 | #endif 122 | /** @} */ 123 | 124 | /** 125 | * @name SPI configuration 126 | * 127 | * @note The GPIOs listed in the configuration are first initialized as SPI 128 | * signals when the corresponding SPI interface is used for the first time 129 | * by either calling the ```spi_init_cs``` function or the ```spi_acquire``` 130 | * function. That is, they are not allocated as SPI signals before and can 131 | * be used for other purposes as long as the SPI interface is not used. 132 | * @{ 133 | */ 134 | #ifndef SPI0_CTRL 135 | #define SPI0_CTRL VSPI /**< VSPI is used as SPI_DEV(0) */ 136 | #endif 137 | #ifndef SPI0_SCK 138 | #define SPI0_SCK GPIO5 /**< VSPI SCK */ 139 | #endif 140 | #ifndef SPI0_MISO 141 | #define SPI0_MISO GPIO19 /**< VSPI MISO */ 142 | #endif 143 | #ifndef SPI0_MOSI 144 | #define SPI0_MOSI GPIO27 /**< VSPI MOSI */ 145 | #endif 146 | #ifndef SPI0_CS0 147 | #define SPI0_CS0 GPIO18 /**< VSPI CS0 */ 148 | #endif 149 | 150 | //#ifndef SPI1_DEV 151 | //#define SPI1_DEV HSPI /**< HSPI is used as SPI_DEV(1) */ 152 | //#endif 153 | //#ifndef SPI1_SCK 154 | //#define SPI1_SCK GPIO14 /**< HSPI SCK */ 155 | //#endif 156 | //#ifndef SPI1_MISO 157 | //#define SPI1_MISO GPIO12 /**< HSPI MISO */ 158 | //#endif 159 | //#ifndef SPI1_MOSI 160 | //#define SPI1_MOSI GPIO13 /**< HSPI MOSI */ 161 | //#endif 162 | //#ifndef SPI1_CS0 163 | //#define SPI1_CS0 GPIO15 /**< HSPI CS0 */ 164 | //#endif 165 | /** @} */ 166 | 167 | /** 168 | * @name UART configuration 169 | * 170 | * ESP32 provides 3 UART interaces at maximum: 171 | * 172 | * UART_DEV(0) uses fixed standard configuration.
173 | * UART_DEV(1) is defined here.
174 | * UART_DEV(2) is not used.
175 | * 176 | * @{ 177 | */ 178 | #define UART0_TXD GPIO10 /**< direct I/O pin for UART_DEV(0) TxD, can't be changed */ 179 | #define UART0_RXD GPIO9 /**< direct I/O pin for UART_DEV(0) RxD, can't be changed */ 180 | 181 | #if FLASH_MODE_DOUT || FLASH_MODE_DIO || DOXYGEN 182 | #ifndef UART1_TXD 183 | #define UART1_TXD GPIO10 /**< direct I/O pin for UART_DEV(1) TxD */ 184 | #endif 185 | #ifndef UART1_RXD 186 | #define UART1_RXD GPIO9 /**< direct I/O pin for UART_DEV(1) RxD */ 187 | #endif 188 | #else 189 | #warning Configuration problem: Flash mode is qio or qout, \ 190 | GPIO9 and GPIO10 are not available for UART1 as configured 191 | #endif 192 | /** @} */ 193 | 194 | 195 | #ifdef __cplusplus 196 | } /* end extern "C" */ 197 | #endif 198 | 199 | /* include common peripheral definitions as last step */ 200 | #include "periph_conf_common.h" 201 | 202 | #endif /* PERIPH_CONF_H */ 203 | /** @} */ 204 | -------------------------------------------------------------------------------- /examples/RIOT_TTGO_TTN/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Inria 3 | * 4 | * This file is subject to the terms and conditions of the GNU Lesser 5 | * General Public License v2.1. See the file LICENSE in the top level 6 | * directory for more details. 7 | */ 8 | 9 | /** 10 | * @ingroup examples 11 | * @{ 12 | * 13 | * @file 14 | * @brief Example demonstrating the use of LoRaWAN with RIOT 15 | * 16 | * @author Alexandre Abadie 17 | * @author fcgdam 18 | * 19 | * @} 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "msg.h" 28 | #include "thread.h" 29 | #include "fmt.h" 30 | 31 | #include "periph/rtc.h" 32 | 33 | #include "net/loramac.h" 34 | #include "semtech_loramac.h" 35 | 36 | /* Messages are sent every 20s to respect the duty cycle on each channel */ 37 | #define PERIOD (20U) 38 | 39 | #define SENDER_PRIO (THREAD_PRIORITY_MAIN - 1) 40 | static kernel_pid_t sender_pid; 41 | static char sender_stack[THREAD_STACKSIZE_MAIN / 2]; 42 | 43 | uint8_t nodeactivation = NODEACTIVATION; 44 | semtech_loramac_t loramac; 45 | 46 | static const char *message = "This is RIOT!"; 47 | 48 | /* Information for OTAA activation 49 | */ 50 | static uint8_t deveui[LORAMAC_DEVEUI_LEN]; 51 | static uint8_t appeui[LORAMAC_APPEUI_LEN]; 52 | static uint8_t appkey[LORAMAC_APPKEY_LEN]; 53 | 54 | /* Information for ABP activation 55 | */ 56 | uint8_t devaddr[LORAMAC_DEVADDR_LEN]; 57 | uint8_t appskey[LORAMAC_APPSKEY_LEN]; 58 | uint8_t nwkskey[LORAMAC_NWKSKEY_LEN]; 59 | 60 | static void rtc_cb(void *arg) 61 | { 62 | (void) arg; 63 | msg_t msg; 64 | msg_send(&msg, sender_pid); 65 | } 66 | 67 | static void _prepare_next_alarm(void) 68 | { 69 | struct tm time; 70 | rtc_get_time(&time); 71 | /* set initial alarm */ 72 | time.tm_sec += PERIOD; 73 | mktime(&time); 74 | rtc_set_alarm(&time, rtc_cb, NULL); 75 | } 76 | 77 | static void _send_message(void) 78 | { 79 | printf("Sending: %s\n", message); 80 | /* The send call blocks until done */ 81 | semtech_loramac_send(&loramac, (uint8_t *)message, strlen(message)); 82 | /* Wait until the send cycle has completed */ 83 | puts("Waiting for completion..."); 84 | semtech_loramac_recv(&loramac); 85 | puts("Sending done!"); 86 | } 87 | 88 | static void *sender(void *arg) 89 | { 90 | (void)arg; 91 | 92 | msg_t msg; 93 | msg_t msg_queue[8]; 94 | msg_init_queue(msg_queue, 8); 95 | 96 | puts("Startup Sender thread."); 97 | 98 | while (1) { 99 | 100 | /* Trigger the message send */ 101 | _send_message(); 102 | 103 | /* Schedule the next wake-up alarm */ 104 | _prepare_next_alarm(); 105 | puts("Waiting for trigger message"); 106 | msg_receive(&msg); 107 | } 108 | 109 | /* this should never be reached */ 110 | return NULL; 111 | } 112 | 113 | int main(void) 114 | { 115 | uint8_t joined = 0; 116 | 117 | puts("LoRaWAN Class A low-power application"); 118 | puts("====================================="); 119 | printf(" -> Node activation by: "); 120 | if ( nodeactivation ) { 121 | puts("OTAA"); 122 | } else { 123 | puts("ABP"); 124 | } 125 | 126 | /* Create the Loramac LORAWAN stack. */ 127 | semtech_loramac_init(&loramac); 128 | 129 | semtech_loramac_set_tx_mode(&loramac , LORAMAC_TX_UNCNF ); 130 | 131 | 132 | /* Convert identifiers and application key */ 133 | fmt_hex_bytes(deveui, DEVEUI); 134 | fmt_hex_bytes(appeui, APPEUI); 135 | fmt_hex_bytes(appkey, APPKEY); 136 | 137 | fmt_hex_bytes(devaddr, DEVADDR); 138 | fmt_hex_bytes(appskey, APPSKEY); 139 | fmt_hex_bytes(nwkskey, NWKSKEY); 140 | 141 | /* Initialize the loramac stack */ 142 | if ( nodeactivation ) { 143 | puts("Set OTAA information."); 144 | semtech_loramac_set_deveui(&loramac, deveui); 145 | semtech_loramac_set_appeui(&loramac, appeui); 146 | semtech_loramac_set_appkey(&loramac, appkey); 147 | } else { 148 | puts("Set ABP information."); 149 | semtech_loramac_set_devaddr(&loramac, devaddr); 150 | semtech_loramac_set_appskey(&loramac, appskey); 151 | semtech_loramac_set_nwkskey(&loramac, nwkskey); 152 | 153 | printf("Dev addr: %02X%02X%02X%02X\n", devaddr[0], devaddr[1], devaddr[2], devaddr[3] ); 154 | printf("App Session Key: %02X%02X%02X%02X...\n", appskey[0], appskey[1], appskey[2], appskey[3] ); 155 | printf("Network Session Key: %02X%02X%02X%02X...\n", nwkskey[0], nwkskey[1], nwkskey[2], nwkskey[3] ); 156 | } 157 | 158 | /* Use a fast datarate, e.g. BW125/SF7 in EU868 */ 159 | semtech_loramac_set_dr(&loramac, LORAMAC_DR_1); 160 | 161 | while ( !joined ) { 162 | /* Start the Over-The-Air Activation (OTAA) procedure to retrieve the 163 | * generated device address and to get the network and application session 164 | * keys. 165 | */ 166 | joined = 1; /* Let's assume success for now, and it fails we reset the variable. */ 167 | if ( nodeactivation ) { 168 | puts("[Sender Thread] Starting join procedure..."); 169 | if (semtech_loramac_join(&loramac, LORAMAC_JOIN_OTAA) != SEMTECH_LORAMAC_JOIN_SUCCEEDED) { 170 | puts("Join procedure failed"); 171 | joined = 0; 172 | } 173 | } else { 174 | puts("[Sender Thread] Starting ABP node activation..."); 175 | if (semtech_loramac_join(&loramac, LORAMAC_JOIN_ABP) != SEMTECH_LORAMAC_JOIN_SUCCEEDED) { 176 | puts("Join procedure failed"); 177 | joined = 0; 178 | } 179 | } 180 | 181 | 182 | if ( !joined ) { 183 | /* Should only reach this if the join failed. 184 | Let's sleep for a while and try again. */ 185 | puts("[Sender Thread] Joined failed... Sleeping 60s..."); 186 | xtimer_sleep(60); 187 | puts("[Sender Thread] Let's try again to join..."); 188 | } 189 | } 190 | 191 | puts("[Sender Thread] Join/ABP procedure succeeded"); 192 | xtimer_sleep(4); 193 | 194 | /* start the sender thread */ 195 | sender_pid = thread_create(sender_stack, sizeof(sender_stack), SENDER_PRIO, 0, sender, NULL, "sender"); 196 | 197 | xtimer_sleep(2); 198 | /* trigger the first send */ 199 | puts("Send trigger message"); 200 | msg_t msg; 201 | msg_send(&msg, sender_pid); 202 | return 0; 203 | } 204 | -------------------------------------------------------------------------------- /boards/esp32-ttgo-lora32-v1/doc.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Gunar Schorcht 3 | * 4 | * This file is subject to the terms and conditions of the GNU Lesser 5 | * General Public License v2.1. See the file LICENSE in the top level 6 | * directory for more details. 7 | */ 8 | 9 | /** 10 | * @defgroup boards_esp32_wroom-32 Generic ESP32-WROOM-32 boards 11 | * @ingroup boards_esp32 12 | * @brief Support for generic ESP32-WROOM-32 boards 13 | * @author Gunar Schorcht 14 | 15 | ## Table of Contents 16 | 17 | 1. [Overview](#overview) 18 | 2. [Hardware](#hardware) 19 | 1. [MCU](#mcu) 20 | 2. [Board Configuration](#board_configuration) 21 | 3. [Board Pinout](#pinout) 22 | 4. [Optional Hardware Configurations](#optional_hardware) 23 | 3. [Flashing the Device](#flashing) 24 | 25 | ## Overview    [[TOC](#toc)] 26 | 27 | This board definition covers not just a single board, but rather a large set of generic boards that use an ESP32-WROOM-32 module and simply break out all GPIOs to external pads without having any special hardware or interfaces on-board. Examples are Espressif's ESP32-DevKitC or NodeMCU-ESP32S and a large number of clones. 28 | 29 | \htmlonly\endhtmlonly 30 | \image html "https://docs.espressif.com/projects/esp-idf/en/latest/_images/esp32-devkitc-functional-overview1.jpg" "Espressif ESP32-DevKitC V4" 31 | 32 | ## Hardware    [[TOC](#toc)] 33 | 34 | This section describes 35 | 36 | - the [MCU](#mcu), 37 | - the default [board configuration](#board_configuration), 38 | - [optional hardware configurations](#optional_hardware), 39 | - the [board pinout](#pinout). 40 | 41 | ### MCU    [[TOC](#toc)] 42 | 43 | Most features of ESP32 boards are provided by the ESP32 SoC. The following table summarizes these features and gives an overview of which of these features are supported by RIOT. For detailed information about the ESP32, see section \ref esp32_mcu "MCU ESP32". 44 | 45 |
46 | MCU | ESP32 | Supported by RIOT 47 | ------------|-----------|------------------ 48 | Vendor | Espressif | | 49 | Cores | 1 or 2 x Tensilica Xtensa LX6 | 1 core 50 | FPU | yes (ULP - Ultra low power co-processor) | no 51 | RAM | 520 kByte SRAM
16 kByte RTC SRAM | yes 52 | ROM | 520 kByte | yes 53 | Flash | 512 kByte ... 16 MByte | yes 54 | Frequency | 240 MHz, 160 MHz, 80 MHz | yes 55 | Power Consumption | 68 mA @ 240 MHz
44 mA @ 160 MHz
31 mA @ 80 MHz
5 uA in deep sleep mode | yes
yes
yes
no 56 | Timers | 4 x 64 bit | yes 57 | ADCs | 2 x SAR-ADC with up to 18 x 12 bit channels total | yes 58 | DACs | 2 x DAC with 8 bit | yes 59 | GPIOs | 34 (6 of them are only inputs) | yes 60 | I2Cs | 2 | yes 61 | SPIs | 4 | yes 62 | UARTs | 3 | yes 63 | WiFi | IEEE 802.11 b/g/n built in | yes 64 | Bluetooth | v4.2 BR/EDR and BLE | no 65 | Ethernet | MAC interface with dedicated DMA and IEEE 1588 support | yes 66 | CAN | version 2.0 | no 67 | IR | up to 8 channels TX/RX | no 68 | Motor PWM | 2 devices x 6 channels | yes 69 | LED PWM | 16 channels | no 70 | Crypto | Hardware acceleration of AES, SHA-2, RSA, ECC, RNG | no 71 | Vcc | 2.5 - 3.6 V | | 72 | Documents | [Datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf)
[Technical Reference](https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf) | | 73 |
74 | 75 | ### Board Configuration    [[TOC](#toc)] 76 | 77 | Generic ESP32-WROOM-32 boards do not have special hardware on board and all GPIOs are simply broken out for flexibility. Therefore, the board configuration is the most flexible one with provides: 78 | 79 | 18 x ADC channels at maximum 80 | 2 x DAC channels at maximum 81 | 2 x SPI at maximum 82 | 1 x I2C at maximum 83 | 2 x UART 84 | 85 | Since all GPIOs have broken out, GPIOs can be used for different purposes in different applications. For flexibility, GPIOs can be listed in various peripheral configurations. For example, GPIO13 is used in the ADC channel definition and the definition of the MOSI signal of SPI_DEV(0). 86 | 87 | This is possible because GPIOs are only used for a specific peripheral interface when 88 | 89 | - the corresponding peripheral module is used, eg. periph_i2c, or 90 | - a corresponding init function is called z. adc_init, dac_init and pwm_init or 91 | - The corresponding peripheral interface is used for the first time, eg. spi_aqcuire. 92 | 93 | That is, the purpose for which a GPIO is used depends on which module or function is used first. 94 | 95 | For example, if module periph_i2c is not used, the GPIOs listed in I2C configuration can be used for the other purposes. 96 | 97 | The following table shows the default board configuration, which is sorted according to the defined functionality of GPIOs. This configuration can be overridden by \ref esp32_app_spec_conf "application-specific configurations". 98 | 99 |
100 | \anchor esp32_wroom_32_table_board_configuration 101 | Function | GPIOs | Remarks |Configuration 102 | :---------------|:-------|:--------|:---------------------------------- 103 | BUTTON0 | GPIO0 | | | 104 | ADC | GPIO0, GPIO2, GPIO4, GPIO12, GPIO13,
GPIO14, GPIO15, GPIO25, GPIO26, GPIO27,
GPIO32, GPIO33, GPIO34, GPIO35, GPIO36,
GPIO39 | | see \ref esp32_adc_channels "ADC Channels" 105 | DAC | GPIO25, GPIO26 | | \ref esp32_dac_channels "refer" 106 | PWM_DEV(0) | GPIO0, GPIO2, GPIO4, GPIO16, GPIO17 | - | \ref esp32_pwm_channels "DAC Channels" 107 | PWM_DEV(1) | GPIO27, GPIO32, GPIO33 | - | \ref esp32_pwm_channels "PWM Channels" 108 | I2C_DEV(0):SDA | GPIO21 | | \ref esp32_i2c_interfaces "I2C Interfaces" 109 | I2C_DEV(0):SCL | GPIO22 | | \ref esp32_i2c_interfaces "I2C Interfaces" 110 | SPI_DEV(0):CLK | GPIO18 | VSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" 111 | SPI_DEV(0):MISO | GPIO19 | VSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" 112 | SPI_DEV(0):MOSI | GPIO23 | VSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" 113 | SPI_DEV(0):CS0 | GPIO5 | VSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" 114 | SPI_DEV(1):CLK | GPIO14 | HSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" 115 | SPI_DEV(1):MISO | GPIO12 | HSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" 116 | SPI_DEV(1):MOSI | GPIO13 | HSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" 117 | SPI_DEV(1):CS0 | GPIO15 | HSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" 118 | UART_DEV(0):TxD | GPIO1 | Console (configuration is fixed) | \ref esp32_uart_interfaces "UART interfaces" 119 | UART_DEV(0):RxD | GPIO3 | Console (configuration is fixed) | \ref esp32_uart_interfaces "UART interfaces" 120 | UART_DEV(1):TxD | GPIO10 | not available in **qout** and **qio** flash mode | \ref esp32_uart_interfaces "UART interfaces" 121 | UART_DEV(1):RxD | GPIO9 | not available in **qout** and **qio** flash mode | \ref esp32_uart_interfaces "UART interfaces" 122 |
123 | 124 | @note 125 | - The configuration of ADC channels contains all ESP32 GPIOs that can be used as ADC channels. 126 | - The configuration of DAC channels contains all ESP32 GPIOs that can be used as DAC channels. 127 | - GPIO9 and GIOP10 can only be used in **dout** and **dio** \ref esp32_flash_modes "flash modes". 128 | 129 | For detailed information about the configuration of ESP32 boards, see section \ref esp32_comm_periph "Common Peripherals". 130 | 131 | ### Optional Hardware Configurations    [[TOC](#toc)] 132 | 133 | MRF24J40-based IEEE 802.15.4 radio modules and ENC28J60-based Ethernet network interface modules have been tested with the board. You could use the following code in your \ref esp32_app_spec_conf "application-specific configuration" to use such modules: 134 | 135 | ``` 136 | #ifdef BOARD_ESP32_WROOM-32 137 | 138 | #if MODULE_MRF24J40 139 | #define MRF24J40_PARAM_CS GPIO16 /* MRF24J40 CS signal */ 140 | #define MRF24J40_PARAM_RESET GPIO17 /* MRF24J40 RESET signal */ 141 | #define MRF24J40_PARAM_INT GPIO34 /* MRF24J40 INT signal */ 142 | #endif 143 | 144 | #if MODULE_ENC28J80 145 | #define ENC28J80_PARAM_CS GPIO32 /* ENC28J80 CS signal */ 146 | #define ENC28J80_PARAM_RESET GPIO33 /* ENC28J80 RESET signal */ 147 | #define ENC28J80_PARAM_INT GPIO35 /* ENC28J80 INT signal */ 148 | endif 149 | 150 | #endif 151 | ``` 152 | For other parameters, the default values defined by the drivers can be used. 153 | 154 | @note The **RESET** signal of MRF24J40 and ENC28J60 based modules can also be connected to the **RST** pin of the board (see \ref esp32_wroom_32_pinout "pinout") to keep the configured GPIO free for other purposes. 155 | 156 | ### Board Pinout    [[TOC](#toc)] 157 | 158 | The following figure shows the pinout of the defined default configuration for the EPS32-DevKitC board as an example of generic ESP32-WROOM-32 boards. The light green GPIOs are not used by configured on-board hardware components and can be used for any purpose. However, if optional off-board hardware modules are used, these GPIOs may also be occupied, see \ref esp32_wroom_32_table_board_configuration "optional functions" in table board configuration. 159 | 160 | The corresponding board schematics can be found her [here](https://dl.espressif.com/dl/schematics/esp32_devkitc_v4-sch-20180607a.pdf) 161 | 162 | \anchor esp32_wroom_32_pinout 163 | @image html "https://gitlab.com/gschorcht/RIOT.wiki-Images/raw/master/esp32/ESP32-WROOM-32_pinouts.png?inline=false" "EPS32-DevKitC V4 Pinout" 164 | 165 | ## Flashing the Device    [[TOC](#toc)] 166 | 167 | Flashing RIOT is quite easy. The board has a Micro-USB connector with reset/boot/flash logic. Just connect the board to your host computer and type using the programming port: 168 | ``` 169 | make flash BOARD=esp32-wroom-32 ... 170 | ``` 171 | For detailed information about ESP32 as well as configuring and compiling RIOT for ESP32 boards, see \ref esp32_riot. 172 | 173 | */ 174 | --------------------------------------------------------------------------------