experiments
This commit is contained in:
parent
de2358e3c8
commit
d7e8386129
|
|
@ -17,7 +17,7 @@ The checksum is calculated over the throttle value and the telemetry bit, so the
|
|||
crc = (value ^ (value >> 4) ^ (value >> 8)) & 0x0F;
|
||||
|
||||
### Bidirectional DSHOT
|
||||
Bidirictional DSHOT is also known as inverted DSHOT, because the signal level is inverted, so 1 is low and a 0 is high. This is done in order to let the ESC know, that we are operating in bidirectional mode and that it should be sending back eRPM telemetry packages.
|
||||
Bidirectional DSHOT is also known as inverted DSHOT, because the signal level is inverted, so 1 is low and a 0 is high. This is done in order to let the ESC know, that we are operating in bidirectional mode and that it should be sending back eRPM telemetry packages.
|
||||
|
||||
#### Calculating the Bidirectional CRC
|
||||
The calculation of the checksum is basically the same, just before the last step the values are inverted:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ DShotRMT::DShotRMT(gpio_num_t gpio, rmt_channel_t rmtChannel)
|
|||
dshot_config.rmt_channel = rmtChannel;
|
||||
dshot_config.mem_block_num = uint8_t(RMT_CHANNEL_MAX - uint8_t(rmtChannel));
|
||||
|
||||
// ...create clean packet
|
||||
// ...create empty packet
|
||||
encode_dshot_to_rmt(DSHOT_NULL_PACKET);
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ DShotRMT::DShotRMT(uint8_t pin, uint8_t channel)
|
|||
dshot_config.rmt_channel = rmt_channel_t(channel);
|
||||
dshot_config.mem_block_num = (RMT_CHANNEL_MAX - channel);
|
||||
|
||||
// ...create clean packet
|
||||
// ...create empty packet
|
||||
encode_dshot_to_rmt(DSHOT_NULL_PACKET);
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ DShotRMT::~DShotRMT()
|
|||
rmt_driver_uninstall(dshot_config.rmt_channel);
|
||||
}
|
||||
|
||||
DShotRMT::DShotRMT(DShotRMT const&)
|
||||
DShotRMT::DShotRMT(DShotRMT const &)
|
||||
{
|
||||
// ...write me
|
||||
}
|
||||
|
|
@ -133,18 +133,18 @@ void DShotRMT::send_dshot_value(uint16_t throttle_value, telemetric_request_t te
|
|||
}
|
||||
|
||||
// ...get all setup data about current mode
|
||||
dshot_config_t* DShotRMT::get_dshot_info()
|
||||
dshot_config_t *DShotRMT::get_dshot_info()
|
||||
{
|
||||
return &dshot_config;
|
||||
}
|
||||
|
||||
// ...get the ABP_Clock Divider for further calculations
|
||||
uint8_t* DShotRMT::get_dshot_clock_div()
|
||||
uint8_t *DShotRMT::get_dshot_clock_div()
|
||||
{
|
||||
return &dshot_config.clk_div;
|
||||
}
|
||||
|
||||
rmt_item32_t* DShotRMT::encode_dshot_to_rmt(uint16_t parsed_packet)
|
||||
rmt_item32_t *DShotRMT::encode_dshot_to_rmt(uint16_t parsed_packet)
|
||||
{
|
||||
// ...is bidirecional mode activated
|
||||
if (dshot_config.bidirectional)
|
||||
|
|
@ -212,7 +212,7 @@ rmt_item32_t* DShotRMT::encode_dshot_to_rmt(uint16_t parsed_packet)
|
|||
|
||||
// ...just returns the checksum
|
||||
// DOES NOT APPEND CHECKSUM!!!
|
||||
uint16_t DShotRMT::calc_dshot_chksum(const dshot_packet_t& dshot_packet)
|
||||
uint16_t DShotRMT::calc_dshot_chksum(const dshot_packet_t &dshot_packet)
|
||||
{
|
||||
// ...start with two emprty "container"
|
||||
uint16_t packet = DSHOT_NULL_PACKET;
|
||||
|
|
@ -235,7 +235,7 @@ uint16_t DShotRMT::calc_dshot_chksum(const dshot_packet_t& dshot_packet)
|
|||
return chksum;
|
||||
}
|
||||
|
||||
uint16_t DShotRMT::prepare_rmt_data(const dshot_packet_t& dshot_packet)
|
||||
uint16_t DShotRMT::prepare_rmt_data(const dshot_packet_t &dshot_packet)
|
||||
{
|
||||
uint16_t prepared_to_encode = DSHOT_NULL_PACKET;
|
||||
uint16_t chksum = calc_dshot_chksum(dshot_packet);
|
||||
|
|
@ -248,7 +248,7 @@ uint16_t DShotRMT::prepare_rmt_data(const dshot_packet_t& dshot_packet)
|
|||
}
|
||||
|
||||
// ...finally output using ESP32 RMT
|
||||
void DShotRMT::output_rmt_data(const dshot_packet_t& dshot_packet)
|
||||
void DShotRMT::output_rmt_data(const dshot_packet_t &dshot_packet)
|
||||
{
|
||||
encode_dshot_to_rmt(prepare_rmt_data(dshot_packet));
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
// Author: derdoktor667
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _DSHOTRMT_h
|
||||
#define _DSHOTRMT_h
|
||||
|
||||
|
|
@ -45,12 +43,12 @@ typedef enum dshot_mode_e
|
|||
} dshot_mode_t;
|
||||
|
||||
// ...to get human readable DShot Mode
|
||||
static const char* const dshot_mode_name[] = {
|
||||
static const char *const dshot_mode_name[] = {
|
||||
"DSHOT_OFF",
|
||||
"DSHOT150",
|
||||
"DSHOT300",
|
||||
"DSHOT600",
|
||||
"DSHOT1200" };
|
||||
"DSHOT1200"};
|
||||
|
||||
typedef String dshot_name_t;
|
||||
|
||||
|
|
@ -95,29 +93,29 @@ typedef struct dshot_config_s
|
|||
|
||||
class DShotRMT
|
||||
{
|
||||
public:
|
||||
public:
|
||||
DShotRMT(gpio_num_t gpio, rmt_channel_t rmtChannel);
|
||||
DShotRMT(uint8_t pin, uint8_t channel);
|
||||
~DShotRMT();
|
||||
DShotRMT(DShotRMT const&);
|
||||
DShotRMT(DShotRMT const &);
|
||||
|
||||
// ...safety first ...no parameters, no DShot
|
||||
bool begin(dshot_mode_t dshot_mode = DSHOT_OFF, bool is_bidirectional = false);
|
||||
void send_dshot_value(uint16_t throttle_value, telemetric_request_t telemetric_request = NO_TELEMETRIC);
|
||||
|
||||
dshot_config_t* get_dshot_info();
|
||||
uint8_t* get_dshot_clock_div();
|
||||
dshot_config_t *get_dshot_info();
|
||||
uint8_t *get_dshot_clock_div();
|
||||
|
||||
private:
|
||||
private:
|
||||
rmt_item32_t dshot_tx_rmt_item[DSHOT_PACKET_LENGTH];
|
||||
rmt_config_t dshot_tx_rmt_config;
|
||||
dshot_config_t dshot_config;
|
||||
|
||||
rmt_item32_t* encode_dshot_to_rmt(uint16_t parsed_packet);
|
||||
uint16_t calc_dshot_chksum(const dshot_packet_t& dshot_packet);
|
||||
uint16_t prepare_rmt_data(const dshot_packet_t& dshot_packet);
|
||||
rmt_item32_t *encode_dshot_to_rmt(uint16_t parsed_packet);
|
||||
uint16_t calc_dshot_chksum(const dshot_packet_t &dshot_packet);
|
||||
uint16_t prepare_rmt_data(const dshot_packet_t &dshot_packet);
|
||||
|
||||
void output_rmt_data(const dshot_packet_t& dshot_packet);
|
||||
void output_rmt_data(const dshot_packet_t &dshot_packet);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue