Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
41 changes: 41 additions & 0 deletions ROMFS/robomaster_common/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -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
# #
Expand Down
7 changes: 4 additions & 3 deletions boards/robomaster/dev-c/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -79,7 +79,7 @@ px4_add_board(
#dmesg
# dumpfile
# esc_calib
# gpio
gpio
# hardfault_log
i2cdetect
# led_control
Expand All @@ -90,7 +90,7 @@ px4_add_board(
# nshterm
param
# perf
# pwm
pwm
reboot
# reflect
# sd_bench
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion boards/robomaster/dev-c/src/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions boards/robomaster/dev-c/src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/************************************************************************************
Expand Down
14 changes: 7 additions & 7 deletions boards/robomaster/dev-c/src/timer_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
#include <px4_arch/io_timer_hw_description.h>

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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
40 changes: 40 additions & 0 deletions src/examples/pwm_main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
16 changes: 16 additions & 0 deletions src/examples/pwm_main/pwm_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @file pwm_main.c
* Main function file for PWM module
*
* @author Chen Tong
*/

#include <px4_platform_common/log.h>

__EXPORT int pwm_main(int argc, char *argv[]);

int pwm_main(int argc, char *argv[])
{
PX4_INFO("Hello pwm!");
return OK;
}