APM:Libraries
RPM_Pin.h
Go to the documentation of this file.
1 /*
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License as published by
4  the Free Software Foundation, either version 3 of the License, or
5  (at your option) any later version.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 #pragma once
16 
17 #include "AP_RPM.h"
18 
19 #include "RPM_Backend.h"
20 #include <Filter/Filter.h>
21 #include <AP_Math/AP_Math.h>
22 
23 class AP_RPM_Pin : public AP_RPM_Backend
24 {
25 public:
26  // constructor
27  AP_RPM_Pin(AP_RPM &ranger, uint8_t instance, AP_RPM::RPM_State &_state);
28 
29  // update state
30  void update(void);
31 
32 private:
33  static void irq_handler(uint8_t instance);
34 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
35  static int irq_handler0(int irq, void *context);
36  static int irq_handler1(int irq, void *context);
37 #else
38  static void irq_handler0(void);
39  static void irq_handler1(void);
40 #endif
41 
43  uint8_t last_pin = -1;
44  uint32_t last_gpio;
45  struct IrqState {
46  uint32_t last_pulse_us;
47  uint32_t dt_sum;
48  uint32_t dt_count;
49  };
51 };
ModeFilterFloat_Size5 signal_quality_filter
Definition: RPM_Pin.h:42
AP_RPM_Pin(AP_RPM &ranger, uint8_t instance, AP_RPM::RPM_State &_state)
Definition: RPM_Pin.cpp:32
uint32_t dt_count
Definition: RPM_Pin.h:48
uint32_t last_gpio
Definition: RPM_Pin.h:44
static int irq_handler1(int irq, void *context)
Definition: RPM_Pin.cpp:67
static int irq_handler0(int irq, void *context)
Definition: RPM_Pin.cpp:58
#define RPM_MAX_INSTANCES
Definition: AP_RPM.h:23
Definition: AP_RPM.h:27
static struct IrqState irq_state[RPM_MAX_INSTANCES]
Definition: RPM_Pin.h:50
static void irq_handler(uint8_t instance)
Definition: RPM_Pin.cpp:40
uint8_t last_pin
Definition: RPM_Pin.h:43
uint32_t last_pulse_us
Definition: RPM_Pin.h:46
void update(void)
Definition: RPM_Pin.cpp:90
uint32_t dt_sum
Definition: RPM_Pin.h:47