arch/risc-v: add support for capture driver on ESP32C6 and ESP32H2.

This commit is contained in:
Filipe Cavalcanti
2024-07-03 09:38:49 -03:00
committed by Alan Carvalho de Assis
parent 3e4a16d851
commit 0c63840b18
18 changed files with 1376 additions and 1 deletions
@@ -99,6 +99,22 @@ You can check that the sensor is working by using the ``bmp180`` application::
Pressure value = 91526 Pressure value = 91526
Pressure value = 91525 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 coremark
-------- --------
@@ -152,7 +152,7 @@ I2S No
Int. Temp. No Int. Temp. No
LED No LED No
LED_PWM Yes LED_PWM Yes
MCPWM No MCPWM Yes (Capture)
Pulse Counter No Pulse Counter No
RMT No RMT No
RNG No RNG No
+72
View File
@@ -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 If only Bluetooth is used, it is recommended to disable this option to reduce binary file
size. 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 endmenu # Peripheral Support
menu "Wi-Fi Configuration" menu "Wi-Fi Configuration"
@@ -1273,6 +1281,70 @@ config ESPRESSIF_I2CTIMEOMS
default 500 default 500
endmenu # I2C configuration 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" menu "High Resolution Timer"
depends on ESPRESSIF_HR_TIMER depends on ESPRESSIF_HR_TIMER
@@ -114,6 +114,10 @@ ifeq ($(CONFIG_ESP_WIRELESS),y)
endif endif
endif endif
ifeq ($(CONFIG_ESP_MCPWM),y)
CHIP_CSRCS += esp_mcpwm.c
endif
############################################################################# #############################################################################
# Espressif HAL for 3rd Party Platforms # Espressif HAL for 3rd Party Platforms
############################################################################# #############################################################################
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,86 @@
/****************************************************************************
* arch/risc-v/src/common/espressif/esp_mcpwm.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __ARCH_RISCV_SRC_COMMON_ESPRESSIF_ESP_MCPWM_H
#define __ARCH_RISCV_SRC_COMMON_ESPRESSIF_ESP_MCPWM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#ifdef CONFIG_ESP_MCPWM
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: esp_mcpwm_capture_initialize
*
* Description:
* This function initializes the MCPWM peripheral and the capture
* submodule with the provided configuration.
*
* Input Parameters:
* channel - Channel to be initialized [0-3].
* pin - GPIO pin assigned to this channel.
*
* Returned Value:
* On success, this function returns a valid pointer to the Capture device
* structure. If the initialization fails, it returns NULL.
*
****************************************************************************/
#ifdef CONFIG_ESP_MCPWM_CAPTURE
struct cap_lowerhalf_s *esp_mcpwm_capture_initialize(int channel, int pin);
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_ESP_MCPWM */
#endif /* __ARCH_RISCV_SRC_COMMON_ESPRESSIF_ESP_MCPWM_CAPTURE_H */
+2
View File
@@ -136,6 +136,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)cache_hal.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)cache_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mpu_hal.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mpu_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mmu_hal.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mmu_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mcpwm_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)uart_hal.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)uart_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)uart_hal_iram.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)uart_hal_iram.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)wdt_hal_iram.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)wdt_hal_iram.c
@@ -152,6 +153,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)ledc_periph.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)ledc_periph.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)rmt_periph.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)rmt_periph.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2c_periph.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2c_periph.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)mcpwm_periph.c
ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y)
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)bootloader_banner_wrap.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)bootloader_banner_wrap.c
+2
View File
@@ -118,6 +118,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)timer_hal.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)timer_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)timer_hal_iram.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)timer_hal_iram.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mpu_hal.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mpu_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mcpwm_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mmu_hal.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)mmu_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)uart_hal.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)uart_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)uart_hal_iram.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)uart_hal_iram.c
@@ -135,6 +136,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)ledc_periph.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)ledc_periph.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)rmt_periph.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)rmt_periph.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2c_periph.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)i2c_periph.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)mcpwm_periph.c
ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y)
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)bootloader_banner_wrap.c CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)bootloader_banner_wrap.c
@@ -0,0 +1,70 @@
/****************************************************************************
* boards/risc-v/esp32c6/common/include/esp_board_mcpwm.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_MCPWM_H
#define __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_MCPWM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_ESP_MCPWM_CAPTURE
/****************************************************************************
* Name: board_capture_initialize
*
* Description:
* Initialize and register the capture driver using the MCPWM peripheral.
*
* Input Parameters:
* None.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int board_capture_initialize(void);
#endif /* CONFIG_ESP_MCPWM_CAPTURE */
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_MCPWM_H */
@@ -60,6 +60,10 @@ ifeq ($(CONFIG_SENSORS_BMP180),y)
CSRCS += esp_board_bmp180.c CSRCS += esp_board_bmp180.c
endif endif
ifeq ($(CONFIG_ESP_MCPWM),y)
CSRCS += esp_board_mcpwm.c
endif
DEPPATH += --dep-path src DEPPATH += --dep-path src
VPATH += :src VPATH += :src
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
@@ -0,0 +1,114 @@
/****************************************************************************
* boards/risc-v/esp32c6/common/src/esp_board_mcpwm.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/timers/capture.h>
#include <arch/board/board.h>
#include "espressif/esp_mcpwm.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_capture_initialize
*
* Description:
* Initialize MCPWM Capture submodule and register the capture device.
*
* Input Parameters:
* None.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int board_capture_initialize(void)
{
int ret;
struct cap_lowerhalf_s *cap;
#ifdef CONFIG_ESP_MCPWM_CAPTURE_CH0
cap = esp_mcpwm_capture_initialize(0, CONFIG_ESP_MCPWM_CAPTURE_CH0_GPIO);
if (cap == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to start MCPWM Capture: CH0\n");
return -ENODEV;
}
ret = cap_register("/dev/capture0", cap);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: cap_register failed: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_ESP_MCPWM_CAPTURE_CH1
cap = esp_mcpwm_capture_initialize(1, CONFIG_ESP_MCPWM_CAPTURE_CH1_GPIO);
if (cap == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to start MCPWM Capture: CH1\n");
return -ENODEV;
}
ret = cap_register("/dev/capture1", cap);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: cap_register failed: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_ESP_MCPWM_CAPTURE_CH2
cap = esp_mcpwm_capture_initialize(2, CONFIG_ESP_MCPWM_CAPTURE_CH2_GPIO);
if (cap == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to start MCPWM Capture: CH2\n");
return -ENODEV;
}
ret = cap_register("/dev/capture2", cap);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: cap_register failed: %d\n", ret);
return ret;
}
#endif
return OK;
}
@@ -0,0 +1,51 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="esp32c6-devkitc"
CONFIG_ARCH_BOARD_COMMON=y
CONFIG_ARCH_BOARD_ESP32C6_DEVKITC=y
CONFIG_ARCH_CHIP="esp32c6"
CONFIG_ARCH_CHIP_ESP32C6=y
CONFIG_ARCH_CHIP_ESP32C6WROOM1=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_LOOPSPERMSEC=15000
CONFIG_BUILTIN=y
CONFIG_DEV_ZERO=y
CONFIG_ESPRESSIF_ESP32C6=y
CONFIG_ESP_MCPWM=y
CONFIG_ESP_MCPWM_CAPTURE=y
CONFIG_ESP_MCPWM_CAPTURE_CH0=y
CONFIG_FS_PROCFS=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_NSH_STRERROR=y
CONFIG_PREALLOC_TIMERS=0
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_BACKTRACE=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=29
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2019
CONFIG_SYSTEM_DUMPSTACK=y
CONFIG_SYSTEM_NSH=y
CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART0_SERIAL_CONSOLE=y
@@ -85,6 +85,10 @@
# include "esp_board_spislavedev.h" # include "esp_board_spislavedev.h"
#endif #endif
#ifdef CONFIG_ESP_MCPWM
# include "esp_board_mcpwm.h"
#endif
#include "esp32c6-devkitc.h" #include "esp32c6-devkitc.h"
/**************************************************************************** /****************************************************************************
@@ -322,6 +326,14 @@ int esp_bringup(void)
} }
#endif /* CONFIG_ESPRESSIF_LEDC */ #endif /* CONFIG_ESPRESSIF_LEDC */
#ifdef CONFIG_ESP_MCPWM_CAPTURE
ret = board_capture_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: board_capture_initialize failed: %d\n", ret);
}
#endif
/* If we got here then perhaps not all initialization was successful, but /* If we got here then perhaps not all initialization was successful, but
* at least enough succeeded to bring-up NSH with perhaps reduced * at least enough succeeded to bring-up NSH with perhaps reduced
* capabilities. * capabilities.
@@ -0,0 +1,70 @@
/****************************************************************************
* boards/risc-v/esp32h2/common/include/esp_board_mcpwm.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_RISCV_ESP32H2_COMMON_INCLUDE_ESP_BOARD_MCPWM_H
#define __BOARDS_RISCV_ESP32H2_COMMON_INCLUDE_ESP_BOARD_MCPWM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_ESP_MCPWM_CAPTURE
/****************************************************************************
* Name: board_capture_initialize
*
* Description:
* Initialize and register the capture driver using the MCPWM peripheral.
*
* Input Parameters:
* None.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int board_capture_initialize(void);
#endif /* CONFIG_ESP_MCPWM_CAPTURE */
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __BOARDS_RISCV_ESP32H2_COMMON_INCLUDE_ESP_BOARD_MCPWM_H */
@@ -56,6 +56,10 @@ ifeq ($(CONFIG_SENSORS_BMP180),y)
CSRCS += esp_board_bmp180.c CSRCS += esp_board_bmp180.c
endif endif
ifeq ($(CONFIG_ESP_MCPWM),y)
CSRCS += esp_board_mcpwm.c
endif
DEPPATH += --dep-path src DEPPATH += --dep-path src
VPATH += :src VPATH += :src
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
@@ -0,0 +1,114 @@
/****************************************************************************
* boards/risc-v/esp32h2/common/src/esp_board_mcpwm.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/timers/capture.h>
#include <arch/board/board.h>
#include "espressif/esp_mcpwm.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_capture_initialize
*
* Description:
* Initialize MCPWM Capture submodule and register the capture device.
*
* Input Parameters:
* None.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int board_capture_initialize(void)
{
int ret;
struct cap_lowerhalf_s *cap;
#ifdef CONFIG_ESP_MCPWM_CAPTURE_CH0
cap = esp_mcpwm_capture_initialize(0, CONFIG_ESP_MCPWM_CAPTURE_CH0_GPIO);
if (cap == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to start MCPWM Capture: CH0\n");
return -ENODEV;
}
ret = cap_register("/dev/capture0", cap);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: cap_register failed: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_ESP_MCPWM_CAPTURE_CH1
cap = esp_mcpwm_capture_initialize(1, CONFIG_ESP_MCPWM_CAPTURE_CH1_GPIO);
if (cap == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to start MCPWM Capture: CH1\n");
return -ENODEV;
}
ret = cap_register("/dev/capture1", cap);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: cap_register failed: %d\n", ret);
return ret;
}
#endif
#ifdef CONFIG_ESP_MCPWM_CAPTURE_CH2
cap = esp_mcpwm_capture_initialize(2, CONFIG_ESP_MCPWM_CAPTURE_CH2_GPIO);
if (cap == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to start MCPWM Capture: CH2\n");
return -ENODEV;
}
ret = cap_register("/dev/capture2", cap);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: cap_register failed: %d\n", ret);
return ret;
}
#endif
return OK;
}
@@ -0,0 +1,51 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="esp32h2-devkit"
CONFIG_ARCH_BOARD_COMMON=y
CONFIG_ARCH_BOARD_ESP32H2_DEVKIT=y
CONFIG_ARCH_CHIP="esp32h2"
CONFIG_ARCH_CHIP_ESP32H2=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_LOOPSPERMSEC=15000
CONFIG_BUILTIN=y
CONFIG_DEV_ZERO=y
CONFIG_ESPRESSIF_ESP32H2=y
CONFIG_ESP_MCPWM=y
CONFIG_ESP_MCPWM_CAPTURE=y
CONFIG_ESP_MCPWM_CAPTURE_CH0=y
CONFIG_ESP_MCPWM_CAPTURE_CH0_GPIO=12
CONFIG_FS_PROCFS=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_NSH_STRERROR=y
CONFIG_PREALLOC_TIMERS=0
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_BACKTRACE=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=29
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2019
CONFIG_SYSTEM_DUMPSTACK=y
CONFIG_SYSTEM_NSH=y
CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART0_SERIAL_CONSOLE=y
@@ -77,6 +77,10 @@
# include "esp_board_spislavedev.h" # include "esp_board_spislavedev.h"
#endif #endif
#ifdef CONFIG_ESP_MCPWM
# include "esp_board_mcpwm.h"
#endif
#include "esp32h2-devkit.h" #include "esp32h2-devkit.h"
/**************************************************************************** /****************************************************************************
@@ -289,6 +293,14 @@ int esp_bringup(void)
} }
#endif /* CONFIG_ESPRESSIF_LEDC */ #endif /* CONFIG_ESPRESSIF_LEDC */
#ifdef CONFIG_ESP_MCPWM_CAPTURE
ret = board_capture_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: board_capture_initialize failed: %d\n", ret);
}
#endif
/* If we got here then perhaps not all initialization was successful, but /* If we got here then perhaps not all initialization was successful, but
* at least enough succeeded to bring-up NSH with perhaps reduced * at least enough succeeded to bring-up NSH with perhaps reduced
* capabilities. * capabilities.