Skip to content

Commit

Permalink
arch/risc-v: add support for capture driver on ESP32C6 and ESP32H2.
Browse files Browse the repository at this point in the history
  • Loading branch information
fdcavalcanti committed Jul 4, 2024
1 parent 8cd207e commit 0f0c9b1
Show file tree
Hide file tree
Showing 18 changed files with 1,376 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ You can check that the sensor is working by using the ``bmp180`` application::
Pressure value = 91526
Pressure value = 91525

capture
--------

The capture configuration enables the capture driver and the capture example, allowing
the user to measure duty cycle and frequency of a signal. Default pin is GPIO 18 with
an internal pull-up resistor enabled. When connecting a 50 Hz pulse with 50% duty cycle,
the following output is expected:

nsh> cap
cap_main: Hardware initialized. Opening the capture device: /dev/capture0
cap_main: Number of samples: 0
pwm duty cycle: 50 %
pwm frequence: 50 Hz
pwm duty cycle: 50 %
pwm frequence: 50 Hz

coremark
--------

Expand Down
2 changes: 1 addition & 1 deletion Documentation/platforms/risc-v/esp32c6/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ I2S No
Int. Temp. No
LED No
LED_PWM Yes
MCPWM No
MCPWM Yes (Capture)
Pulse Counter No
RMT No
RNG No
Expand Down
72 changes: 72 additions & 0 deletions arch/risc-v/src/common/espressif/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,14 @@ config ESP_COEX_SW_COEXIST_ENABLE
If only Bluetooth is used, it is recommended to disable this option to reduce binary file
size.

config ESP_MCPWM
bool "Motor Control PWM (MCPWM)"
default n
depends on ESPRESSIF_ESP32C6 || ESPRESSIF_ESP32H2
---help---
Enable support for timer capture and motor control using
the Motor Control PWM peripheral.

endmenu # Peripheral Support

menu "Wi-Fi Configuration"
Expand Down Expand Up @@ -1273,6 +1281,70 @@ config ESPRESSIF_I2CTIMEOMS
default 500

endmenu # I2C configuration
menu "MCPWM Configuration"
depends on ESP_MCPWM

config ESP_MCPWM_CAPTURE
bool "MCPWM Capture Submodule"
depends on ESP_MCPWM
select CAPTURE
default n
---help---
Enables the use of the MCPWM capture submodule.

if ESP_MCPWM_CAPTURE

config ESP_MCPWM_CAPTURE_CH0
bool "Capture Channel 0"
default n
---help---
Enables capture on channel 0.

if ESP_MCPWM_CAPTURE_CH0

config ESP_MCPWM_CAPTURE_CH0_GPIO
int "GPIO Pin"
default 18
---help---
GPIO pin assigned to capture channel 0.

endif # ESP_MCPWM_CAPTURE_CH0

config ESP_MCPWM_CAPTURE_CH1
bool "Capture Channel 1"
default n
---help---
Enables capture on channel 1.

if ESP_MCPWM_CAPTURE_CH1

config ESP_MCPWM_CAPTURE_CH1_GPIO
int "GPIO Pin"
default 19
---help---
GPIO pin assigned to capture channel 1.

endif # ESP_MCPWM_CAPTURE_CH1

config ESP_MCPWM_CAPTURE_CH2
bool "Capture Channel 2"
default n
---help---
Enables capture on channel 2.

if ESP_MCPWM_CAPTURE_CH2

config ESP_MCPWM_CAPTURE_CH2_GPIO
int "GPIO Pin"
default 20
---help---
GPIO pin assigned to capture channel 2.

endif # ESP_MCPWM_CAPTURE_CH2

endif # ESP_MCPWM_CAPTURE

endmenu # MCPWM Configuration

menu "High Resolution Timer"
depends on ESPRESSIF_HR_TIMER
Expand Down
4 changes: 4 additions & 0 deletions arch/risc-v/src/common/espressif/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ ifeq ($(CONFIG_ESP_WIRELESS),y)
endif
endif

ifeq ($(CONFIG_ESP_MCPWM),y)
CHIP_CSRCS += esp_mcpwm.c
endif

#############################################################################
# Espressif HAL for 3rd Party Platforms
#############################################################################
Expand Down
Loading

0 comments on commit 0f0c9b1

Please sign in to comment.