Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
dshot_erps.h File Reference
#include <ch.h>
#include <hal.h>
+ Include dependency graph for dshot_erps.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  DshotEPeriodPacket
 ERPS classic rpm frame. More...
 
union  DshotEPeriodTelemetry
 ERPS telemetry frame. More...
 
struct  DshotErps
 ERPS complete frame, raw and decoded. More...
 
struct  DshotEPeriodPacket.__unnamed2__
 
struct  DshotEPeriodTelemetry.__unnamed4__
 

Enumerations

enum  EdtType {
  EDT_NOTEDT =0x0 , EDT_TEMP =0x2 , EDT_VOLT =0x4 , EDT_CURRENT =0x6 ,
  EDT_DBG1 =0x8 , EDT_DBG2 =0xA , EDT_STRESS =0xC , EDT_STATUS =0xE
}
 ERPS telemetry type. More...
 
enum  EdtStatus { EDT_STATUS_ALERT = 1<<7 , EDT_STATUS_WARNING = 1<<6 , EDT_STATUS_ERROR = 1<<5 }
 

Functions

 _Static_assert (sizeof(DshotEPeriodPacket)==sizeof(uint16_t), "DshotEPeriodPacket size error")
 
 _Static_assert (sizeof(DshotEPeriodTelemetry)==sizeof(uint16_t), "DshotEPeriodTelemetry size error")
 
const DshotErpsDshotErpsSetFromFrame (DshotErps *derpsp, uint32_t frame)
 initialise from GCR encoded frame More...
 
const DshotErpsDshotErpsSetFromRpm (DshotErps *derpsp, uint32_t rpm)
 initialise from rpm value More...
 
uint32_t DshotErpsGetEperiod (const DshotErps *derpsp)
 return eperiod from mantisse and exponent More...
 
uint32_t DshotErpsGetRpm (const DshotErps *derpsp)
 calculate and return rpm More...
 
bool DshotErpsCheckCrc4 (const DshotErps *derpsp)
 check packed validity More...
 
static uint32_t DshotErpsGetFrame (const DshotErps *derpsp)
 return encoded frame More...
 
static bool DshotErpsIsEdt (const DshotErps *derpsp)
 return true if current frame is a telemetry frame More...
 
static EdtType DshotErpsEdtType (const DshotErps *derpsp)
 return type of a telemetry frame More...
 
static uint8_t DshotErpsEdtTempCentigrade (const DshotErps *derpsp)
 return temperature for a temperature telemetry frame More...
 
static uint16_t DshotErpsEdtCentiVolts (const DshotErps *derpsp)
 return voltage for a voltage telemetry frame More...
 
static uint16_t DshotErpsEdtCurrentAmp (const DshotErps *derpsp)
 return current intensity for a current telemetry frame More...
 
static uint16_t DshotErpsEdtStress (const DshotErps *derpsp)
 return stress value More...
 
static uint16_t DshotErpsEdtStatus (const DshotErps *derpsp)
 return status value More...
 

Data Structure Documentation

◆ DshotEPeriodPacket

union DshotEPeriodPacket

ERPS classic rpm frame.

Definition at line 30 of file dshot_erps.h.

+ Collaboration diagram for DshotEPeriodPacket:
Data Fields
struct DshotEPeriodPacket __unnamed__
uint16_t rawFrame

◆ DshotEPeriodTelemetry

union DshotEPeriodTelemetry

ERPS telemetry frame.

Definition at line 42 of file dshot_erps.h.

+ Collaboration diagram for DshotEPeriodTelemetry:
Data Fields
struct DshotEPeriodTelemetry __unnamed__
uint16_t rawFrame

◆ DshotErps

struct DshotErps

ERPS complete frame, raw and decoded.

Definition at line 58 of file dshot_erps.h.

+ Collaboration diagram for DshotErps:
Data Fields
uint32_t ef
DshotEPeriodPacket ep

◆ DshotEPeriodPacket.__unnamed2__

struct DshotEPeriodPacket.__unnamed2__

Definition at line 31 of file dshot_erps.h.

Data Fields
uint16_t crc:4
uint16_t exponent:3
uint16_t mantisse:9

◆ DshotEPeriodTelemetry.__unnamed4__

struct DshotEPeriodTelemetry.__unnamed4__

Definition at line 43 of file dshot_erps.h.

Data Fields
uint16_t crc:4
EdtType edt_type:4
uint16_t edt_value:8

Enumeration Type Documentation

◆ EdtStatus

enum EdtStatus
Enumerator
EDT_STATUS_ALERT 
EDT_STATUS_WARNING 
EDT_STATUS_ERROR 

Definition at line 21 of file dshot_erps.h.

◆ EdtType

enum EdtType

ERPS telemetry type.

Note
last (as of mid 2022) addition to the dshot bidir protocol
Enumerator
EDT_NOTEDT 
EDT_TEMP 
EDT_VOLT 
EDT_CURRENT 
EDT_DBG1 
EDT_DBG2 
EDT_STRESS 
EDT_STATUS 

Definition at line 14 of file dshot_erps.h.

Function Documentation

◆ _Static_assert() [1/2]

_Static_assert ( sizeof(DshotEPeriodPacket = =sizeof(uint16_t),
"DshotEPeriodPacket size error"   
)

Referenced by mtostk_populate_float_array_from_buffer().

+ Here is the caller graph for this function:

◆ _Static_assert() [2/2]

_Static_assert ( sizeof(DshotEPeriodTelemetry = =sizeof(uint16_t),
"DshotEPeriodTelemetry size error"   
)

◆ DshotErpsCheckCrc4()

bool DshotErpsCheckCrc4 ( const DshotErps derpsp)

check packed validity

Parameters
[in]derpsppointer to the DshotErps object
Returns
true if CRC is OK @api

Definition at line 99 of file dshot_erps.c.

References crc4(), DshotErps::ep, and DshotEPeriodPacket::rawFrame.

+ Here is the call graph for this function:

◆ DshotErpsEdtCentiVolts()

static uint16_t DshotErpsEdtCentiVolts ( const DshotErps derpsp)
inlinestatic

return voltage for a voltage telemetry frame

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 115 of file dshot_erps.h.

References DshotErps::ep, and DshotEPeriodPacket::rawFrame.

◆ DshotErpsEdtCurrentAmp()

static uint16_t DshotErpsEdtCurrentAmp ( const DshotErps derpsp)
inlinestatic

return current intensity for a current telemetry frame

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 124 of file dshot_erps.h.

References DshotErps::ep, and DshotEPeriodPacket::rawFrame.

◆ DshotErpsEdtStatus()

static uint16_t DshotErpsEdtStatus ( const DshotErps derpsp)
inlinestatic

return status value

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 144 of file dshot_erps.h.

References DshotErps::ep, and DshotEPeriodPacket::rawFrame.

◆ DshotErpsEdtStress()

static uint16_t DshotErpsEdtStress ( const DshotErps derpsp)
inlinestatic

return stress value

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 134 of file dshot_erps.h.

References DshotErps::ep, and DshotEPeriodPacket::rawFrame.

◆ DshotErpsEdtTempCentigrade()

static uint8_t DshotErpsEdtTempCentigrade ( const DshotErps derpsp)
inlinestatic

return temperature for a temperature telemetry frame

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 106 of file dshot_erps.h.

References DshotErps::ep, and DshotEPeriodPacket::rawFrame.

◆ DshotErpsEdtType()

static EdtType DshotErpsEdtType ( const DshotErps derpsp)
inlinestatic

return type of a telemetry frame

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 97 of file dshot_erps.h.

References DshotErps::ep, and DshotEPeriodPacket::rawFrame.

◆ DshotErpsGetEperiod()

uint32_t DshotErpsGetEperiod ( const DshotErps derpsp)

return eperiod from mantisse and exponent

Parameters
[in]derpsppointer to the DshotErps object
Returns
eperiod in microseconds
Note
getEperiod avoid a division and is more cpu friendly than getRpm

Definition at line 72 of file dshot_erps.c.

References DshotErps::ep.

Referenced by DshotErpsGetRpm().

+ Here is the caller graph for this function:

◆ DshotErpsGetFrame()

static uint32_t DshotErpsGetFrame ( const DshotErps derpsp)
inlinestatic

return encoded frame

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 77 of file dshot_erps.h.

References DshotErps::ef.

◆ DshotErpsGetRpm()

uint32_t DshotErpsGetRpm ( const DshotErps derpsp)

calculate and return rpm

Parameters
[in]derpsppointer to the DshotErps object
Returns
rotational speed in RPM
Note
involve a division, which is a cpu cycle hog, If you can use getEperiod instead, it will be less calculus intensive @api

Definition at line 87 of file dshot_erps.c.

References DshotErpsGetEperiod().

+ Here is the call graph for this function:

◆ DshotErpsIsEdt()

static bool DshotErpsIsEdt ( const DshotErps derpsp)
inlinestatic

return true if current frame is a telemetry frame

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 84 of file dshot_erps.h.

References DshotErps::ep, DshotEPeriodPacket::rawFrame, and DshotEPeriodTelemetry::rawFrame.

◆ DshotErpsSetFromFrame()

const DshotErps* DshotErpsSetFromFrame ( DshotErps derpsp,
uint32_t  frame 
)

initialise from GCR encoded frame

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 44 of file dshot_erps.c.

References DshotErps::ef, frame, and frameToPacket().

+ Here is the call graph for this function:

◆ DshotErpsSetFromRpm()

const DshotErps* DshotErpsSetFromRpm ( DshotErps derpsp,
uint32_t  rpm 
)

initialise from rpm value

Parameters
[in]derpsppointer to the DshotErps object @api

Definition at line 57 of file dshot_erps.c.

References rpm, and setFromEperiod().

+ Here is the call graph for this function: