dshot_esc_encoder.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. #include "driver/rmt_encoder.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief Throttle representation in DShot protocol
  15. */
  16. typedef struct {
  17. uint16_t throttle; /*!< Throttle value */
  18. bool telemetry_req; /*!< Telemetry request */
  19. } dshot_esc_throttle_t;
  20. /**
  21. * @brief Type of Dshot ESC encoder configuration
  22. */
  23. typedef struct {
  24. uint32_t resolution; /*!< Encoder resolution, in Hz */
  25. uint32_t baud_rate; /*!< Dshot protocol runs at several different baud rates, e.g. DSHOT300 = 300k baud rate */
  26. uint32_t post_delay_us; /*!< Delay time after one Dshot frame, in microseconds */
  27. } dshot_esc_encoder_config_t;
  28. /**
  29. * @brief Create RMT encoder for encoding Dshot ESC frame into RMT symbols
  30. *
  31. * @param[in] config Encoder configuration
  32. * @param[out] ret_encoder Returned encoder handle
  33. * @return
  34. * - ESP_ERR_INVALID_ARG for any invalid arguments
  35. * - ESP_ERR_NO_MEM out of memory when creating Dshot ESC encoder
  36. * - ESP_OK if creating encoder successfully
  37. */
  38. esp_err_t rmt_new_dshot_esc_encoder(const dshot_esc_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder);
  39. #ifdef __cplusplus
  40. }
  41. #endif