Skip to content

Commit

Permalink
Merge pull request #11337 from gschorcht/cpu/esp32/periph/submodules
Browse files Browse the repository at this point in the history
cpu/esp32: fix of periph_* submodule compilation
  • Loading branch information
leandrolanzieri authored May 1, 2019
2 parents a1f5306 + 94a1af3 commit 7c14ff4
Show file tree
Hide file tree
Showing 10 changed files with 555 additions and 400 deletions.
14 changes: 14 additions & 0 deletions boards/common/esp32/board_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void board_init(void)
}

extern void adc_print_config(void);
extern void dac_print_config(void);
extern void pwm_print_config(void);
extern void i2c_print_config(void);
extern void spi_print_config(void);
Expand All @@ -59,11 +60,24 @@ void print_board_config (void)
{
ets_printf("\nBoard configuration:\n");

#if MODULE_PERIPH_ADC
adc_print_config();
#endif
#if MODULE_PERIPH_DAC
dac_print_config();
#endif
#if MODULE_PERIPH_PWM
pwm_print_config();
#endif
#if MODULE_PERIPH_I2C
i2c_print_config();
#endif
#if MODULE_PERIPH_SPI
spi_print_config();
#endif
#if MODULE_PERIPH_UART
uart_print_config();
#endif

#ifdef MODULE_ESP_CAN
can_print_config();
Expand Down
19 changes: 12 additions & 7 deletions cpu/esp32/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ ifneq (,$(filter riot_freertos,$(USEMODULE)))
USEMODULE += xtimer
endif

ifneq (,$(filter esp_i2c_hw,$(USEMODULE)))
USEMODULE += xtimer
else
# PLEASE NOTE: because of the very poor and faulty hardware implementation
# we use software implementation by default for the moment (if module
# esp_i2c_hw is not explicitly used)
USEMODULE += esp_i2c_sw
ifneq (,$(filter periph_i2c,$(USEMODULE)))
ifneq (,$(filter esp_i2c_hw,$(USEMODULE)))
USEMODULE += core_thread_flags
USEMODULE += xtimer
USEMODULE += periph_i2c_hw
else
# PLEASE NOTE: because of the very poor and faulty hardware implementation
# we use software implementation by default for the moment (if module
# esp_i2c_hw is not explicitly used)
USEMODULE += esp_i2c_sw
USEMODULE += periph_i2c_sw
endif
endif

ifneq (, $(filter esp_spi_ram, $(DISABLE_MODULE)))
Expand Down
5 changes: 5 additions & 0 deletions cpu/esp32/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ USEMODULE += esp_idf_soc
USEMODULE += log
USEMODULE += newlib_syscalls_default
USEMODULE += periph
USEMODULE += periph_adc_ctrl
USEMODULE += periph_common
USEMODULE += periph_hwrng
USEMODULE += periph_flash
USEMODULE += periph_rtc
USEMODULE += periph_uart
USEMODULE += random
USEMODULE += stdio_uart
USEMODULE += xtensa
Expand Down
10 changes: 0 additions & 10 deletions cpu/esp32/include/adc_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ int adc_set_attenuation(adc_t line, adc_attenuation_t atten);
*/
int adc_vref_to_gpio25 (void);

/**
* @brief Configure sleep mode for an GPIO pin if the pin is an RTCIO pin
* @param pin GPIO pin
* @param mode active in sleep mode if true
* @param input as input if true, as output otherwise
* @return 0 success
* @return -1 on invalid pin
*/
int rtcio_config_sleep_mode (gpio_t pin, bool mode, bool input);

#ifdef __cplusplus
}
#endif
Expand Down
100 changes: 100 additions & 0 deletions cpu/esp32/include/adc_ctrl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright (C) 2019 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 cpu_esp32
* @{
*
* @file
* @brief ADC controller functions used by ADC and DAC peripherals
*
* @author Gunar Schorcht <gunar@schorcht.net>
* @}
*/

#ifndef ADC_CTRL_H
#define ADC_CTRL_H

#ifdef __cplusplus
extern "C" {
#endif

#include "periph/gpio.h"

/**
* @brief ADC controllers
*/
enum {
ADC1_CTRL, /**< ADC1 controller */
ADC2_CTRL /**< ADC2 controller */
};

/**
* @brief RTC IO pin type (does not correspond to RTC gpio num order)
*/
enum {

RTCIO_TOUCH0 = 0, /**< touch sensor 0 */
RTCIO_TOUCH1, /**< touch sensor 1 */
RTCIO_TOUCH2, /**< touch sensor 2 */
RTCIO_TOUCH3, /**< touch sensor 3 */
RTCIO_TOUCH4, /**< touch sensor 4 */
RTCIO_TOUCH5, /**< touch sensor 5 */
RTCIO_TOUCH6, /**< touch sensor 6 */
RTCIO_TOUCH7, /**< touch sensor 7 */
RTCIO_TOUCH8, /**< touch sensor 8, 32K_XP */
RTCIO_TOUCH9, /**< touch sensor 9, 32K_XN */

RTCIO_ADC_ADC1, /**< VDET_1 */
RTCIO_ADC_ADC2, /**< VDET_2 */

RTCIO_SENSOR_SENSE1, /**< SENSOR_VP */
RTCIO_SENSOR_SENSE2, /**< SENSOR_CAPP */
RTCIO_SENSOR_SENSE3, /**< SENSOR_CAPN */
RTCIO_SENSOR_SENSE4, /**< SENSOR_VN */

RTCIO_DAC1, /**< DAC output */
RTCIO_DAC2, /**< DAC output */

RTCIO_NA, /**< RTC pad not available */
};

/**
* @brief ADC pin hardware information type (for internal use only)
*/
struct _adc_hw_t {
gpio_t gpio; /**< GPIO */
uint8_t rtc_gpio; /**< corresponding RTC GPIO */
uint8_t adc_ctrl; /**< ADC controller */
uint8_t adc_channel; /**< channel of ADC controller */
char* pad_name; /**< symbolic name of pad */
};

/**
* @brief RTC hardware map
*
* The index corresponds to RTC pin type _rtcio_pin_t (Table 19 in Technical
* Reference)
*/
extern const struct _adc_hw_t _adc_hw[];

/**
* @brief Configure sleep mode for an GPIO pin if the pin is a RTCIO pin
* @param pin GPIO pin
* @param mode active in sleep mode if true
* @param input as input if true, as output otherwise
* @return 0 success
* @return -1 on invalid pin
*/
int rtcio_config_sleep_mode (gpio_t pin, bool mode, bool input);

#ifdef __cplusplus
}
#endif

#endif /* ADC_CTRL_H */
2 changes: 1 addition & 1 deletion cpu/esp32/periph/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
MODULE = periph

include $(RIOTBASE)/Makefile.base
include $(RIOTMAKE)/periph.mk
Loading

0 comments on commit 7c14ff4

Please sign in to comment.