-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
144 changed files
with
30,440 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = boards_common_esp32 | ||
|
||
include $(RIOTBASE)/Makefile.base |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# on ESP32 modules all board features results directly from CPU features | ||
# therefore just include CPU's Makefile.features | ||
|
||
include $(RIOTCPU)/esp32/Makefile.features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* 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 <[email protected]> | ||
*/ | ||
|
||
#include "board_common.h" | ||
#include "common.h" | ||
#include "log.h" | ||
#include "periph/gpio.h" | ||
#include "periph/spi.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
void board_init(void) | ||
{ | ||
for (int i = 0; i < SPI_NUMOF; i++) | ||
spi_init (SPI_DEV(i)); | ||
} | ||
|
||
static uint32_t leds1_initialized = 0x0; /* GPIOs 0 ... 31 */ | ||
static uint32_t leds2_initialized = 0x0; /* GPIOs 32 ... 39 */ | ||
|
||
static void _led_init(uint8_t led) | ||
{ | ||
uint32_t led_mask = (led < 32) ? BIT(led) : BIT(led - 32); | ||
uint32_t* led_init = (led < 32) ? &leds1_initialized : &leds2_initialized; | ||
|
||
if (!(*led_init & led_mask)) | ||
{ | ||
gpio_init (led, GPIO_OUT); | ||
*led_init |= led_mask; | ||
} | ||
} | ||
|
||
void led_on_off (uint8_t led, uint8_t value) | ||
{ | ||
_led_init(led); | ||
gpio_write(led, value ? 0 : 1); | ||
} | ||
|
||
void led_toggle (uint8_t led) | ||
{ | ||
_led_init(led); | ||
gpio_toggle(led); | ||
} | ||
|
||
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); | ||
|
||
void print_board_config (void) | ||
{ | ||
adc_print_config(); | ||
pwm_print_config(); | ||
i2c_print_config(); | ||
spi_print_config(); | ||
uart_print_config(); | ||
|
||
LOG_INFO("LED: pins=[ "); | ||
#ifdef LED0_PIN | ||
LOG_INFO("%d ", LED0_PIN); | ||
#endif | ||
#ifdef LED1_PIN | ||
LOG_INFO("%d ", LED1_PIN); | ||
#endif | ||
#ifdef LED2_PIN | ||
LOG_INFO("%d ", LED2_PIN); | ||
#endif | ||
LOG_INFO("]\n"); | ||
} | ||
|
||
#ifdef __cplusplus | ||
} /* end extern "C" */ | ||
#endif | ||
|
||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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 | ||
* @brief Definitions that are common for all esp32 boards. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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 Common declarations and functions for all ESP32 boards. | ||
* | ||
* This file contains default declarations and functions that are used | ||
* for all ESP32 boards. | ||
* | ||
* @author Gunar Schorcht <[email protected]> | ||
* @file | ||
* @{ | ||
*/ | ||
|
||
#ifndef BOARD_COMMON_H | ||
#define BOARD_COMMON_H | ||
|
||
#include <stdint.h> | ||
|
||
#include "cpu.h" | ||
#include "periph_conf.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @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. Therefore, this function only initializes SPI interfaces. | ||
*/ | ||
void board_init (void); | ||
|
||
/** | ||
* @brief Swith LED on or off. | ||
* @note LED outputs are supposed to be low active. | ||
*/ | ||
void led_on_off (uint8_t led, uint8_t value); | ||
|
||
/** Toggle the LED status. */ | ||
void led_toggle (uint8_t led); | ||
|
||
/** Print board configuration */ | ||
void print_board_config (void); | ||
|
||
#ifdef __cplusplus | ||
} /* end extern "C" */ | ||
#endif | ||
|
||
#endif /* BOARD_COMMON_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* 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 Common declarations of ESP32 periphery for all ESP32 boards | ||
* | ||
* This file contains default declarations that are valid for all ESP32. These | ||
* default configurations can be overriden in *board.h* with board specific | ||
* declarations. | ||
* | ||
* @author Gunar Schorcht <[email protected]> | ||
* @file | ||
* @{ | ||
*/ | ||
|
||
#ifndef PERIPH_CONF_H | ||
#define PERIPH_CONF_H | ||
|
||
/* load default periphery configurations provided by the CPU first */ | ||
#include "periph_cpu.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef DOXYGEN | ||
|
||
#if defined(MODULE_MRF24J40) && !defined(MRF24J40_PARAM_SPI) | ||
/** default configuration for MRF24J40 using VSPI / SPI_DEV(0) and GPIO2 as CS */ | ||
#define MRF24J40_PARAM_SPI SPI_DEV(0) | ||
#define MRF24J40_PARAM_SPI_CLK SPI_CLK_1MHZ | ||
#define MRF24J40_PARAM_CS GPIO2 | ||
#define MRF24J40_PARAM_RESET GPIO32 | ||
#define MRF24J40_PARAM_INT GPIO34 | ||
#endif /* defined(MODULE_MRF24J40) && !defined(MRF24J40_PARAM_SPI) */ | ||
|
||
#if defined(MODULE_ENC28J60) && !defined(ENC28J60_PARAM_SPI) | ||
/** default configuration for ENC28J60 using VSPI / SPI_DEV(0) and GPIO2 as CS */ | ||
#define ENC28J60_PARAM_SPI SPI_DEV(0) | ||
#define ENC28J60_PARAM_CS GPIO4 | ||
#define ENC28J60_PARAM_RESET GPIO33 | ||
#define ENC28J60_PARAM_INT GPIO35 | ||
#endif /* defined(MODULE_ENC28J60) && !defined(ENC28J60_PARAM_SPI) */ | ||
|
||
#if defined(MODULE_SDCARD_SPI) && !defined(SDCARD_SPI_PARAM_SPI) | ||
/** default configuration for SDCARD module using HSPI / SPI_DEV(1) with default CS */ | ||
#define SDCARD_SPI_PARAM_SPI SPI_DEV(1) | ||
#define SDCARD_SPI_PARAM_CS SPI1_CS0 | ||
#define SDCARD_SPI_PARAM_CLK SPI1_SCK | ||
#define SDCARD_SPI_PARAM_MOSI SPI1_MOSI | ||
#define SDCARD_SPI_PARAM_MISO SPI1_MISO | ||
#define SDCARD_SPI_PARAM_POWER GPIO_UNDEF | ||
#endif /* defined(MODULE_SDCARD_SPI) && !defined(SDCARD_SPI_PARAM_SPI) */ | ||
|
||
/** | ||
* @name LED configuration (three predefined LEDs at maximum) | ||
* @{ | ||
*/ | ||
#ifdef LED0_PIN | ||
/** if LED0 pin defined, declare according macros for handling */ | ||
#define LED0_MASK (BIT(LED0_PIN)) | ||
#define LED0_ON led_on_off (LED0_PIN, 1) | ||
#define LED0_OFF led_on_off (LED0_PIN, 0) | ||
#define LED0_TOGGLE led_toggle (LED0_PIN) | ||
#endif | ||
|
||
#ifdef LED1_PIN | ||
/** if LED1 pin defined, declare according macros for handling */ | ||
#define LED1_MASK (BIT(LED1_PIN)) | ||
#define LED1_ON led_on_off (LED1_PIN, 1) | ||
#define LED1_OFF led_on_off (LED1_PIN, 0) | ||
#define LED1_TOGGLE led_toggle (LED1_PIN) | ||
#endif | ||
|
||
#ifdef LED2_PIN | ||
/** if LED2 pin defined, declare according macros for handling */ | ||
#define LED2_MASK (BIT(LED2_PIN)) | ||
#define LED2_ON led_on_off (LED2_PIN, 1) | ||
#define LED2_OFF led_on_off (LED2_PIN, 0) | ||
#define LED2_TOGGLE led_toggle (LED2_PIN) | ||
#endif | ||
/** @} */ | ||
|
||
#endif /* !DOXYGEN */ | ||
|
||
#ifdef __cplusplus | ||
} /* end extern "C" */ | ||
#endif | ||
|
||
#endif /* PERIPH_CONF_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
MODULE = board | ||
|
||
DIRS = $(RIOTBOARD)/common/esp32 | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(RIOTBOARD)/common/esp32/Makefile.features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
USEMODULE += boards_common_esp32 | ||
|
||
include $(RIOTBOARD)/common/esp32/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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_esp32_generic ESP32 - Generic Board | ||
* @ingroup boards | ||
* @brief Board defitions for generic ESP32 boards | ||
* @{ | ||
* | ||
* This board definition can be used for all ESP32 boards that simply break | ||
* out all GPIOs to external pads without having any special hardware or | ||
* interfaces on-board. These are usually boards that use the ESP32 | ||
* WROOM module like Espressif's EPS32-DEVKIT or ESP-32 NodeMCU and a large | ||
* number of clones. | ||
* | ||
* Therefore the board definition is simply a wrapper arround the common ESP32 | ||
* board definition. | ||
* | ||
* **PLEASE NOTE:** | ||
* Most of the board defitions can be overriden by an application specific | ||
* board configuration file. For that purpose, a header file located in | ||
* application directory can be specified using the BOARD_APP_CONF make | ||
* variable at command line, for example: | ||
* | ||
* BOARD_APP_CONF=esp32_generic_conf.h | ||
* | ||
* @file | ||
* @author Gunar Schorcht <[email protected]> | ||
*/ | ||
|
||
#ifndef BOARD_H | ||
#define BOARD_H | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* include the application specific board configuration file from application | ||
source directory if specified */ | ||
#ifdef BOARD_APP_CONF | ||
#include BOARD_APP_CONF | ||
#endif | ||
|
||
/* define all board specific definitions here */ | ||
|
||
#ifdef __cplusplus | ||
} /* end extern "C" */ | ||
#endif | ||
|
||
/* include common board definitions as last step */ | ||
#include "board_common.h" | ||
|
||
#endif /* BOARD_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
MODULE = board | ||
|
||
DIRS = $(RIOTBOARD)/common/esp32 | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(RIOTBOARD)/common/esp32/Makefile.features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
USEMODULE += boards_common_esp32 | ||
|
||
include $(RIOTBOARD)/common/esp32/Makefile.include |
Oops, something went wrong.