-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdshot_rmt_encoder.h
46 lines (40 loc) · 1.36 KB
/
dshot_rmt_encoder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <driver/rmt_encoder.h>
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Throttle representation in DShot protocol
*/
typedef struct
{
uint16_t throttle; /*!< Throttle value */
bool telemetry_req; /*!< Telemetry request */
} dshot_rmt_throttle_t;
/**
* @brief Type of Dshot ESC encoder configuration
*/
typedef struct
{
uint32_t resolution; /*!< Encoder resolution, in Hz */
uint32_t baud_rate; /*!< Dshot protocol runs at several different baud rates, e.g. DSHOT300 = 300k baud rate */
bool bidirectional; /*!< Dshot bidirectional mode */
uint32_t post_delay_us; /*!< Delay time after one Dshot frame, in microseconds */
} dshot_rmt_encoder_config_t;
/**
* @brief Create RMT encoder for encoding Dshot ESC frame into RMT symbols
*
* @param[in] config Encoder configuration
* @param[out] ret_encoder Returned encoder handle
* @return
* - ESP_ERR_INVALID_ARG for any invalid arguments
* - ESP_ERR_NO_MEM out of memory when creating Dshot ESC encoder
* - ESP_OK if creating encoder successfully
*/
esp_err_t rmt_new_dshot_esc_encoder(const dshot_rmt_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder);
#ifdef __cplusplus
}
#endif