diff --git a/.vscode/settings.json b/.vscode/settings.json index ae6e0f4572db..cbc6d04b8ade 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -178,5 +178,6 @@ "workbench.statusBar.feedback.visible": false, "yaml.schemas": { "${workspaceRoot}/validation/module_schema.yaml": "${workspaceRoot}/src/modules/*/module.yaml" - } + }, + "C_Cpp.dimInactiveRegions": false } diff --git a/ROMFS/robomaster_common/init.d/rcS b/ROMFS/robomaster_common/init.d/rcS index b3fe16b33603..a6b9d0c7455c 100644 --- a/ROMFS/robomaster_common/init.d/rcS +++ b/ROMFS/robomaster_common/init.d/rcS @@ -178,6 +178,47 @@ unset BOARD_RC_SENSORS commander start +# Sensors on the PWM interface bank. +if param compare -s SENS_EN_LL40LS 1 +then + # Clear pins 5 and 6. + set FMU_MODE pwm4 + set AUX_MODE pwm4 +fi + + +# Check if ATS is enabled +if param compare FD_EXT_ATS_EN 1 +then + # Clear pins 5 and 6. + set FMU_MODE pwm4 + set AUX_MODE pwm4 +fi + +if param greater TRIG_MODE 0 +then + # We ONLY support trigger on pins 5+6 or 7+8 when simultanously using AUX for actuator output. + if param compare TRIG_PINS 56 + then + # clear pins 5 and 6 + set FMU_MODE pwm4 + set AUX_MODE pwm4 + else + if param compare TRIG_PINS 78 + then + # clear pins 7 and 8 + set FMU_MODE pwm6 + set AUX_MODE pwm6 + else + set FMU_MODE none + set AUX_MODE none + fi + fi + + camera_trigger start + camera_feedback start +fi + # # # # Optional board mavlink streams: rc.board_mavlink # # diff --git a/boards/robomaster/dev-c/default.cmake b/boards/robomaster/dev-c/default.cmake index af5aa4040120..dc72699d2085 100644 --- a/boards/robomaster/dev-c/default.cmake +++ b/boards/robomaster/dev-c/default.cmake @@ -18,7 +18,7 @@ px4_add_board( # barometer # all available barometer drivers # batt_smbus # camera_capture - # camera_trigger + camera_trigger # differential_pressure # all available differential pressure drivers # distance_sensor # all available distance sensor drivers # dshot @@ -79,7 +79,7 @@ px4_add_board( #dmesg # dumpfile # esc_calib - # gpio + gpio # hardfault_log i2cdetect # led_control @@ -90,7 +90,7 @@ px4_add_board( # nshterm param # perf - # pwm + pwm reboot # reflect # sd_bench @@ -104,6 +104,7 @@ px4_add_board( EXAMPLES # fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control hello + # pwm_main # hwtest # Hardware test # #matlab_csv_serial px4_mavlink_debug # Tutorial code from http://dev.px4.io/en/debug/debug_values.html diff --git a/boards/robomaster/dev-c/src/board_config.h b/boards/robomaster/dev-c/src/board_config.h index af3b008a033f..371057f2abd4 100644 --- a/boards/robomaster/dev-c/src/board_config.h +++ b/boards/robomaster/dev-c/src/board_config.h @@ -153,7 +153,7 @@ /* PWM */ -#define DIRECT_PWM_OUTPUT_CHANNELS 6 +#define DIRECT_PWM_OUTPUT_CHANNELS 4 #define DIRECT_INPUT_TIMER_CHANNELS 6 /* USB OTG FS diff --git a/boards/robomaster/dev-c/src/init.c b/boards/robomaster/dev-c/src/init.c index 070cf99c58c2..1722f88ffd05 100644 --- a/boards/robomaster/dev-c/src/init.c +++ b/boards/robomaster/dev-c/src/init.c @@ -113,17 +113,17 @@ __END_DECLS __EXPORT void board_peripheral_reset(int ms) { /* set the peripheral rails off */ - stm32_configgpio(GPIO_VDD_5V_PERIPH_EN); - stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 1); + // stm32_configgpio(GPIO_VDD_5V_PERIPH_EN); + // stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 1); - /* wait for the peripheral rail to reach GND */ - usleep(ms * 1000); - syslog(LOG_DEBUG, "reset done, %d ms\n", ms); + // /* wait for the peripheral rail to reach GND */ + // usleep(ms * 1000); + // syslog(LOG_DEBUG, "reset done, %d ms\n", ms); - /* re-enable power */ + // /* re-enable power */ - /* switch the peripheral rail back on */ - stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 0); + // /* switch the peripheral rail back on */ + // stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 0); } /************************************************************************************ diff --git a/boards/robomaster/dev-c/src/timer_config.cpp b/boards/robomaster/dev-c/src/timer_config.cpp index e8c680ef6bb5..6e0031997ac1 100644 --- a/boards/robomaster/dev-c/src/timer_config.cpp +++ b/boards/robomaster/dev-c/src/timer_config.cpp @@ -34,17 +34,17 @@ #include constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { - initIOTimer(Timer::Timer1, DMA{DMA::Index2, DMA::Stream5, DMA::Channel6}), - initIOTimer(Timer::Timer4, DMA{DMA::Index1, DMA::Stream6, DMA::Channel2}), + initIOTimer(Timer::Timer1), + // initIOTimer(Timer::Timer8, DMA{DMA::Index1, DMA::Stream6, DMA::Channel2}), }; constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { - initIOTimerChannelOutputClear(io_timers, {Timer::Timer1, Timer::Channel4}, {GPIO::PortE, GPIO::Pin14}), - initIOTimerChannelOutputClear(io_timers, {Timer::Timer1, Timer::Channel3}, {GPIO::PortE, GPIO::Pin13}), - initIOTimerChannelOutputClear(io_timers, {Timer::Timer1, Timer::Channel2}, {GPIO::PortE, GPIO::Pin11}), initIOTimerChannelOutputClear(io_timers, {Timer::Timer1, Timer::Channel1}, {GPIO::PortE, GPIO::Pin9}), - initIOTimerChannelOutputClear(io_timers, {Timer::Timer4, Timer::Channel2}, {GPIO::PortD, GPIO::Pin13}), - initIOTimerChannelOutputClear(io_timers, {Timer::Timer4, Timer::Channel3}, {GPIO::PortD, GPIO::Pin14}), + initIOTimerChannelOutputClear(io_timers, {Timer::Timer1, Timer::Channel2}, {GPIO::PortE, GPIO::Pin11}), + initIOTimerChannelOutputClear(io_timers, {Timer::Timer1, Timer::Channel3}, {GPIO::PortE, GPIO::Pin13}), + initIOTimerChannelOutputClear(io_timers, {Timer::Timer1, Timer::Channel4}, {GPIO::PortE, GPIO::Pin14}), + // initIOTimerChannelOutputClear(io_timers, {Timer::Timer4, Timer::Channel2}, {GPIO::PortD, GPIO::Pin13}), + // initIOTimerChannelOutputClear(io_timers, {Timer::Timer4, Timer::Channel3}, {GPIO::PortD, GPIO::Pin14}), }; constexpr io_timers_channel_mapping_t io_timers_channel_mapping = diff --git a/platforms/nuttx/src/px4/common/include/px4_platform/io_timer_init.h b/platforms/nuttx/src/px4/common/include/px4_platform/io_timer_init.h index cbfed2fa1157..f39efd750d58 100644 --- a/platforms/nuttx/src/px4/common/include/px4_platform/io_timer_init.h +++ b/platforms/nuttx/src/px4/common/include/px4_platform/io_timer_init.h @@ -60,6 +60,8 @@ static inline constexpr io_timers_channel_mapping_t initIOTimerChannelMapping(co uint32_t first_channel = UINT32_MAX; uint32_t channel_count = 0; + + // MAX_TIMER_IO_CHANNELS is 8 here since DIRECT_PWM_OUTPUT_CHANNELS is 4 in board_config.h for (uint32_t channel = 0; channel < MAX_TIMER_IO_CHANNELS; ++channel) { if (timer_io_channels_conf[channel].gpio_in == 0 && timer_io_channels_conf[channel].gpio_out == 0) { break; diff --git a/src/drivers/camera_trigger/interfaces/src/camera_interface.cpp b/src/drivers/camera_trigger/interfaces/src/camera_interface.cpp index 40a8f30e223d..30fe8117ee0a 100644 --- a/src/drivers/camera_trigger/interfaces/src/camera_interface.cpp +++ b/src/drivers/camera_trigger/interfaces/src/camera_interface.cpp @@ -15,7 +15,7 @@ CameraInterface::CameraInterface(): void CameraInterface::get_pins() { - // Get parameter handle + // Get parameter handle. TRIG_PINS is defined as 56 in camera_trigger_param.c _p_pin = param_find("TRIG_PINS"); if (_p_pin == PARAM_INVALID) { diff --git a/src/examples/pwm_main/CMakeLists.txt b/src/examples/pwm_main/CMakeLists.txt new file mode 100644 index 000000000000..ad4842b7341e --- /dev/null +++ b/src/examples/pwm_main/CMakeLists.txt @@ -0,0 +1,40 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE examples__pwm_main + MAIN pwm_main + STACK_MAIN 2000 + SRCS + pwm_main.cpp + DEPENDS + ) diff --git a/src/examples/pwm_main/pwm_main.cpp b/src/examples/pwm_main/pwm_main.cpp new file mode 100644 index 000000000000..2da9cfa77324 --- /dev/null +++ b/src/examples/pwm_main/pwm_main.cpp @@ -0,0 +1,16 @@ +/** + * @file pwm_main.c + * Main function file for PWM module + * + * @author Chen Tong + */ + +#include + +__EXPORT int pwm_main(int argc, char *argv[]); + +int pwm_main(int argc, char *argv[]) +{ + PX4_INFO("Hello pwm!"); + return OK; +}