mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-15 00:01:35 +08:00
dshot: remove BOARD_DSHOT_MOTOR_ASSIGNMENT & handle timer channel gaps
This commit is contained in:
@@ -58,6 +58,8 @@ static inline constexpr io_timers_channel_mapping_t initIOTimerChannelMapping(co
|
||||
}
|
||||
|
||||
uint32_t first_channel = UINT32_MAX;
|
||||
uint32_t min_timer_channel = UINT32_MAX;
|
||||
uint32_t max_timer_channel = 0;
|
||||
uint32_t channel_count = 0;
|
||||
|
||||
for (uint32_t channel = 0; channel < MAX_TIMER_IO_CHANNELS; ++channel) {
|
||||
@@ -74,11 +76,23 @@ static inline constexpr io_timers_channel_mapping_t initIOTimerChannelMapping(co
|
||||
}
|
||||
|
||||
++channel_count;
|
||||
|
||||
if (timer_io_channels_conf[channel].timer_channel < min_timer_channel) {
|
||||
min_timer_channel = timer_io_channels_conf[channel].timer_channel;
|
||||
}
|
||||
|
||||
if (timer_io_channels_conf[channel].timer_channel > max_timer_channel) {
|
||||
max_timer_channel = timer_io_channels_conf[channel].timer_channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (first_channel == UINT32_MAX) { //unused timer, channel_count is 0
|
||||
first_channel = 0;
|
||||
|
||||
} else {
|
||||
ret.element[i].lowest_timer_channel = min_timer_channel;
|
||||
ret.element[i].channel_count_including_gaps = max_timer_channel - min_timer_channel + 1;
|
||||
}
|
||||
|
||||
ret.element[i].first_channel_index = first_channel;
|
||||
|
||||
Reference in New Issue
Block a user