APM:Libraries
AP_RCProtocol_DSM.h
Go to the documentation of this file.
1 /*
2  * This file is free software: you can redistribute it and/or modify it
3  * under the terms of the GNU General Public License as published by the
4  * Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This file is distributed in the hope that it will be useful, but
8  * WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License along
13  * with this program. If not, see <http://www.gnu.org/licenses/>.
14  *
15  * Code by Andrew Tridgell and Siddharth Bharat Purohit
16  */
17 
18 #pragma once
19 
20 #include "AP_RCProtocol.h"
21 
23 public:
25  void process_pulse(uint32_t width_s0, uint32_t width_s1) override;
26  void start_bind(void) override;
27  void update(void) override;
28 
29 private:
30  void dsm_decode();
31  bool dsm_decode_channel(uint16_t raw, unsigned shift, unsigned *channel, unsigned *value);
32  void dsm_guess_format(bool reset, const uint8_t dsm_frame[16]);
33  bool dsm_decode(uint64_t frame_time, const uint8_t dsm_frame[16],
34  uint16_t *values, uint16_t *num_values, uint16_t max_values);
35 
37  unsigned dsm_channel_shift;
38  // state of DSM decoder
39  struct {
40  uint16_t bytes[16]; // including start bit and stop bit
41  uint16_t bit_ofs;
42  } dsm_state;
43 
44  // bind state machine
45  enum {
51  } bind_state;
52  uint32_t bind_last_ms;
53 
54 };
uint64_t dsm_last_frame_time
void process_pulse(uint32_t width_s0, uint32_t width_s1) override
void reset()
void dsm_guess_format(bool reset, const uint8_t dsm_frame[16])
void update(void) override
void start_bind(void) override
bool dsm_decode_channel(uint16_t raw, unsigned shift, unsigned *channel, unsigned *value)
float value
AP_RCProtocol_DSM(AP_RCProtocol &_frontend)
enum AP_RCProtocol_DSM::@179 bind_state
struct AP_RCProtocol_DSM::@178 dsm_state