mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 05:13:34 +08:00
drivers: dshot: prepare to extend for bidrectional dshot
This commit is contained in:
committed by
David Sidrane
parent
2de0af52e8
commit
e2969952d3
@@ -89,6 +89,7 @@ static uint32_t dshot_tcmp;
|
||||
static uint32_t bdshot_tcmp;
|
||||
static uint32_t dshot_mask;
|
||||
static uint32_t bdshot_recv_mask;
|
||||
static uint32_t bdshot_parsed_recv_mask;
|
||||
|
||||
static inline uint32_t flexio_getreg32(uint32_t offset)
|
||||
{
|
||||
@@ -350,13 +351,14 @@ int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq, bool enable_bi
|
||||
return channel_mask;
|
||||
}
|
||||
|
||||
|
||||
void up_bdshot_erpm(void)
|
||||
{
|
||||
uint32_t value;
|
||||
uint32_t erpm;
|
||||
uint32_t csum_data;
|
||||
|
||||
bdshot_parsed_recv_mask = 0;
|
||||
|
||||
// Decode each individual channel
|
||||
for (uint8_t channel = 0; (channel < DSHOT_TIMERS); channel++) {
|
||||
if (bdshot_recv_mask & (1 << channel)) {
|
||||
@@ -391,13 +393,25 @@ void up_bdshot_erpm(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bdshot_parsed_recv_mask = bdshot_recv_mask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int up_bdshot_get_erpm(uint8_t channel, int *erpm)
|
||||
{
|
||||
if (bdshot_parsed_recv_mask & (1 << channel)) {
|
||||
*erpm = dshot_inst[channel].erpm;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void up_bdshot_status(void)
|
||||
{
|
||||
/* Call this function to calculate last ERPM ideally a workqueue does this.
|
||||
For now this to debug using the dshot status cli command */
|
||||
up_bdshot_erpm();
|
||||
|
||||
for (uint8_t channel = 0; (channel < DSHOT_TIMERS); channel++) {
|
||||
|
||||
@@ -424,6 +438,9 @@ void up_dshot_trigger(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Calc data now since we're not event driven
|
||||
up_bdshot_erpm();
|
||||
|
||||
bdshot_recv_mask = 0x0;
|
||||
|
||||
clear_timer_status_flags(0xFF);
|
||||
|
||||
@@ -82,7 +82,7 @@ static uint8_t dshot_burst_buffer_array[DSHOT_TIMERS * DSHOT_BURST_BUFFER_SIZE(M
|
||||
px4_cache_aligned_data() = {};
|
||||
static uint32_t *dshot_burst_buffer[DSHOT_TIMERS] = {};
|
||||
|
||||
int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq)
|
||||
int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq, bool enable_bidirectional_dshot)
|
||||
{
|
||||
unsigned buffer_offset = 0;
|
||||
|
||||
@@ -152,6 +152,10 @@ int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq)
|
||||
return ret_val == OK ? channels_init_mask : ret_val;
|
||||
}
|
||||
|
||||
void up_bdshot_status(void)
|
||||
{
|
||||
}
|
||||
|
||||
void up_dshot_trigger(void)
|
||||
{
|
||||
for (uint8_t timer = 0; (timer < DSHOT_TIMERS); timer++) {
|
||||
|
||||
Reference in New Issue
Block a user