mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
arch/xtensa: add support for capture driver on ESP32 and ESP32|S3|
Squashed: Initial settings for MCPWM Capture on board level Created lower half files - compilation ok Using capture debug features. Simple example on fops works Successful duty and freq calculation Documentation update Fixed and added interupt capabilities for all 3 capture channels Cleaned defconfig Renamed macros, added S3 options and moved arch source to common dir Added support for ESP32S3 Added capture example to defconfig and renamed
This commit is contained in:
committed by
Xiang Xiao
parent
92747b7529
commit
365e9e967c
@@ -294,6 +294,22 @@ the ``buttons`` application and pressing on any of the available board buttons::
|
||||
nsh> Sample = 1
|
||||
Sample = 0
|
||||
|
||||
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 14 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
|
||||
--------
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ GPIO Yes
|
||||
I2C Yes
|
||||
I2S Yes
|
||||
LED_PWM Yes
|
||||
MCPWM No
|
||||
MCPWM Yes Capture
|
||||
Pulse_CNT No
|
||||
RMT Yes
|
||||
RNG Yes
|
||||
|
||||
@@ -146,6 +146,22 @@ the ``buttons`` application and pressing on any of the available board buttons::
|
||||
nsh> Sample = 1
|
||||
Sample = 0
|
||||
|
||||
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 12 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
|
||||
--------
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ I2C No
|
||||
I2S Yes
|
||||
LCD No
|
||||
LED_PWM No
|
||||
MCPWM No
|
||||
MCPWM Yes Capture
|
||||
Pulse_CNT No
|
||||
RMT No
|
||||
RNG No
|
||||
|
||||
@@ -7,3 +7,11 @@ config ESP_RMT
|
||||
an infrared transceiver. However, due to the flexibility of its data
|
||||
format, RMT can be extended to a versatile and general-purpose
|
||||
transceiver, transmitting or receiving many other types of signals.
|
||||
|
||||
config ESP_MCPWM
|
||||
bool "Motor Control PWM (MCPWM)"
|
||||
default n
|
||||
depends on ARCH_CHIP_ESP32 || ARCH_CHIP_ESP32S3
|
||||
---help---
|
||||
Enable support for timer capture and motor control using
|
||||
the Motor Control PWM peripheral.
|
||||
|
||||
@@ -25,4 +25,8 @@ CHIP_CSRCS += esp_ws2812.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP_MCPWM),y)
|
||||
CHIP_CSRCS += esp_mcpwm.c
|
||||
endif
|
||||
|
||||
INCLUDES += ${INCDIR_PREFIX}$(ARCH_SRCDIR)$(DELIM)common$(DELIM)espressif$(DELIM)platform_include
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
* arch/xtensa/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_XTENSA_SRC_COMMON_ESPRESSIF_ESP_MCPWM_H
|
||||
#define __ARCH_XTENSA_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 specified 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_XTENSA_SRC_COMMON_ESPRESSIF_ESP_MCPWM_H */
|
||||
@@ -2496,6 +2496,71 @@ config ESP32_LEDC_CHANNEL7_PIN
|
||||
|
||||
endmenu # LEDC 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 14
|
||||
---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 15
|
||||
---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 16
|
||||
---help---
|
||||
GPIO pin assigned to capture channel 2.
|
||||
|
||||
endif # ESP_MCPWM_CAPTURE_CH2
|
||||
|
||||
endif # ESP_MCPWM_CAPTURE
|
||||
|
||||
endmenu # MCPWM Configuration
|
||||
|
||||
config ESP32_HAVE_OTA_PARTITION
|
||||
bool
|
||||
default n
|
||||
|
||||
@@ -97,6 +97,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)ledc_hal_iram.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)ledc_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)rmt_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)timer_hal_iram.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)uart_hal_iram.c
|
||||
@@ -106,5 +107,6 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)gpio_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)mcpwm_periph.c
|
||||
|
||||
CFLAGS += ${DEFINE_PREFIX}ESP_PLATFORM=1
|
||||
|
||||
@@ -2117,6 +2117,71 @@ config ESP32S3_LEDC_CHANNEL7_PIN
|
||||
|
||||
endmenu # LEDC 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 12
|
||||
---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 15
|
||||
---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 16
|
||||
---help---
|
||||
GPIO pin assigned to capture channel 2.
|
||||
|
||||
endif # ESP_MCPWM_CAPTURE_CH2
|
||||
|
||||
endif # ESP_MCPWM_CAPTURE
|
||||
|
||||
endmenu # MCPWM Configuration
|
||||
|
||||
menu "USB OTG Configuration"
|
||||
depends on ESP32S3_OTG
|
||||
|
||||
|
||||
@@ -103,6 +103,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)ledc_hal_iram.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)ledc_hal.c
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)rmt_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)timer_hal_iram.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)cache_hal.c
|
||||
@@ -115,6 +116,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)gpio_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)mcpwm_periph.c
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y)
|
||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)bootloader_banner_wrap.c
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/common/include/esp32_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_XTENSA_ESP32_COMMON_INCLUDE_ESP32_BOARD_MCPWM_H
|
||||
#define __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_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: esp32_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_XTENSA_ESP32_COMMON_INCLUDE_ESP32_BOARD_MCPWM_H */
|
||||
@@ -152,6 +152,10 @@ ifeq ($(CONFIG_SENSORS_ZEROCROSS),y)
|
||||
CSRCS += esp32_zerocross.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP_MCPWM),y)
|
||||
CSRCS += esp32_board_mcpwm.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/common/src/esp32_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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_CAPTURE
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# 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_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32-devkitc"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32_DEVKITC=y
|
||||
CONFIG_ARCH_CHIP="esp32"
|
||||
CONFIG_ARCH_CHIP_ESP32=y
|
||||
CONFIG_ARCH_CHIP_ESP32WROVER=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_ESP32_UART0=y
|
||||
CONFIG_ESP_MCPWM=y
|
||||
CONFIG_ESP_MCPWM_CAPTURE=y
|
||||
CONFIG_ESP_MCPWM_CAPTURE_CH0=y
|
||||
CONFIG_EXAMPLES_CAPTURE=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MM_REGIONS=3
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSLOG_BUFFER=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
@@ -169,6 +169,10 @@
|
||||
# include "esp32_board_rmt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM
|
||||
# include "esp32_board_mcpwm.h"
|
||||
#endif
|
||||
|
||||
#include "esp32-devkitc.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -283,6 +287,14 @@ int esp32_bringup(void)
|
||||
}
|
||||
#endif /* CONFIG_ESP32_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
|
||||
|
||||
#ifdef CONFIG_SENSORS_MAX6675
|
||||
ret = board_max6675_initialize(0, 2);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s3/common/include/esp32s3_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_XTENSA_ESP32_COMMON_INCLUDE_ESP32S3_BOARD_MCPWM_H
|
||||
#define __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32S3_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_XTENSA_ESP32_COMMON_INCLUDE_ESP32S3_BOARD_MCPWM_H */
|
||||
@@ -72,6 +72,10 @@ ifeq ($(CONFIG_ESP_RMT),y)
|
||||
CSRCS += esp32s3_board_rmt.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP_MCPWM),y)
|
||||
CSRCS += esp32s3_board_mcpwm.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s3/common/src/esp32s3_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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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,49 @@
|
||||
#
|
||||
# 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_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32s3-devkit"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32s3"
|
||||
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||
CONFIG_ARCH_CHIP_ESP32S3WROOM1N4=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_ESP32S3_UART0=y
|
||||
CONFIG_ESP_MCPWM=y
|
||||
CONFIG_ESP_MCPWM_CAPTURE=y
|
||||
CONFIG_ESP_MCPWM_CAPTURE_CH0=y
|
||||
CONFIG_EXAMPLES_CAPTURE=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSLOG_BUFFER=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
@@ -100,6 +100,10 @@
|
||||
# include "esp32s3_board_rmt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM
|
||||
# include "esp32s3_board_mcpwm.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S3_SPI
|
||||
#include "esp32s3_spi.h"
|
||||
#include "esp32s3_board_spidev.h"
|
||||
@@ -470,6 +474,14 @@ int esp32s3_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
* at least enough succeeded to bring-up NSH with perhaps reduced
|
||||
* capabilities.
|
||||
|
||||
Reference in New Issue
Block a user