Aruna
ESP32_RMT_Dshot.h
Go to the documentation of this file.
1 //
2 // Created by noeel on 08-11-20.
3 //
4 
5 #ifndef ARUNA_ESP32_RMT_DSHOT_H
6 #define ARUNA_ESP32_RMT_DSHOT_H
7 #define RMT_CHANNEL_FLAGS_ALWAYS_ON 1
8 
9 #include "aruna/driver/Dshot.h"
10 #include <driver/rmt.h>
11 
12 
13 namespace aruna {
14  namespace driver {
15  class ESP32_RMT_Dshot: public Dshot{
16  private:
17  // tick tock
18  uint16_t T0H_ticks: 15;
19  uint16_t T1H_ticks: 15;
20  uint16_t T0L_ticks: 15;
21  uint16_t T1L_ticks: 15;
22 
23 // threading
24  pthread_mutex_t dshot_frame_lock;
25  pthread_t update_handler;
26 
27  rmt_config_t driver_config;
28  uint16_t dshot_frame = 0;
29 
35  void bits_to_dshotFrame(uint16_t bits, rmt_item32_t *frame_buffer);
36 
40  void update_task();
41 
47  static void *_update_task(void *_this);
48 
49  err_t _write_frame_continuous(uint16_t dshot_frame) override;
50 
51 
57  err_t single_write(uint16_t dshot_frame);
58 
59  public:
65  ESP32_RMT_Dshot(rmt_channel_t channel, gpio_num_t gpio_port);
66 
68 
69 
70  };
71 
72  }
73 }
74 
75 #endif //ARUNA_ESP32_RMT_DSHOT_H
static void * _update_task(void *_this)
static function to help pthead
Definition: comm.cpp:14
err_t single_write(uint16_t dshot_frame)
Write a single Dshot frame to the bus.
void update_task()
updates ESC with current dshot buffer, blocks CPU
void bits_to_dshotFrame(uint16_t bits, rmt_item32_t *frame_buffer)
convert bits to rmt frame
Link * driver
stores the driver.
Definition: comm.cpp:45
ESP32_RMT_Dshot(rmt_channel_t channel, gpio_num_t gpio_port)
Dshot150 using RMT hardware.
err_t _write_frame_continuous(uint16_t dshot_frame) override
Write set Dshot frame continuously on the bus.