|
Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
DSHOT driver based on ChibiOS. More...
#include <ch.h>#include <hal.h>#include "mcu_periph/hal_stm32_dma.h"#include "modules/actuators/esc_dshot_config.h"
Include dependency graph for esc_dshot.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | DshotTelemetryFrame |
| telemetry packed as sent by some KISS ESC More... | |
| struct | DshotTelemetry |
| telemetry with timestamp More... | |
| union | DshotDmaBuffer |
| struct | DSHOTConfig |
| DSHOT Driver configuration structure. More... | |
| union | DshotPacket |
| struct | DshotPackets |
| struct | DSHOTDriver |
| DSHOT driver structure. More... | |
| union | DshotTelemetryFrame.__unnamed7__ |
| struct | DshotTelemetryFrame.__unnamed7__.__unnamed9__ |
| struct | DshotPacket.__unnamed11__ |
Macros | |
| #define | DSHOT_CHANNEL_FIRST_INDEX 0U |
| #define | DSHOT_BIT_WIDTHS 16U |
| DMA buffer size and number of channels. | |
| #define | DSHOT_PRE_FRAME_SILENT_SYNC_BITS 2U |
| #define | DSHOT_POST_FRAME_SILENT_SYNC_BITS 4U |
| #define | DSHOT_DMA_BUFFER_SIZE |
| #define | DSHOT_BIDIR_ERR_CRC UINT32_MAX |
| special values returned by dshotGetRpm function | |
| #define | DSHOT_BIDIR_TLM_EDT (UINT32_MAX-1U) |
| #define | DSHOT_ALL_MOTORS 255U |
| special value for index : send order to all channels | |
Typedefs | |
| typedef struct DSHOTDriver | DSHOTDriver |
| Type of a structure representing an DSHOT driver. | |
Enumerations | |
| enum | dshot_special_commands_t { DSHOT_CMD_MOTOR_STOP = 0U , DSHOT_CMD_BEACON1 , DSHOT_CMD_BEACON2 , DSHOT_CMD_BEACON3 , DSHOT_CMD_BEACON4 , DSHOT_CMD_BEACON5 , DSHOT_CMD_ESC_INFO , DSHOT_CMD_SPIN_DIRECTION_1 , DSHOT_CMD_SPIN_DIRECTION_2 , DSHOT_CMD_3D_MODE_OFF , DSHOT_CMD_3D_MODE_ON , DSHOT_CMD_SETTINGS_REQUEST , DSHOT_CMD_SAVE_SETTINGS , DSHOT_CMD_BIDIR_EDT_MODE_ON , DSHOT_CMD_BIDIR_EDT_MODE_OFF , DSHOT_CMD_SPIN_DIRECTION_NORMAL = 20U , DSHOT_CMD_SPIN_DIRECTION_REVERSED = 21U , DSHOT_CMD_LED0_ON , DSHOT_CMD_LED1_ON , DSHOT_CMD_LED2_ON , DSHOT_CMD_LED3_ON , DSHOT_CMD_LED0_OFF , DSHOT_CMD_LED1_OFF , DSHOT_CMD_LED2_OFF , DSHOT_CMD_LED3_OFF , DSHOT_CMD_AUDIO_STREAM_MODE_ON_OFF = 30U , DSHOT_CMD_SILENT_MODE_ON_OFF = 31U , DSHOT_CMD_MAX = 47U , DSHOT_MIN_THROTTLE } |
| DSHOT special commands (0-47) for KISS and BLHELI ESC. More... | |
Functions | |
| void | dshotStart (DSHOTDriver *driver, const DSHOTConfig *config) |
| Configures and activates the DSHOT peripheral. | |
| void | dshotStop (DSHOTDriver *driver) |
| stop the DSHOT driver and free the related resources : pwm driver and dma driver. | |
| void | dshotSetThrottle (DSHOTDriver *driver, const uint8_t index, const uint16_t throttle) |
| prepare throttle order for specified ESC | |
| void | dshotSendFrame (DSHOTDriver *driver) |
| send throttle order | |
| void | dshotSendThrottles (DSHOTDriver *driver, const uint16_t throttles[DSHOT_CHANNELS]) |
| send throttle packed order to all of the ESCs | |
| void | dshotSendSpecialCommand (DSHOTDriver *driver, const uint8_t index, const dshot_special_commands_t specmd) |
| send special order to one of the ESC (BHELIX, KISS, ...) | |
| uint32_t | dshotGetCrcErrorCount (const DSHOTDriver *driver) |
| return number of telemetry crc error since dshotStart | |
| uint32_t | dshotGetTelemetryFrameCount (const DSHOTDriver *driver) |
| return number of telemetry succesfull frame since dshotStart | |
| DshotTelemetry | dshotGetTelemetry (DSHOTDriver *driver, const uint32_t index) |
| return last received telemetry data | |
DSHOT driver based on ChibiOS.
Definition in file esc_dshot.h.
| struct DshotTelemetryFrame |
telemetry packed as sent by some KISS ESC
Definition at line 139 of file esc_dshot.h.
| Data Fields | ||
|---|---|---|
| union DshotTelemetryFrame.__unnamed7__ | __unnamed__ | |
| uint8_t | crc8 | |
| struct DshotTelemetry |
telemetry with timestamp
Definition at line 158 of file esc_dshot.h.
Collaboration diagram for DshotTelemetry:| Data Fields | ||
|---|---|---|
| DshotTelemetryFrame | frame | |
| uint8_t | status | |
| uint8_t | stress | |
| systime_t | ts | |
| union DshotDmaBuffer |
Definition at line 166 of file esc_dshot.h.
| Data Fields | ||
|---|---|---|
| uint16_t | widths16[DSHOT_DMA_BUFFER_SIZE][DSHOT_CHANNELS] | |
| struct DSHOTConfig |
DSHOT Driver configuration structure.
Definition at line 182 of file esc_dshot.h.
Collaboration diagram for DSHOTConfig:| Data Fields | ||
|---|---|---|
| DshotDmaBuffer * | dma_buf | dshot dma buffer, should be defined in a non Dcached region |
| uint8_t | dma_channel | : dma channel associated with pwm timer used to generate dshot output |
| uint32_t | dma_stream | : dma stream associated with pwm timer used to generate dshot output |
| PWMDriver * | pwmp | PWM driver that feed up to 4 dshot lines. |
| uint16_t | speed_khz |
dynamic dshot speed, when speed id not known at compilation
|
| SerialDriver * | tlm_sd | if non null : dshot telemetry serial driver |
| union DshotPacket |
Definition at line 265 of file esc_dshot.h.
Collaboration diagram for DshotPacket:| Data Fields | ||
|---|---|---|
| struct DshotPacket.__unnamed11__ | __unnamed__ | |
| uint16_t | rawFrame | |
| struct DshotPackets |
Definition at line 275 of file esc_dshot.h.
Collaboration diagram for DshotPackets:| Data Fields | ||
|---|---|---|
| uint8_t | currentTlmQry | |
| DshotPacket | dp[DSHOT_CHANNELS] | |
| DshotTelemetry | dt[DSHOT_CHANNELS] | |
| volatile bool | onGoingQry | |
| mutex_t | tlmMtx[DSHOT_CHANNELS] | |
| union DshotTelemetryFrame.__unnamed7__ |
Definition at line 140 of file esc_dshot.h.
| Data Fields | ||
|---|---|---|
| struct DshotTelemetryFrame.__unnamed7__.__unnamed9__ | __unnamed__ | |
| uint8_t | rawData[9] | |
| struct DshotTelemetryFrame.__unnamed7__.__unnamed9__ |
| struct DshotPacket.__unnamed11__ |
Definition at line 266 of file esc_dshot.h.
| Data Fields | ||
|---|---|---|
| uint16_t | crc:4 | |
| uint16_t | telemetryRequest:1 | |
| uint16_t | throttle:11 | |
special value for index : send order to all channels
Definition at line 74 of file esc_dshot.h.
| #define DSHOT_BIDIR_ERR_CRC UINT32_MAX |
special values returned by dshotGetRpm function
Definition at line 65 of file esc_dshot.h.
| #define DSHOT_BIDIR_TLM_EDT (UINT32_MAX-1U) |
Definition at line 66 of file esc_dshot.h.
DMA buffer size and number of channels.
Definition at line 48 of file esc_dshot.h.
| #define DSHOT_CHANNEL_FIRST_INDEX 0U |
Definition at line 43 of file esc_dshot.h.
| #define DSHOT_DMA_BUFFER_SIZE |
Definition at line 51 of file esc_dshot.h.
Definition at line 50 of file esc_dshot.h.
Definition at line 49 of file esc_dshot.h.
| typedef struct DSHOTDriver DSHOTDriver |
Type of a structure representing an DSHOT driver.
Definition at line 176 of file esc_dshot.h.
DSHOT special commands (0-47) for KISS and BLHELI ESC.
Definition at line 102 of file esc_dshot.h.
| uint32_t dshotGetCrcErrorCount | ( | const DSHOTDriver * | driver | ) |
return number of telemetry crc error since dshotStart
| [in] | driver | pointer to the DSHOTDriver object |
Definition at line 442 of file esc_dshot.c.
References DSHOTDriver::crc_errors.
| DshotTelemetry dshotGetTelemetry | ( | DSHOTDriver * | driver, |
| uint32_t | index | ||
| ) |
return last received telemetry data
| [in] | driver | pointer to the DSHOTDriver object |
| [in] | index | channel : [0..3] or [0..1] depending on driver used |
Definition at line 468 of file esc_dshot.c.
References DSHOT_CHANNEL_FIRST_INDEX, DSHOT_CHANNELS, DSHOTDriver::dshotMotors, DshotPackets::dt, foo, and DshotPackets::tlmMtx.
Referenced by actuators_dshot_arch_commit(), and esc_msg_send().
Here is the caller graph for this function:| uint32_t dshotGetTelemetryFrameCount | ( | const DSHOTDriver * | driver | ) |
return number of telemetry succesfull frame since dshotStart
| [in] | driver | pointer to the DSHOTDriver object |
Definition at line 454 of file esc_dshot.c.
References DSHOTDriver::tlm_frame_nb.
| void dshotSendFrame | ( | DSHOTDriver * | driver | ) |
send throttle order
| [in] | driver | pointer to the DSHOTDriver object |
Definition at line 404 of file esc_dshot.c.
References buildDshotDmaBuffer(), DSHOTDriver::config, DshotPackets::currentTlmQry, DSHOTConfig::dma_buf, DMA_READY, DSHOTDriver::dmap, dmaTransfert(), DshotPackets::dp, DSHOT_CHANNELS, DSHOT_DMA_BUFFER_SIZE, DSHOTDriver::dshotMotors, dshotRpmCatchErps(), dshotStop(), foo, DSHOTDriver::mb, DshotPackets::onGoingQry, DSHOTConfig::pwmp, setDshotPacketTlm(), DMADriver::state, and DSHOTConfig::tlm_sd.
Referenced by actuators_dshot_arch_commit(), dshotSendSpecialCommand(), and dshotSendThrottles().
Here is the call graph for this function:
Here is the caller graph for this function:| void dshotSendSpecialCommand | ( | DSHOTDriver * | driver, |
| const uint8_t | index, | ||
| const dshot_special_commands_t | specmd | ||
| ) |
send special order to one of the ESC (BHELIX, KISS, ...)
| [in] | driver | pointer to the DSHOTDriver object |
| [in] | index | channel : [0..3] or [0..1] depending on driver used |
| [in] | specmd | special commands, see enum @api |
Definition at line 330 of file esc_dshot.c.
References DSHOTDriver::config, DshotPackets::dp, DSHOT_ALL_MOTORS, DSHOT_CHANNELS, DSHOT_CMD_3D_MODE_OFF, DSHOT_CMD_3D_MODE_ON, DSHOT_CMD_AUDIO_STREAM_MODE_ON_OFF, DSHOT_CMD_BIDIR_EDT_MODE_OFF, DSHOT_CMD_BIDIR_EDT_MODE_ON, DSHOT_CMD_MAX, DSHOT_CMD_SAVE_SETTINGS, DSHOT_CMD_SETTINGS_REQUEST, DSHOT_CMD_SILENT_MODE_ON_OFF, DSHOT_CMD_SPIN_DIRECTION_1, DSHOT_CMD_SPIN_DIRECTION_2, DSHOTDriver::dshotMotors, dshotSendFrame(), foo, setDshotPacketThrottle(), setDshotPacketTlm(), and DSHOTConfig::tlm_sd.
Here is the call graph for this function:| void dshotSendThrottles | ( | DSHOTDriver * | driver, |
| const uint16_t | throttles[DSHOT_CHANNELS] | ||
| ) |
send throttle packed order to all of the ESCs
| [in] | driver | pointer to the DSHOTDriver object |
| [in] | throttle[DSHOT_CHANNELS] | [48 .. 2047] |
Definition at line 385 of file esc_dshot.c.
References DshotPackets::dp, DSHOT_CHANNELS, DSHOTDriver::dshotMotors, dshotSendFrame(), foo, and setDshotPacketThrottle().
Here is the call graph for this function:prepare throttle order for specified ESC
| [in] | driver | pointer to the DSHOTDriver object |
| [in] | index | channel : [0..3] or [0..1] depending on driver used |
| [in] | throttle | [48 .. 2047] |
Definition at line 301 of file esc_dshot.c.
References DshotPackets::dp, DSHOT_ALL_MOTORS, DSHOT_CHANNEL_FIRST_INDEX, DSHOT_CHANNELS, DSHOT_CMD_MAX, DSHOT_MAX_VALUE, DSHOTDriver::dshotMotors, foo, Min, and setDshotPacketThrottle().
Referenced by actuators_dshot_arch_commit().
Here is the call graph for this function:
Here is the caller graph for this function:| void dshotStart | ( | DSHOTDriver * | driver, |
| const DSHOTConfig * | config | ||
| ) |
Configures and activates the DSHOT peripheral.
| [in] | driver | pointer to the DSHOTDriver object |
| [in] | config | pointer to the DSHOTConfig object. @api |
Definition at line 154 of file esc_dshot.c.
References DSHOTDriver::_mbBuf, ARRAY_LEN, DSHOTDriver::bit0Duty, DSHOTDriver::bit1Duty, DSHOTDriver::config, config, DSHOTDriver::crc_errors, DshotPackets::currentTlmQry, DCR_DBA, DCR_DBL, DSHOTDriver::dma_conf, DMA_DIR_M2P, DMA_ONESHOT, dmaObjectInit(), DSHOTDriver::dmap, dmaStart(), DshotPackets::dp, DSHOT_BIDIR, DSHOT_BIT0_DUTY_RATIO, DSHOT_CHANNELS, DSHOT_PWM_PERIOD, DSHOT_TELEMETRY_BAUD, DSHOTDriver::dshotMotors, dshotRpmCaptureStart(), dshotTlmRec(), foo, getTimerWidth(), makeDshotPacket(), DSHOTDriver::mb, DshotPackets::onGoingQry, DSHOTDriver::pwm_conf, DSHOTConfig::pwmp, DMAConfig::stream, TICK_FREQ, TICKS_PER_PERIOD, DSHOTDriver::tlm_frame_nb, DSHOTConfig::tlm_sd, and DshotPackets::tlmMtx.
Referenced by actuators_dshot_arch_init().
Here is the call graph for this function:
Here is the caller graph for this function:| void dshotStop | ( | DSHOTDriver * | driver | ) |
stop the DSHOT driver and free the related resources : pwm driver and dma driver.
| [in] | driver | pointer to the DSHOTDriver object @api |
Definition at line 260 of file esc_dshot.c.
References DSHOTDriver::config, DSHOTDriver::dmap, dmaStop(), dmaStopTransfert(), foo, and DSHOTConfig::pwmp.
Referenced by dshotSendFrame().
Here is the call graph for this function:
Here is the caller graph for this function: