CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/AP_Periph/hwing_esc.h
Views: 1798
1
/*
2
ESC Telemetry for Hobbywing Pro 80A HV ESC. This will be
3
incorporated into a broader ESC telemetry library in ArduPilot
4
master in the future
5
*/
6
7
#pragma once
8
9
#include <AP_HAL/AP_HAL.h>
10
11
#ifdef HAL_PERIPH_ENABLE_HWESC
12
13
class HWESC_Telem {
14
public:
15
HWESC_Telem();
16
17
void init(AP_HAL::UARTDriver *uart);
18
bool update();
19
20
struct HWESC {
21
uint32_t counter;
22
uint16_t throttle_req;
23
uint16_t throttle;
24
float rpm;
25
float voltage;
26
float phase_current;
27
float current;
28
uint8_t mos_temperature;
29
uint8_t cap_temperature;
30
uint16_t status;
31
uint32_t error_count;
32
};
33
34
const HWESC &get_telem(void) {
35
return decoded;
36
}
37
38
private:
39
AP_HAL::UARTDriver *uart;
40
41
struct PACKED {
42
uint8_t header; // 0x9B
43
uint8_t pkt_len; // 0x16
44
uint32_t counter;
45
uint16_t throttle_req;
46
uint16_t throttle;
47
uint16_t rpm;
48
uint16_t voltage;
49
int16_t current;
50
int16_t phase_current;
51
uint8_t mos_temperature;
52
uint8_t cap_temperature;
53
uint16_t status;
54
uint16_t crc;
55
} pkt;
56
57
uint8_t len;
58
uint32_t last_read_ms;
59
uint32_t error_count;
60
61
struct HWESC decoded;
62
63
bool parse_packet(void);
64
uint8_t temperature_decode(uint8_t temp_raw) const;
65
};
66
67
#endif // HAL_PERIPH_ENABLE_HWESC
68
69