Bidirectional DSHOT and eRPM telemetry #1556
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements bidirectional DSHOT in the CF 2.1 Brushless motor drivers, enabled through the
motorPowerSet.bidiDshotparam. ESC eRPM telemetry readings are exposed asmotor.m#_erpmlog variables.DSHOT RX is implemented with DMA Input Capture, recording the timestamps of all edge transitions on the DSHOT line for 100us after the command packet (accounting for 30us wait time, ~50us telemetry packet time and some headroom).
All motors share TIM2 and DSHOT TX and RX need different timer periods, so at each cycle the code transmits a command to M1, M3 and M4, waits for their telemetry reply, then transmits to M2 and receive.
Caveats
motorPowerSet.bidiDshotis enabled at boot, so it currently needs to be set to 1 while the drone is already turned on, on the ground.Implementation
The changes are split in a few commits that should be testable individually:
motorPowerSet.bidiDshotparam to turn on bidirectional DSHOT for all motors. When set, ESCs should reset and beep the motors, then everything should work normally. If you attach a logic analyser to DSHOT lineRC_IN, you should see the DSHOT signal inverted (idle high) and that command packets are followed by a telemetry packet.dshotDecodeTelemetryERPMResources
https://brushlesswhoop.com/dshot-and-bidirectional-dshot/#bidirectional-dshot
https://github.com/betaflight/betaflight/blob/40b8a468f16d683aefed91a6ecf77590943f47f3/src/platform/STM32/pwm_output_dshot.c
https://github.com/betaflight/betaflight/blob/0b94db5fee44ec5af9f899a229aa329c90cbd8a8/src/platform/common/stm32/pwm_output_dshot_shared.c#L164
Closes #1411