The inbound half of DShot: the GCR (group-coded recording) burst an ESC (electronic speed controller) sends back on the signal line.
More...
|
| static uint8_t | nibble_of (uint8_t quintet) |
| | 0xFF for the sixteen codes that are not in the table.
|
| static uint16_t | fold (uint16_t v) |
| | The checksum, folded over the twelve bits that carry the reading.
|
| uint32_t | dshot_gcr_encode (uint16_t value) |
| | The other direction, for the suite and for anything that fakes an ESC.
|
| bool | dshot_gcr_decode (uint32_t line, uint16_t *out) |
| | Undo the line code and the group code: 21 line bits to a 16-bit value.
|
| static void | erpm_from_payload (uint16_t payload, dshot_telem_t *out) |
| | Fill an eRPM reading from a twelve-bit payload.
|
| bool | dshot_telem_from_value (uint16_t value, bool edt, dshot_telem_t *out) |
| | A 16-bit value to what it meant, checksum first.
|
| bool | dshot_telem_decode (uint32_t line, bool edt, dshot_telem_t *out) |
| | The two steps above, together: 21 line bits to a reading.
|
| uint16_t | dshot_telem_value (dshot_telem_kind_t kind, uint16_t payload) |
| | Build a response, for the suite and for anything that fakes an ESC.
|
| uint32_t | dshot_rpm (uint32_t erpm, uint8_t pole_pairs) |
| | Electrical rpm to mechanical rpm.
|
| static bool | sample_at (const uint32_t *samples, size_t i) |
| | Read one sample of the capture.
|
| bool | dshot_rx_bits (const uint32_t *samples, size_t words, uint8_t oversample, uint32_t *line) |
| | Turn an oversampled capture of the line into the 21 bits of the response.
|
| uint32_t | dshot_edt_millivolts (uint16_t count) |
| | Millivolts for a DSHOT_TELEM_VOLTAGE payload (at most 255 * 250 = 63,750).
|
| uint32_t | dshot_edt_amps (uint16_t count) |
| | Amperes for a DSHOT_TELEM_CURRENT payload.
|
| uint32_t | dshot_edt_celsius (uint16_t count) |
| | Degrees Celsius for a DSHOT_TELEM_TEMPERATURE payload.
|
The inbound half of DShot: the GCR (group-coded recording) burst an ESC (electronic speed controller) sends back on the signal line.
See dshot.h for the model.
SPDX-License-Identifier: MIT
| bool dshot_gcr_decode |
( |
uint32_t | line, |
|
|
uint16_t * | out ) |
Undo the line code and the group code: 21 line bits to a 16-bit value.
The line is differential – each bit is the previous one exclusive-ored with the data – so a run of identical bits becomes a level that does not change, which is what keeps the ESC's clock and this end's from having to agree for long. Undoing it is x ^ (x >> 1), and the leading bit falls off the top. The 20 bits below are four quintets, each one nibble.
Returns false for a quintet that is not in the table, which is what a missed or extra sample looks like.
- Parameters
-
| line | The 21 captured line bits. |
| out | Receives the 16-bit value. |
- Returns
- false for a quintet that is not in the table, which is what a missed or extra sample looks like; true otherwise.
| bool dshot_rx_bits |
( |
const uint32_t * | samples, |
|
|
size_t | words, |
|
|
uint8_t | oversample, |
|
|
uint32_t * | line ) |
Turn an oversampled capture of the line into the 21 bits of the response.
The capture is a bit per sample, most significant bit of word 0 first, at oversample samples per response bit. Sampling at a fixed rate and dividing is not enough on its own: the ESC's bit rate is its own crystal's, a percent or two from this end's, and 21 bits is long enough for that to walk a sample point off the end of a bit. The phase is therefore reset at every transition, the same way a UART (universal asynchronous receiver-transmitter) resynchronises on a start bit, and each bit is read from the middle of its window.
The response is located by the first falling edge: bidirectional DShot idles high, so everything before that edge is idle line and not data.
Returns false when the capture holds no falling edge, or ends before 21 bits have been read.
- Parameters
-
| samples | Capture, one bit per sample, MSB of word 0 first. |
| words | Number of 32-bit words in samples. |
| oversample | Samples per response bit, 2 or more. |
| line | Receives the 21 response bits. |
- Returns
- false when the capture holds no falling edge, or ends before 21 bits have been read; true otherwise.
| bool dshot_telem_from_value |
( |
uint16_t | value, |
|
|
bool | edt, |
|
|
dshot_telem_t * | out ) |
A 16-bit value to what it meant, checksum first.
The checksum is the complement of the frame's, so a correct value leaves 0x0F rather than 0 when it is folded; this returns false otherwise.
edt says whether extended telemetry was turned on and accepted for this ESC. It cannot be inferred from the bits: the type nibble that marks an extended frame is an ordinary exponent and mantissa in an eRPM one, and the two are only told apart by the guarantee an extended-telemetry ESC makes about normalising its exponent. Declaring it false reads every frame as eRPM, which is correct for every ESC that was not asked.
- Parameters
-
| value | The 16-bit frame value. |
| edt | true when extended telemetry is on for this ESC. |
| out | Receives the decoded reading. |
- Returns
- true for a valid checksum, false otherwise.