9 0x19, 0x1B, 0x12, 0x13, 0x1D, 0x15, 0x16, 0x17,
10 0x1A, 0x09, 0x0A, 0x0B, 0x1E, 0x0D, 0x0E, 0x0F};
16 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
17 0xff, 0x9, 0xa, 0xb, 0xff, 0xd, 0xe, 0xf,
18 0xff, 0xff, 0x2, 0x3, 0xff, 0x5, 0x6, 0x7,
19 0xff, 0x0, 0x8, 0x1, 0xff, 0x4, 0xc, 0xff};
74 return derpsp->
ep.mantisse << derpsp->
ep.exponent;
114 return (~(
val ^ (
val >> 4) ^ (
val >> 8))) & 0x0F;
127 const uint32_t exponent = eperiod >> 9;
129 if (exponent > 128) {
132 p.exponent = 32U - __builtin_clz(exponent);
133 p.mantisse = eperiod >>
p.exponent;
165 return num ^ (num >> 1);
178 for (
size_t i = 0U; i < 4U; i++) {
197 for (
size_t i = 0; i < 4U; i++) {
199 if (nibble == 0xff) {
205 ret |= (nibble << (i << 2U));
static const uint8_t gcrNibble[16]
IBM GCR encoding lookup table.
static uint32_t greyDecode(const uint32_t num)
get natural binary value from grey binary
const DshotErps * DshotErpsSetFromFrame(DshotErps *derpsp, uint32_t frame)
initialise from GCR encoded frame
static void frameToPacket(DshotErps *derpsp)
decode eperiod
static uint32_t eperiodEncode(const uint16_t eperiod)
encode eperiod to 20 bits GCR of grey value
static uint32_t gcrEncode(uint32_t from)
encode 16 bit value to 20 bits GCR
static uint8_t crc4(uint16_t val)
calculate crc4
uint32_t DshotErpsGetRpm(const DshotErps *derpsp)
calculate and return rpm
static void packetToFrame(DshotErps *derpsp)
encode eperiod
uint32_t DshotErpsGetEperiod(const DshotErps *derpsp)
return eperiod from mantisse and exponent
static uint32_t greyEncode(uint32_t num)
get grey binary value from natural binary
static uint32_t gcrDecode(uint32_t from)
decode 20 bits GCR value to 16 bits natural
static uint32_t eperiodDecode(const uint32_t frame)
decode 20 bits GCR of grey value to eperiod
static const uint8_t gcrNibbleInv[32]
IBM GCR decoding lookup table.
static void setFromEperiod(DshotErps *derpsp, uint32_t eperiod)
initialize from eperiod in microseconds
static DshotEPeriodPacket eperiodToPacked(const uint32_t eperiod)
encode packet from eperiod
bool DshotErpsCheckCrc4(const DshotErps *derpsp)
check packed validity
const DshotErps * DshotErpsSetFromRpm(DshotErps *derpsp, uint32_t rpm)
initialise from rpm value
ERPS complete frame, raw and decoded.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.