From 624c6f24cac0cd8ae9770e8dd4649e3c721ca82d Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Wed, 18 Dec 2019 13:10:34 +0100 Subject: [PATCH] boards/esp32: allow board specific initialization --- boards/common/esp32/board_common.c | 4 +-- boards/common/esp32/include/board_common.h | 26 ++++++++++++++----- .../esp32-mh-et-live-minikit/include/board.h | 8 ++++++ boards/esp32-olimex-evb/include/board.h | 8 ++++++ boards/esp32-ttgo-t-beam/Makefile.dep | 4 +++ boards/esp32-ttgo-t-beam/include/board.h | 5 ++++ .../esp32-wemos-lolin-d32-pro/include/board.h | 8 ++++++ boards/esp32-wroom-32/include/board.h | 8 ++++++ boards/esp32-wrover-kit/include/board.h | 8 ++++++ 9 files changed, 71 insertions(+), 8 deletions(-) diff --git a/boards/common/esp32/board_common.c b/boards/common/esp32/board_common.c index d393f6e5f8..42a05e2e01 100644 --- a/boards/common/esp32/board_common.c +++ b/boards/common/esp32/board_common.c @@ -30,7 +30,7 @@ extern "C" { #endif -void board_init(void) +void board_init_common(void) { #ifdef LED0_PIN gpio_init (LED0_PIN, GPIO_OUT); @@ -54,7 +54,7 @@ extern void spi_print_config(void); extern void uart_print_config(void); extern void can_print_config(void); -void print_board_config (void) +void print_board_config(void) { ets_printf("\nBoard configuration:\n"); diff --git a/boards/common/esp32/include/board_common.h b/boards/common/esp32/include/board_common.h index 3b5143eb59..f8076e0831 100644 --- a/boards/common/esp32/include/board_common.h +++ b/boards/common/esp32/include/board_common.h @@ -147,23 +147,37 @@ extern mtd_dev_t *mtd0; /** - * @brief Initialize board specific hardware + * @brief Initialize the hardware that is common for all ESP32 boards. * - * 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. + * This function has to be called from the board specific `board_init` function. */ -void board_init (void); +void board_init_common(void); /** * @brief Print the board configuration in a human readable format */ -void print_board_config (void); +void print_board_config(void); #ifdef __cplusplus } /* end extern "C" */ #endif +#else /* ESP32_IDF_CODE */ + +#ifndef DOXYGEN + +#ifdef __cplusplus +extern "C" +#endif + +/* declaration of `board_init_common` is required when compiling vendor code */ +extern void board_init_common(void); + +#ifdef __cplusplus +} +#endif + +#endif /* DOXYGEN */ #endif /* ESP32_IDF_CODE */ #endif /* BOARD_COMMON_H */ /** @} */ diff --git a/boards/esp32-mh-et-live-minikit/include/board.h b/boards/esp32-mh-et-live-minikit/include/board.h index ca1a91ff4a..5efe74313a 100644 --- a/boards/esp32-mh-et-live-minikit/include/board.h +++ b/boards/esp32-mh-et-live-minikit/include/board.h @@ -58,5 +58,13 @@ /* include definitions for optional hardware modules */ #include "board_modules.h" +/** + * @brief Initialize the board specific hardware + */ +static inline void board_init(void) { + /* there is nothing special to initialize on this board */ + board_init_common(); +} + #endif /* BOARD_H */ /** @} */ diff --git a/boards/esp32-olimex-evb/include/board.h b/boards/esp32-olimex-evb/include/board.h index b46ba658d5..4233bede75 100644 --- a/boards/esp32-olimex-evb/include/board.h +++ b/boards/esp32-olimex-evb/include/board.h @@ -98,6 +98,14 @@ extern "C" { /* include common board definitions as last step */ #include "board_common.h" +/** + * @brief Initialize the board specific hardware + */ +static inline void board_init(void) { + /* there is nothing special to initialize on this board */ + board_init_common(); +} + #ifdef __cplusplus } /* end extern "C" */ #endif diff --git a/boards/esp32-ttgo-t-beam/Makefile.dep b/boards/esp32-ttgo-t-beam/Makefile.dep index 29d6c99ba8..6c6d30e82b 100644 --- a/boards/esp32-ttgo-t-beam/Makefile.dep +++ b/boards/esp32-ttgo-t-beam/Makefile.dep @@ -1 +1,5 @@ +ifneq (,$(filter esp32_ttgo_t_beam_v1_0,$(USEMODULE))) + FEATURES_REQUIRED += periph_i2c +endif + include $(RIOTBOARD)/common/esp32/Makefile.dep diff --git a/boards/esp32-ttgo-t-beam/include/board.h b/boards/esp32-ttgo-t-beam/include/board.h index 45759d88e1..80fee9be7e 100644 --- a/boards/esp32-ttgo-t-beam/include/board.h +++ b/boards/esp32-ttgo-t-beam/include/board.h @@ -79,5 +79,10 @@ /* include common board definitions as last step */ #include "board_common.h" +/** + * @brief Initialize the board specific hardware + */ +void board_init(void); + #endif /* BOARD_H */ /** @} */ diff --git a/boards/esp32-wemos-lolin-d32-pro/include/board.h b/boards/esp32-wemos-lolin-d32-pro/include/board.h index dbab5be37b..330d2970ed 100644 --- a/boards/esp32-wemos-lolin-d32-pro/include/board.h +++ b/boards/esp32-wemos-lolin-d32-pro/include/board.h @@ -80,5 +80,13 @@ /* include common board definitions as last step */ #include "board_common.h" +/** + * @brief Initialize the board specific hardware + */ +static inline void board_init(void) { + /* there is nothing special to initialize on this board */ + board_init_common(); +} + #endif /* BOARD_H */ /** @} */ diff --git a/boards/esp32-wroom-32/include/board.h b/boards/esp32-wroom-32/include/board.h index d7ed1d6ecf..3ff7e5f03a 100644 --- a/boards/esp32-wroom-32/include/board.h +++ b/boards/esp32-wroom-32/include/board.h @@ -64,5 +64,13 @@ /* include common board definitions as last step */ #include "board_common.h" +/** + * @brief Initialize the board specific hardware + */ +static inline void board_init(void) { + /* there is nothing special to initialize on this board */ + board_init_common(); +} + #endif /* BOARD_H */ /** @} */ diff --git a/boards/esp32-wrover-kit/include/board.h b/boards/esp32-wrover-kit/include/board.h index def0ed0951..ab559e0be3 100644 --- a/boards/esp32-wrover-kit/include/board.h +++ b/boards/esp32-wrover-kit/include/board.h @@ -108,5 +108,13 @@ /* include common board definitions as last step */ #include "board_common.h" +/** + * @brief Initialize the board specific hardware + */ +static inline void board_init(void) { + /* there is nothing special to initialize on this board */ + board_init_common(); +} + #endif /* BOARD_H */ /** @} */