APM:Libraries
SoftSigReader.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 #pragma once
19 #include <AP_HAL/AP_HAL_Boards.h>
20 
21 #include "AP_HAL_ChibiOS.h"
22 
23 #if HAL_USE_ICU == TRUE
24 
25 #define INPUT_CAPTURE_FREQUENCY 1000000 //capture unit in microseconds
26 #define MAX_SIGNAL_TRANSITIONS 256
27 #define DEFAULT_BOUNCE_BUF_SIZE 32
28 
30 public:
31  bool attach_capture_timer(ICUDriver* icu_drv, icuchannel_t chan, uint8_t dma_stream, uint32_t dma_channel);
32  bool read(uint32_t &widths0, uint32_t &widths1);
33  //This sets the size of bounce buffer size, which in turn controls the rate of interrupt from DMA
34  bool set_bounce_buf_size(uint16_t buf_size);
35 private:
36  uint32_t *signal;
37  static void _irq_handler(void* self, uint32_t flags);
41  uint8_t max_pulse_width;
42  const stm32_dma_stream_t* dma;
43  ICUConfig icucfg;
44  ICUDriver* _icu_drv = nullptr;
46  bool need_swap;
47 };
48 
49 #endif // HAL_USE_ICU
50 
bool attach_capture_timer(ICUDriver *icu_drv, icuchannel_t chan, uint8_t dma_stream, uint32_t dma_channel)
ObjectBuffer< uint32_t > sigbuf
Definition: SoftSigReader.h:39
dma_channel
DMA channels.
Definition: dma.h:68
bool read(uint32_t &widths0, uint32_t &widths1)
enum Dma_stream dma_stream
#define DEFAULT_BOUNCE_BUF_SIZE
Definition: SoftSigReader.h:27
AP_HAL::AnalogSource * chan
Definition: AnalogIn.cpp:8
static void _irq_handler(void *self, uint32_t flags)
bool set_bounce_buf_size(uint16_t buf_size)
const stm32_dma_stream_t * dma
Definition: SoftSigReader.h:42
#define MAX_SIGNAL_TRANSITIONS
Definition: SoftSigReader.h:26