mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 07:28:38 +08:00
arch/xtensa: add support for brushed DC motor control
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 Basic bring up ready. New Kconfig options for motor. Good motor registration Working on enabling pwm generators Working on enabling pwm generators Added fops functions Success on PWM 50% stable pwm operation for bdc Added loopback option for testing Improved rules on fsm Working motor direction control Testing new ISR for fault handling Issues on fault ISR Removed fault implementation (not working) Added support for esp32s3 Documentation improvements Added default motor spin direction Added parameter change while running Review fixes arch/xtensa: add support for fault signal on motor control 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 Basic bring up ready. New Kconfig options for motor. Good motor registration Working on enabling pwm generators Working on enabling pwm generators Added fops functions Success on PWM 50% stable pwm operation for bdc Added loopback option for testing Improved rules on fsm Working motor direction control Testing new ISR for fault handling Issues on fault ISR Removed fault implementation (not working) Added support for esp32s3 Documentation improvements Added default motor spin direction Added parameter change while running Got responsive fault indicator Working brakes - still need to work on starting isr Fixed single-time ISR initializiation Working soft brake on fault Improved KConfig for BDC and BLDC Kconfig fixed at board level
This commit is contained in:
parent
b57079e88e
commit
91dfd20eaf
17 changed files with 1897 additions and 72 deletions
|
@ -300,15 +300,15 @@ 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:
|
||||
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
|
||||
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
|
||||
--------
|
||||
|
@ -561,6 +561,19 @@ module
|
|||
|
||||
This config is to run apps/examples/module.
|
||||
|
||||
motor
|
||||
-------
|
||||
|
||||
The motor configuration enables the MCPWM peripheral with support to brushed DC motor
|
||||
control.
|
||||
|
||||
It creates a ``/dev/motor0`` device with speed and direction control capabilities
|
||||
by using two GPIOs (GPIO15 and GPIO16) for PWM output. PWM frequency is configurable
|
||||
from 25 Hz to 3 kHz, however it defaults to 1 kHz.
|
||||
There is also support for an optional fault GPIO (defaults to GPIO10), which can be used
|
||||
for quick motor braking. All GPIOs are configurable in ``menuconfig``.
|
||||
|
||||
|
||||
mqttc
|
||||
-----
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ GPIO Yes
|
|||
I2C Yes
|
||||
I2S Yes
|
||||
LED_PWM Yes
|
||||
MCPWM Yes Capture
|
||||
MCPWM Yes
|
||||
Pulse_CNT No
|
||||
RMT Yes
|
||||
RNG Yes
|
||||
|
|
|
@ -152,15 +152,15 @@ 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:
|
||||
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
|
||||
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
|
||||
--------
|
||||
|
@ -257,6 +257,18 @@ Flash and PSRAM).
|
|||
.. warning:: The World Controller and Permission Control **do not** prevent
|
||||
the application from accessing CPU System Registers.
|
||||
|
||||
motor
|
||||
-------
|
||||
|
||||
The motor configuration enables the MCPWM peripheral with support to brushed DC motor
|
||||
control.
|
||||
|
||||
It creates a ``/dev/motor0`` device with speed and direction control capabilities
|
||||
by using two GPIOs (GPIO15 and GPIO16) for PWM output. PWM frequency is configurable
|
||||
from 25 Hz to 3 kHz, however it defaults to 1 kHz.
|
||||
There is also support for an optional fault GPIO (defaults to GPIO10), which can be used
|
||||
for quick motor braking. All GPIOs are configurable in ``menuconfig``.
|
||||
|
||||
mcuboot_nsh
|
||||
-----------
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ I2C No
|
|||
I2S Yes
|
||||
LCD No
|
||||
LED_PWM No
|
||||
MCPWM Yes Capture
|
||||
MCPWM Yes
|
||||
Pulse_CNT No
|
||||
RMT No
|
||||
RNG No
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -56,6 +56,31 @@ extern "C"
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_motor_bdc_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function initializes the MCPWM peripheral and configures the
|
||||
* motor control driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* channel - Channel to be initialized (only 0 available for now).
|
||||
* frequency - PWM output frequency in Hertz.
|
||||
* pwm_a_pin - GPIO pin number for PWM0_A output.
|
||||
* pwm_b_pin - GPIO pin number for PWM0_B output.
|
||||
* fault_pin - GPIO pin number for fault signal input.
|
||||
*
|
||||
* 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_MOTOR_BDC
|
||||
struct motor_lowerhalf_s *esp_motor_bdc_initialize(int channel,
|
||||
uint32_t frequency, int pwm_a_pin, int pwm_b_pin, int fault_pin);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_mcpwm_capture_initialize
|
||||
*
|
||||
|
|
|
@ -2496,6 +2496,99 @@ endmenu # LEDC configuration
|
|||
menu "MCPWM Configuration"
|
||||
depends on ESP_MCPWM
|
||||
|
||||
config ESP_MCPWM_MOTOR
|
||||
bool "MCPWM Motor Support"
|
||||
default n
|
||||
|
||||
menu "MCPWM Motor Configuration"
|
||||
depends on ESP_MCPWM_MOTOR
|
||||
|
||||
config ESP_MCPWM_MOTOR_BDC
|
||||
bool "Brushed DC Motor Control"
|
||||
depends on ESP_MCPWM
|
||||
depends on ESP_MCPWM_MOTOR
|
||||
select MOTOR
|
||||
select MOTOR_UPPER
|
||||
select MOTOR_UPPER_HAVE_SPEED
|
||||
default n
|
||||
---help---
|
||||
Enables the use of the MCPWM submodule for control of brushed DC
|
||||
motor.
|
||||
|
||||
if ESP_MCPWM_MOTOR_BDC
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH0
|
||||
bool "Motor Control Channel 0"
|
||||
default n
|
||||
---help---
|
||||
Enables motor control on channel 0.
|
||||
|
||||
if ESP_MCPWM_MOTOR_CH0
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH0_PWMA_GPIO
|
||||
int "Output Pin PWM_A"
|
||||
default 15
|
||||
---help---
|
||||
Output pin assigned to channel 0 PWM output PWM_A.
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH0_PWMB_GPIO
|
||||
int "Output Pin PWM_B"
|
||||
default 16
|
||||
---help---
|
||||
Output pin assigned to channel 0 PWM output PWM_B.
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH0_PWM_FREQ
|
||||
int "PWM output frequency for channel 0 [Hz]"
|
||||
default 1000
|
||||
---help---
|
||||
Select PWM frequency for channel 0.
|
||||
Minimum is 25 Hz and maximum is 3000 Hz.
|
||||
|
||||
config ESP_MCPMW_MOTOR_CH0_FAULT
|
||||
bool "Enable fault for channel 0"
|
||||
default n
|
||||
---help---
|
||||
Enables the use of a fault pin to quickly stop the motor when
|
||||
a GPIO pin pulled high.
|
||||
|
||||
if ESP_MCPMW_MOTOR_CH0_FAULT
|
||||
|
||||
config ESP_MCPMW_MOTOR_CH0_FAULT_GPIO
|
||||
int "GPIO Pin for fault detection"
|
||||
default 10
|
||||
---help---
|
||||
Input pin assigned to channel 0 fault indicator.
|
||||
|
||||
endif # ESP_MCPMW_MOTOR_CH0_FAULT
|
||||
|
||||
endif # ESP_MCPWM_MOTOR_CH0
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH1
|
||||
bool "Motor Control Channel 1"
|
||||
default n
|
||||
---help---
|
||||
Enables motor control on channel 1.
|
||||
|
||||
if ESP_MCPWM_MOTOR_CH1
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH1_PWMA_GPIO
|
||||
int "Output Pin CH1 PWM_A"
|
||||
default 15
|
||||
---help---
|
||||
Output pin assigned to channel 1 PWM output PWM_A.
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH1_PWMB_GPIO
|
||||
int "Output Pin CH1 PWM_B"
|
||||
default 16
|
||||
---help---
|
||||
Output pin assigned to channel 1 PWM output PWM_B.
|
||||
|
||||
endif # ESP_MCPWM_MOTOR_CH1
|
||||
|
||||
endif # ESP_MCPWM_MOTOR_BDC
|
||||
|
||||
endmenu # MCPWM Motor Settings
|
||||
|
||||
config ESP_MCPWM_CAPTURE
|
||||
bool "MCPWM Capture Submodule"
|
||||
depends on ESP_MCPWM
|
||||
|
@ -2516,7 +2609,7 @@ if ESP_MCPWM_CAPTURE_CH0
|
|||
|
||||
config ESP_MCPWM_CAPTURE_CH0_GPIO
|
||||
int "GPIO Pin"
|
||||
default 14
|
||||
default 12
|
||||
---help---
|
||||
GPIO pin assigned to capture channel 0.
|
||||
|
||||
|
@ -2556,6 +2649,15 @@ endif # ESP_MCPWM_CAPTURE_CH2
|
|||
|
||||
endif # ESP_MCPWM_CAPTURE
|
||||
|
||||
config ESP_MCPWM_TEST_LOOPBACK
|
||||
bool "MCPWM loopback test mode"
|
||||
depends on EXPERIMENTAL
|
||||
default n
|
||||
---help---
|
||||
This enables a lower-half driver-specific loopback test
|
||||
mode that attaches a capture device to the PWM output on
|
||||
motor tests.
|
||||
|
||||
endmenu # MCPWM Configuration
|
||||
|
||||
config ESP32_HAVE_OTA_PARTITION
|
||||
|
|
|
@ -2120,6 +2120,99 @@ endmenu # LEDC configuration
|
|||
menu "MCPWM Configuration"
|
||||
depends on ESP_MCPWM
|
||||
|
||||
config ESP_MCPWM_MOTOR
|
||||
bool "MCPWM Motor Support"
|
||||
default n
|
||||
|
||||
menu "MCPWM Motor Configuration"
|
||||
depends on ESP_MCPWM_MOTOR
|
||||
|
||||
config ESP_MCPWM_MOTOR_BDC
|
||||
bool "Brushed DC Motor Control"
|
||||
depends on ESP_MCPWM
|
||||
depends on ESP_MCPWM_MOTOR
|
||||
select MOTOR
|
||||
select MOTOR_UPPER
|
||||
select MOTOR_UPPER_HAVE_SPEED
|
||||
default n
|
||||
---help---
|
||||
Enables the use of the MCPWM submodule for control of brushed DC
|
||||
motor.
|
||||
|
||||
if ESP_MCPWM_MOTOR_BDC
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH0
|
||||
bool "Motor Control Channel 0"
|
||||
default n
|
||||
---help---
|
||||
Enables motor control on channel 0.
|
||||
|
||||
if ESP_MCPWM_MOTOR_CH0
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH0_PWMA_GPIO
|
||||
int "Output Pin PWM_A"
|
||||
default 15
|
||||
---help---
|
||||
Output pin assigned to channel 0 PWM output PWM_A.
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH0_PWMB_GPIO
|
||||
int "Output Pin PWM_B"
|
||||
default 16
|
||||
---help---
|
||||
Output pin assigned to channel 0 PWM output PWM_B.
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH0_PWM_FREQ
|
||||
int "PWM output frequency for channel 0 [Hz]"
|
||||
default 1000
|
||||
---help---
|
||||
Select PWM frequency for channel 0.
|
||||
Minimum is 25 Hz and maximum is 3000 Hz.
|
||||
|
||||
config ESP_MCPMW_MOTOR_CH0_FAULT
|
||||
bool "Enable fault for channel 0"
|
||||
default n
|
||||
---help---
|
||||
Enables the use of a fault pin to quickly stop the motor when
|
||||
a GPIO pin pulled high.
|
||||
|
||||
if ESP_MCPMW_MOTOR_CH0_FAULT
|
||||
|
||||
config ESP_MCPMW_MOTOR_CH0_FAULT_GPIO
|
||||
int "GPIO Pin for fault detection"
|
||||
default 10
|
||||
---help---
|
||||
Input pin assigned to channel 0 fault indicator.
|
||||
|
||||
endif # ESP_MCPMW_MOTOR_CH0_FAULT
|
||||
|
||||
endif # ESP_MCPWM_MOTOR_CH0
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH1
|
||||
bool "Motor Control Channel 1"
|
||||
default n
|
||||
---help---
|
||||
Enables motor control on channel 1.
|
||||
|
||||
if ESP_MCPWM_MOTOR_CH1
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH1_PWMA_GPIO
|
||||
int "Output Pin CH1 PWM_A"
|
||||
default 15
|
||||
---help---
|
||||
Output pin assigned to channel 1 PWM output PWM_A.
|
||||
|
||||
config ESP_MCPWM_MOTOR_CH1_PWMB_GPIO
|
||||
int "Output Pin CH1 PWM_B"
|
||||
default 16
|
||||
---help---
|
||||
Output pin assigned to channel 1 PWM output PWM_B.
|
||||
|
||||
endif # ESP_MCPWM_MOTOR_CH1
|
||||
|
||||
endif # ESP_MCPWM_MOTOR_BDC
|
||||
|
||||
endmenu # MCPWM Motor Settings
|
||||
|
||||
config ESP_MCPWM_CAPTURE
|
||||
bool "MCPWM Capture Submodule"
|
||||
depends on ESP_MCPWM
|
||||
|
@ -2180,6 +2273,15 @@ endif # ESP_MCPWM_CAPTURE_CH2
|
|||
|
||||
endif # ESP_MCPWM_CAPTURE
|
||||
|
||||
config ESP_MCPWM_TEST_LOOPBACK
|
||||
bool "MCPWM loopback test mode"
|
||||
depends on EXPERIMENTAL
|
||||
default n
|
||||
---help---
|
||||
This enables a lower-half driver-specific loopback test
|
||||
mode that attaches a capture device to the PWM output on
|
||||
motor tests.
|
||||
|
||||
endmenu # MCPWM Configuration
|
||||
|
||||
menu "USB OTG Configuration"
|
||||
|
|
|
@ -43,6 +43,25 @@ extern "C"
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_motor_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize MCPWM peripheral for motor control and register the motor
|
||||
* driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_MOTOR_BDC
|
||||
int board_motor_initialize(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_CAPTURE
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/motor/motor.h>
|
||||
#include <nuttx/timers/capture.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
@ -39,10 +40,59 @@
|
|||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPMW_MOTOR_CH0_FAULT
|
||||
# define MCPWM_FAULT_GPIO CONFIG_ESP_MCPMW_MOTOR_CH0_FAULT_GPIO
|
||||
#else
|
||||
# define MCPWM_FAULT_GPIO 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_motor_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize MCPWM peripheral for motor control and register the motor
|
||||
* driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_MOTOR_BDC
|
||||
int board_motor_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
struct motor_lowerhalf_s *motor;
|
||||
|
||||
motor = esp_motor_bdc_initialize(0,
|
||||
CONFIG_ESP_MCPWM_MOTOR_CH0_PWM_FREQ,
|
||||
CONFIG_ESP_MCPWM_MOTOR_CH0_PWMA_GPIO,
|
||||
CONFIG_ESP_MCPWM_MOTOR_CH0_PWMB_GPIO,
|
||||
MCPWM_FAULT_GPIO);
|
||||
if (!motor)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to start MCPWM BDC Motor: CH0\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = motor_register("/dev/motor0", motor);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: motor_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_capture_initialize
|
||||
*
|
||||
|
|
|
@ -23,6 +23,7 @@ CONFIG_ESP32_UART0=y
|
|||
CONFIG_ESP_MCPWM=y
|
||||
CONFIG_ESP_MCPWM_CAPTURE=y
|
||||
CONFIG_ESP_MCPWM_CAPTURE_CH0=y
|
||||
CONFIG_ESP_MCPWM_CAPTURE_CH0_GPIO=14
|
||||
CONFIG_EXAMPLES_CAPTURE=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
|
|
50
boards/xtensa/esp32/esp32-devkitc/configs/motor/defconfig
Normal file
50
boards/xtensa/esp32/esp32-devkitc/configs/motor/defconfig
Normal file
|
@ -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_MOTOR=y
|
||||
CONFIG_ESP_MCPWM_MOTOR_BDC=y
|
||||
CONFIG_ESP_MCPWM_MOTOR_CH0=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
|
|
@ -295,6 +295,14 @@ int esp32_bringup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_MOTOR_BDC
|
||||
ret = board_motor_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_motor_initialize failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SENSORS_MAX6675
|
||||
ret = board_max6675_initialize(0, 2);
|
||||
if (ret < 0)
|
||||
|
|
|
@ -43,7 +43,28 @@ extern "C"
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_CAPTURE
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_motor_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize MCPWM peripheral for motor control and register the motor
|
||||
* driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_MOTOR_BDC
|
||||
int board_motor_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_capture_initialize
|
||||
|
@ -59,9 +80,10 @@ extern "C"
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_CAPTURE
|
||||
int board_capture_initialize(void);
|
||||
|
||||
#endif /* CONFIG_ESP_MCPWM_CAPTURE */
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/motor/motor.h>
|
||||
#include <nuttx/timers/capture.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
@ -39,10 +40,61 @@
|
|||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPMW_MOTOR_CH0_FAULT
|
||||
# define MCPWM_FAULT_GPIO CONFIG_ESP_MCPMW_MOTOR_CH0_FAULT_GPIO
|
||||
#else
|
||||
# define MCPWM_FAULT_GPIO 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_motor_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize MCPWM peripheral for motor control and register the motor
|
||||
* driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_MOTOR_BDC
|
||||
int board_motor_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
struct motor_lowerhalf_s *motor;
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_MOTOR_CH0
|
||||
motor = esp_motor_bdc_initialize(0,
|
||||
CONFIG_ESP_MCPWM_MOTOR_CH0_PWM_FREQ,
|
||||
CONFIG_ESP_MCPWM_MOTOR_CH0_PWMA_GPIO,
|
||||
CONFIG_ESP_MCPWM_MOTOR_CH0_PWMB_GPIO,
|
||||
MCPWM_FAULT_GPIO);
|
||||
if (motor == NULL)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to start MCPWM BDC Motor: CH0\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = motor_register("/dev/motor0", motor);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: motor_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_capture_initialize
|
||||
*
|
||||
|
@ -57,6 +109,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_CAPTURE
|
||||
int board_capture_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
|
@ -116,3 +169,4 @@ int board_capture_initialize(void)
|
|||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
|
49
boards/xtensa/esp32s3/esp32s3-devkit/configs/motor/defconfig
Normal file
49
boards/xtensa/esp32s3/esp32s3-devkit/configs/motor/defconfig
Normal file
|
@ -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_MOTOR=y
|
||||
CONFIG_ESP_MCPWM_MOTOR_BDC=y
|
||||
CONFIG_ESP_MCPWM_MOTOR_CH0=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
|
|
@ -482,6 +482,14 @@ int esp32s3_bringup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_MCPWM_MOTOR_BDC
|
||||
ret = board_motor_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_motor_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.
|
||||
|
|
Loading…
Reference in a new issue