36 lines
755 B
C
36 lines
755 B
C
#pragma once
|
|
|
|
#include <inttypes.h>
|
|
#include <stdbool.h>
|
|
|
|
#if CONFIG_IDF_TARGET_ESP32H2
|
|
#define DSHOT_ESC_RESOLUTION_HZ 32000000 // 32MHz resolution, DSHot protocol needs a relative high resolution
|
|
#else
|
|
#define DSHOT_ESC_RESOLUTION_HZ 40000000 // 40MHz resolution, DSHot protocol needs a relative high resolution
|
|
#endif
|
|
|
|
#define ESC_UART_NUM UART_NUM_2
|
|
|
|
/**
|
|
* Struct for returning telemetry data
|
|
*/
|
|
typedef struct {
|
|
uint16_t temperature;
|
|
uint16_t voltage;
|
|
uint16_t current;
|
|
uint16_t consumption;
|
|
uint16_t rpm;
|
|
} esc_telemetry_t;
|
|
|
|
void init_rmt_esc_tx(void);
|
|
|
|
void send_dshot_packet(void);
|
|
|
|
bool parse_telemetry(esc_telemetry_t * telemetry);
|
|
|
|
void init_motor(void);
|
|
|
|
uint16_t get_throttle(void);
|
|
|
|
void update_throttle(uint16_t throttle);
|