Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Dev dshot #12634

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2e0b717
Added prescaler calculations for dshot PWM.
Igor-Misic Jul 10, 2019
2a67239
Updated up_pwm_servo_set_rate_group_update function with DSHOT rates.
Igor-Misic Jul 11, 2019
b140044
Added more dshot drivers.
Igor-Misic Jul 22, 2019
efb361b
Added support: NVIC for DMA2 stream 5 enabling
Igor-Misic Jul 22, 2019
937bb48
NVIC for DMA2 Streams is handled inside Nuttx.
Igor-Misic Jul 23, 2019
3a3a0d7
First dshot driver able to send data.
Igor-Misic Jul 24, 2019
dd3d996
Improved software structure.
Igor-Misic Jul 25, 2019
1dfa2d4
Removing dshot from pwm_servo.
Igor-Misic Jul 25, 2019
af70d39
Added proper arming/disarming sequence.
Igor-Misic Jul 26, 2019
808888c
Updated init function.
Igor-Misic Jul 26, 2019
f5503d6
Update src/drivers/stm32/drv_io_timer.c
Igor-Misic Aug 6, 2019
3bdea9e
Support for enabling telemetry flag.
Igor-Misic Aug 6, 2019
80b9e78
Merge remote-tracking branch 'origin/dev-dshot' into dev-dshot
Igor-Misic Aug 6, 2019
1d9f3c9
Added support for multiple timers.
Igor-Misic Aug 11, 2019
49ce97a
Setting burst length from config instead of counting.
Igor-Misic Aug 12, 2019
431ce33
DShot config merged with timer config structure.
Igor-Misic Aug 13, 2019
757985e
Added prescaler calculations for dshot PWM.
Igor-Misic Jul 10, 2019
a95336b
Updated up_pwm_servo_set_rate_group_update function with DSHOT rates.
Igor-Misic Jul 11, 2019
de27d8a
Added more dshot drivers.
Igor-Misic Jul 22, 2019
0712a14
Added support: NVIC for DMA2 stream 5 enabling
Igor-Misic Jul 22, 2019
83be707
NVIC for DMA2 Streams is handled inside Nuttx.
Igor-Misic Jul 23, 2019
8a0d85c
First dshot driver able to send data.
Igor-Misic Jul 24, 2019
b1398b9
Improved software structure.
Igor-Misic Jul 25, 2019
7dd8780
Removing dshot from pwm_servo.
Igor-Misic Jul 25, 2019
94e1f79
Added proper arming/disarming sequence.
Igor-Misic Jul 26, 2019
590817f
Updated init function.
Igor-Misic Jul 26, 2019
1d186aa
Update src/drivers/stm32/drv_io_timer.c
Igor-Misic Aug 6, 2019
298368a
Support for enabling telemetry flag.
Igor-Misic Aug 6, 2019
5c0f4ae
Added support for multiple timers.
Igor-Misic Aug 11, 2019
00b265e
Setting burst length from config instead of counting.
Igor-Misic Aug 12, 2019
51e44c2
DShot config merged with timer config structure.
Igor-Misic Aug 13, 2019
70881c8
Merge remote-tracking branch 'origin/dev-dshot' into dev-dshot
Igor-Misic Aug 16, 2019
248cea9
MCUs with DMA_V1 are not supported.
Igor-Misic Aug 16, 2019
6ad72f0
dshot: add BOARD_DSHOT_MOTOR_ASSIGNMENT, change input throttle to ran…
bkueng Aug 17, 2019
e3733b6
omnbus: enable dshot
bkueng Aug 17, 2019
f75b088
dshot: add commands
bkueng Aug 17, 2019
f92916e
Fix for not supported IP DMA V1 MCUs.
Igor-Misic Aug 18, 2019
84d3af1
Code style update.
Igor-Misic Aug 18, 2019
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
2 changes: 1 addition & 1 deletion boards/omnibus/f4sd/nuttx-config/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
#define GPIO_USART1_TX GPIO_USART1_TX_1

/* USART1 require a RX DMA configuration */
#define DMAMAP_USART1_RX DMAMAP_USART1_RX_2
#define DMAMAP_USART1_RX DMAMAP_USART1_RX_1

/* USART3:
*
Expand Down
2 changes: 2 additions & 0 deletions boards/omnibus/f4sd/src/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@
#define BOARD_ENABLE_CONSOLE_BUFFER
#define BOARD_CONSOLE_BUFFER_SIZE (1024*3)

#define BOARD_DSHOT_MOTOR_ASSIGNMENT {2, 3, 1, 0};

__BEGIN_DECLS

/****************************************************************************************************
Expand Down
19 changes: 17 additions & 2 deletions boards/omnibus/f4sd/src/timer_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = {
.first_channel_index = 0,
.last_channel_index = 1,
.handler = io_timer_handler1,
.vectorno = STM32_IRQ_TIM2
.vectorno = STM32_IRQ_TIM2,
.dshot = {
.dma_base = DSHOT_DMA1_BASE,
.channel = DShot_Channel3,
.stream = DShot_Stream1,
.start_ccr_register = TIM_DMABASE_CCR3,
.channels_number = 2u /* CCR3 and CCR4 */
}
},
{
.base = STM32_TIM3_BASE,
Expand All @@ -69,9 +76,17 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = {
.first_channel_index = 2,
.last_channel_index = 3,
.handler = io_timer_handler2,
.vectorno = STM32_IRQ_TIM3
.vectorno = STM32_IRQ_TIM3,
.dshot = {
.dma_base = DSHOT_DMA1_BASE,
.channel = DShot_Channel5,
.stream = DShot_Stream2,
.start_ccr_register = TIM_DMABASE_CCR3,
.channels_number = 2u /* CCR3 and CCR4 */
}
}
};

/*
* OUTPUTS:
* M3 : PA3 : TIM2_CH3
Expand Down
4 changes: 2 additions & 2 deletions boards/px4/fmu-v4/nuttx-config/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@
/* UART8 has no alternate pin config */

/* UART RX DMA configurations */
#define DMAMAP_USART1_RX DMAMAP_USART1_RX_2
#define DMAMAP_USART6_RX DMAMAP_USART6_RX_2
#define DMAMAP_USART1_RX DMAMAP_USART1_RX_1 /*DMA2 Stream 2*/
#define DMAMAP_USART6_RX DMAMAP_USART6_RX_1 /*DMA2 Stream 1*/

/*
* CAN
Expand Down
15 changes: 15 additions & 0 deletions boards/px4/fmu-v4/src/timer_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

#include <drivers/drv_pwm_output.h>
#include <drivers/stm32/drv_io_timer.h>
#include <drivers/stm32/drv_dshot.h>

#include "board_config.h"

Expand All @@ -60,6 +61,13 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = {
.last_channel_index = 3,
.handler = io_timer_handler0,
.vectorno = STM32_IRQ_TIM1CC,
.dshot = {
.dma_base = DSHOT_DMA2_BASE,
.channel = DShot_Channel6,
.stream = DShot_Stream5,
.start_ccr_register = TIM_DMABASE_CCR1,
.channels_number = 4u /* CCR1, CCR2, CCR3 and CCR4 */
}

},
{
Expand All @@ -71,6 +79,13 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = {
.last_channel_index = 5,
.handler = io_timer_handler1,
.vectorno = STM32_IRQ_TIM4,
.dshot = {
.dma_base = DSHOT_DMA1_BASE,
.channel = DShot_Channel2,
.stream = DShot_Stream6,
.start_ccr_register = TIM_DMABASE_CCR2,
.channels_number = 2u /* CCR2 and CCR3 */
}
}
};

Expand Down
54 changes: 54 additions & 0 deletions src/drivers/drv_pwm_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,17 @@ struct pwm_output_rc_config {
*/
#define PWM_SERVO_GET_RATEGROUP(_n) _PX4_IOC(_PWM_SERVO_BASE, 0x70 + _n)

/** specific rates for configuring the timer for OneShot or PWM */
#define PWM_RATE_ONESHOT 0u
#define PWM_RATE_LOWER_LIMIT 1u
#define PWM_RATE_UPPER_LIMIT 10000u

/** Dshot PWM frequency */
#define DSHOT1200 1200000u //Hz
#define DSHOT600 600000u //Hz
#define DSHOT300 300000u //Hz
#define DSHOT150 150000u //Hz

/*
* Low-level PWM output interface.
*
Expand Down Expand Up @@ -378,4 +389,47 @@ __EXPORT extern int up_pwm_servo_set(unsigned channel, servo_position_t value);
*/
__EXPORT extern servo_position_t up_pwm_servo_get(unsigned channel);

/**
* Intialise the Dshot outputs using the specified configuration.
*
* @param channel_mask Bitmask of channels (LSB = channel 0) to enable.
* This allows some of the channels to remain configured
* as GPIOs or as another function.
* @param dshot_pwm_freq is frequency of DSHOT signal. Usually DSHOT1200, DSHOT600, DSHOT300 or DSHOT150
* @return OK on success.
*/
__EXPORT extern int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq);

/**
* Set the current dshot throttle value for a channel (motor).
*
* @param channel The channel to set.
* @param throttle The output dshot throttle value in [0, 1999].
* @param telemetry If true, request telemetry from that motor
*/
__EXPORT extern void up_dshot_motor_data_set(unsigned channel, uint16_t throttle, bool telemetry);

/**
* Send DShot command to a channel (motor).
*
* @param channel The channel to set.
* @param command dshot_command_t
*/
__EXPORT extern void up_dshot_motor_command(unsigned channel, uint16_t command);

/**
* Trigger dshot data transfer.
*/
__EXPORT extern void up_dshot_trigger(void);

/**
* Arm or disarm dshot outputs (This will enable/disable complete timer for safety purpose.).
*
* When disarmed, dshot output no pulse.
*
* @param armed If true, outputs are armed; if false they
* are disarmed.
*/
__EXPORT extern int up_dshot_arm(bool armed);

__END_DECLS
1 change: 1 addition & 0 deletions src/drivers/stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ add_library(drivers_arch
drv_pwm_trigger.c
drv_input_capture.c
drv_led_pwm.cpp
drv_dshot.c
)
add_dependencies(drivers_arch prebuild_targets)
target_link_libraries(drivers_arch PRIVATE drivers_board)
Expand Down
Loading