Skip to content

Commit

Permalink
dshot: cleaning UDE flag before the DMA is enabled, instead of in the…
Browse files Browse the repository at this point in the history
… callback function
  • Loading branch information
Igor-Misic committed Oct 21, 2019
1 parent 59261e4 commit bf2aebc
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c
Expand Up @@ -67,7 +67,6 @@ typedef struct dshot_handler_t {
bool init;
DMA_HANDLE dma_handle;
uint32_t dma_size;
uint8_t callback_arg;
} dshot_handler_t;

#define DMA_BUFFER_MASK (PX4_ARCH_DCACHE_LINESIZE - 1)
Expand All @@ -85,7 +84,6 @@ static const uint8_t motor_assignment[MOTORS_NUMBER] = BOARD_DSHOT_MOTOR_ASSIGNM
#endif /* BOARD_DSHOT_MOTOR_ASSIGNMENT */

void dshot_dmar_data_prepare(uint8_t timer, uint8_t first_motor, uint8_t motors_number);
void dshot_callback(DMA_HANDLE handle, uint8_t status, void *arg);

int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq)
{
Expand Down Expand Up @@ -182,22 +180,16 @@ void up_dshot_trigger(void)
dshot_handler[timer].dma_size,
DSHOT_DMA_SCR);

// Clean UDE flag before DMA is started
io_timer_update_dma_req(timer, false);
// Trigger DMA (DShot Outputs)
dshot_handler[timer].callback_arg = timer;
stm32_dmastart(dshot_handler[timer].dma_handle, &dshot_callback, &(dshot_handler[timer].callback_arg), false);
stm32_dmastart(dshot_handler[timer].dma_handle, NULL, NULL, false);
io_timer_update_dma_req(timer, true);

}
}
}

void dshot_callback(DMA_HANDLE handle, uint8_t status, void *arg)
{

uint8_t timer = *((uint8_t *)arg);
io_timer_update_dma_req(timer, false);
}

/**
* bits 1-11 - throttle value (0-47 are reserved, 48-2047 give 2000 steps of throttle resolution)
* bit 12 - dshot telemetry enable/disable
Expand Down

0 comments on commit bf2aebc

Please sign in to comment.