APM:Libraries
RCOutput_AeroIO.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Intel Corporation. All rights reserved.
3  *
4  * This file is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This file is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #include "AP_HAL_Linux.h"
21 
22 namespace Linux {
23 
25 public:
28 
29  void init() override;
30 
34  void enable_ch(uint8_t ch) override;
35 
39  void disable_ch(uint8_t ch) override;
40 
47  void set_freq(uint32_t chmask, uint16_t freq_hz) override;
48 
56  uint16_t get_freq(uint8_t ch) override;
57 
64  void write(uint8_t ch, uint16_t period_us) override;
65 
66  void cork() override;
67 
68  void push() override;
69 
73  uint16_t read(uint8_t ch) override;
74 
82  void read(uint16_t *period_us, uint8_t len) override;
83 
84 private:
94  static uint16_t _usec_to_hw(uint16_t freq, uint16_t usec);
95 
103  static uint16_t _hw_to_usec(uint16_t freq, uint16_t hw_val);
104 
113  bool _hw_write(uint16_t address, uint16_t data);
114 
122  uint16_t _hw_read(uint16_t address);
123 
125 
129  uint16_t *_freq_buffer;
130 
134  uint16_t *_duty_buffer;
135 
147 
152  bool _corking = false;
153 };
154 
155 }
void enable_ch(uint8_t ch) override
AP_HAL::OwnPtr< AP_HAL::Device > _spi
uint16_t read(uint8_t ch) override
static uint16_t _hw_to_usec(uint16_t freq, uint16_t hw_val)
bool _hw_write(uint16_t address, uint16_t data)
void write(uint8_t ch, uint16_t period_us) override
void set_freq(uint32_t chmask, uint16_t freq_hz) override
uint16_t _hw_read(uint16_t address)
uint16_t get_freq(uint8_t ch) override
void disable_ch(uint8_t ch) override
static uint16_t _usec_to_hw(uint16_t freq, uint16_t usec)