Skip to content

Commit

Permalink
dshot bidir
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien-B committed Mar 19, 2024
1 parent 60b3d4a commit 024d589
Show file tree
Hide file tree
Showing 19 changed files with 4,486 additions and 282 deletions.
8 changes: 8 additions & 0 deletions conf/modules/actuators_dshot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
It might be required to disable by hand some PWM output to avoid conflicts when they are activated by default on a board.
Currently only implemented over ChibiOS.
</description>
<configure name="DSHOT_BIDIR" value="FALSE" description="Bidirectionnal DSHOT for fast rpm feedback"/>
<define name="DSHOT_SPEED" value="600" description="DSHOT speed (150,300,600,1200)"/>
</doc>
<dep>
Expand All @@ -19,8 +20,15 @@
<file name="actuators_dshot.h"/>
</header>
<makefile>
<configure name="DSHOT_BIDIR" default="FALSE"/>
<define name="DSHOT_BIDIR" value="$(DSHOT_BIDIR)"/>
<define name="USE_GPT7" value="TRUE" cond="ifeq ($(DSHOT_BIDIR),TRUE)"/>
<file_arch name="actuators_dshot_arch.c"/>
<file_arch name="esc_dshot.c" cond="ifeq ($(RTOS),chibios)"/>
<file_arch name="dshot_rpmCapture.c" cond="ifeq ($(DSHOT_BIDIR),TRUE)"/>
<file_arch name="dshot_erps.c" cond="ifeq ($(DSHOT_BIDIR),TRUE)"/>
<file_arch name="inputCapture.c" cond="ifeq ($(DSHOT_BIDIR),TRUE)"/>
<file_arch name="timerDmaCache.c" cond="ifeq ($(DSHOT_BIDIR),TRUE)"/>
<file_arch name="hal_stm32_dma.c" dir="mcu_periph" cond="ifeq ($(RTOS),chibios)"/>
<test/>
</makefile>
Expand Down
4 changes: 4 additions & 0 deletions sw/airborne/arch/chibios/mcu_periph/gpio_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ void gpio_setup_input_pulldown(ioportid_t port, uint16_t gpios)
chSysUnlock();
}

void gpio_setup_pin_af_pullup(ioportid_t port, uint16_t pin, uint8_t af) {
palSetPadMode(port, pin, PAL_MODE_ALTERNATE(af) | PAL_STM32_PUPDR_PULLUP);
}

void gpio_setup_pin_af(ioportid_t port, uint16_t pin, uint8_t af, bool is_output)
{
chSysLock();
Expand Down
6 changes: 6 additions & 0 deletions sw/airborne/arch/chibios/mcu_periph/gpio_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ extern void gpio_setup_input_pulldown(ioportid_t port, uint16_t gpios);
*/
extern void gpio_setup_pin_af(ioportid_t port, uint16_t pin, uint8_t af, bool is_output);

/**
* Setup a gpio for input pullup with alternate function.
* This is an STM32 specific helper funtion and should only be used in stm32 code.
*/
void gpio_setup_pin_af_pullup(ioportid_t port, uint16_t pin, uint8_t af);

/**
* Setup a gpio for analog use.
* @param[in] port
Expand Down

0 comments on commit 024d589

Please sign in to comment.