Skip to content
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.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions boards/common/esp32/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = boards_common_esp32

include $(RIOTBASE)/Makefile.base
5 changes: 5 additions & 0 deletions boards/common/esp32/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include $(RIOTCPU)/esp32/Makefile.dep

ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
12 changes: 12 additions & 0 deletions boards/common/esp32/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# most board features results directly from ESP32 CPU features
include $(RIOTCPU)/esp32/Makefile.features

# additional features provided by all boards are GPIOs and at least one UART
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_gpio_irq
FEATURES_PROVIDED += periph_uart

# other features provided by all boards
FEATURES_PROVIDED += esp_spiffs
FEATURES_PROVIDED += esp_wifi
FEATURES_PROVIDED += esp_now
11 changes: 11 additions & 0 deletions boards/common/esp32/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# the cpu to build for
export CPU ?= esp32
export CPU_MODEL ?= esp32

# configure the serial interface
PORT_LINUX ?= /dev/ttyUSB0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
include $(RIOTMAKE)/tools/serial.inc.mk

# reset tool configuration
export RESET = esptool.py --before default_reset run
103 changes: 103 additions & 0 deletions boards/common/esp32/board_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (C) 2018 Gunar Schorcht
*
* 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_common_esp32 ESP32 Board Commons
* @ingroup boards_common
* @brief Common definitions for all ESP32 boards
* @{
*
* @file
* @brief Common declarations and functions for all ESP32 boards.
*
* This file contains default declarations and functions that are valid
* for all ESP32 boards.
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/

#include "board.h"
#include "esp_common.h"
#include "log.h"
#include "periph/gpio.h"
#include "periph/spi.h"
#include "rom/ets_sys.h"

#ifdef __cplusplus
extern "C" {
#endif

void board_init(void)
{
#ifdef LED0_PIN
gpio_init (LED0_PIN, GPIO_OUT);
LED0_OFF;
#endif
#ifdef LED1_PIN
gpio_init (LED1_PIN, GPIO_OUT);
LED1_OFF;
#endif
#ifdef LED2_PIN
gpio_init (LED2_PIN, GPIO_OUT);
LED2_OFF;
#endif
}

extern void adc_print_config(void);
extern void pwm_print_config(void);
extern void i2c_print_config(void);
extern void spi_print_config(void);
extern void uart_print_config(void);
extern void can_print_config(void);

void print_board_config (void)
{
ets_printf("\nBoard configuration:\n");

adc_print_config();
pwm_print_config();
i2c_print_config();
spi_print_config();
uart_print_config();

#ifdef MODULE_ESP_CAN
can_print_config();
#endif

ets_printf("\tLED\t\tpins=[ ");
#ifdef LED0_PIN
ets_printf("%d ", LED0_PIN);
#endif
#ifdef LED1_PIN
ets_printf("%d ", LED1_PIN);
#endif
#ifdef LED2_PIN
ets_printf("%d ", LED2_PIN);
#endif
ets_printf("]\n");

ets_printf("\tBUTTONS\t\tpins=[ ");
#ifdef BUTTON0_PIN
ets_printf("%d ", BUTTON0_PIN);
#endif
#ifdef BUTTON2_PIN
ets_printf("%d ", BUTTON1_PIN);
#endif
#ifdef BUTTON3_PIN
ets_printf("%d ", BUTTON2_PIN);
#endif
ets_printf("]\n");

ets_printf("\n");
}

#ifdef __cplusplus
} /* end extern "C" */
#endif

/** @} */
29 changes: 29 additions & 0 deletions boards/common/esp32/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2018 Gunar Schorcht
*
* 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_common_esp32 ESP32 Common
* @ingroup boards_common
* @ingroup boards_esp32
* @brief Definitions and configurations that are common for
* all ESP32 boards.
*
* For detailed information about the ESP32, configuring and compiling RIOT
* for ESP32 boards, please refer \ref esp32_riot.
*/

/**
* @defgroup boards_esp32 ESP32 Boards
* @ingroup boards
* @brief This group of boards contains the documentation
* defined ESP32 boards.
*
* @note For detailed information about the ESP32 SoC, the tool chain
* as well as configuring and compiling RIOT for ESP32 boards,
* see \ref esp32_riot.
*/
72 changes: 72 additions & 0 deletions boards/common/esp32/include/arduino_board_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2018 Gunar Schorcht
*
* 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_common_esp32
* @{
*
* @file
* @brief Common board for the Arduino API
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/

#ifndef ARDUINO_BOARD_COMMON_H
#define ARDUINO_BOARD_COMMON_H

#include "arduino_pinmap.h"

#ifdef __cplusplus
extern "C"
{
#endif

/**
* @brief Look-up table for the Arduino's digital pins
*/
static const gpio_t arduino_pinmap[] = {
ARDUINO_PIN_0,
ARDUINO_PIN_1,
ARDUINO_PIN_2,
ARDUINO_PIN_3,
ARDUINO_PIN_4,
ARDUINO_PIN_5,
ARDUINO_PIN_6,
ARDUINO_PIN_7,
ARDUINO_PIN_8,
ARDUINO_PIN_9,
ARDUINO_PIN_10,
ARDUINO_PIN_11,
ARDUINO_PIN_12,
ARDUINO_PIN_13,
ARDUINO_PIN_A0,
ARDUINO_PIN_A1,
ARDUINO_PIN_A2,
ARDUINO_PIN_A3,
ARDUINO_PIN_A4,
ARDUINO_PIN_A5
};

/**
* @brief Look-up table for the Arduino's analog pins
*/
static const adc_t arduino_analog_map[] = {
ARDUINO_PIN_A0,
ARDUINO_PIN_A1,
ARDUINO_PIN_A2,
ARDUINO_PIN_A3,
ARDUINO_PIN_A4,
ARDUINO_PIN_A5
};

#ifdef __cplusplus
}
#endif

#endif /* ARDUINO_BOARD_COMMON_H */
/** @} */
148 changes: 148 additions & 0 deletions boards/common/esp32/include/board_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* Copyright (C) 2018 Gunar Schorcht
*
* 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_common_esp32
* @brief Board definitions that are common for all ESP32 boards.
*
* This file contains board configurations that are valid for all ESP32.
*
* For detailed information about the configuration of ESP32 boards, see
* section \ref esp32_comm_periph "Common Peripherals".
*
* @author Gunar Schorcht <gunar@schorcht.net>
* @file
* @{
*/

#ifndef BOARD_COMMON_H
#define BOARD_COMMON_H

#include <stdint.h>

#include "cpu.h"
#include "periph_conf.h"
#include "arduino_pinmap.h"

#include "periph/gpio.h"
#include "sdk_conf.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name LED configuration (three predefined LEDs at maximum)
*
* @note LEDx_ACTIVE value must be declared in board configuration.
* @{
*/
#if defined(LED0_PIN) || DOXYGEN
#define LED0_MASK (BIT(LED0_PIN))
#define LED0_ON (gpio_write(LED0_PIN, LED0_ACTIVE))
#define LED0_OFF (gpio_write(LED0_PIN, !LED0_ACTIVE))
#define LED0_TOGGLE (gpio_toggle(LED0_PIN))
#endif

#if defined(LED1_PIN) || DOXYGEN
#define LED1_MASK (BIT(LED1_PIN))
#define LED1_ON (gpio_write(LED1_PIN, LED1_ACTIVE))
#define LED1_OFF (gpio_write(LED1_PIN, !LED1_ACTIVE))
#define LED1_TOGGLE (gpio_toggle(LED1_PIN))
#endif

#if defined(LED2_PIN) || DOXYGEN
#define LED2_MASK (BIT(LED2_PIN))
#define LED2_ON (gpio_write(LED2_PIN, LED2_ACTIVE))
#define LED2_OFF (gpio_write(LED2_PIN, !LED2_ACTIVE))
#define LED2_TOGGLE (gpio_toggle(LED2_PIN))
#endif
/** @} */


/**
* @name STDIO configuration
* @{
*/
/**< Default baudrate of UART for stdio */
#ifndef STDIO_UART_BAUDRATE
#define STDIO_UART_BAUDRATE (115200)
#endif
/** @} */


#if MODULE_MTD || DOXYGEN
/**
* @name MTD system drive configuration
*
* Built-in SPI flash memory is used as MTD system drive.
* @{
*/
#include "mtd.h"

/**
* @brief MTD drive start address in SPI flash memory
*
* Defines the start adress of the MTD system device in the SPI
* flash memory. It can be overridden by \ref esp32_app_spec_conf
* "application-specific board configuration"
*
* If the MTD start address is not defined or is 0, the first possible
* multiple of 0x100000 (1 MByte) is used in free SPI flash memory,
* which was determined from the partition table.
*/
#ifndef SPI_FLASH_DRIVE_START
#define SPI_FLASH_DRIVE_START 0
#endif

/** Default MTD drive definition */
#define MTD_0 mtd0

/** Pointer to the default MTD drive structure */
extern mtd_dev_t *mtd0;

/** @} */
#endif /* MODULE_MTD || DOXYGEN */


#if MODULE_SPIFFS || DOXYGEN
/**
* @name SPIFFS configuration for the system MTD device
*
* Configuration of the SPIFFS that can be used on the system MTD device.
* @{
*/
#define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 1
#define SPIFFS_READ_ONLY 0
#define SPIFFS_SINGLETON 0
#define SPIFFS_HAL_CALLBACK_EXTRA 1
#define SPIFFS_CACHE 1
/** @} */
#endif /* MODULE_SPIFFS || DOXYGEN */


/**
* @brief Initialize board specific hardware
*
* Since all features of ESP32 boards are provided by the SOC, almost all
* initializations are done during the CPU initialization that is called from
* boot loader.
*/
void board_init (void);

/**
* @brief Print the board configuration in a human readable format
*/
void print_board_config (void);

#ifdef __cplusplus
} /* end extern "C" */
#endif

#endif /* BOARD_COMMON_H */
/** @} */
Loading