mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-04 15:08:28 -04:00
5dd0086698
this reduces interrupt latency on the F100, which allows us to use all RC input protocols on the pulse based decoder, allowing for more flexibility in RC input protocols
58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
/*
|
|
* This file is free software: you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This file is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* Code by Andrew Tridgell and Siddharth Bharat Purohit
|
|
*/
|
|
#pragma once
|
|
#include <AP_HAL/utility/RingBuffer.h>
|
|
#include <AP_HAL/AP_HAL_Boards.h>
|
|
|
|
#include "AP_HAL_ChibiOS.h"
|
|
|
|
#if HAL_USE_ICU == TRUE
|
|
|
|
#define INPUT_CAPTURE_FREQUENCY 1000000 //capture unit in microseconds
|
|
|
|
#ifndef SOFTSIG_MAX_SIGNAL_TRANSITIONS
|
|
#define SOFTSIG_MAX_SIGNAL_TRANSITIONS 256
|
|
#endif
|
|
|
|
// we use a small bounce buffer size to minimise time in the DMA
|
|
// callback IRQ
|
|
#define SOFTSIG_BOUNCE_BUF_SIZE 8
|
|
|
|
class ChibiOS::SoftSigReader {
|
|
friend class ChibiOS::RCInput;
|
|
public:
|
|
bool attach_capture_timer(ICUDriver* icu_drv, icuchannel_t chan, uint8_t dma_stream, uint32_t dma_channel);
|
|
bool read(uint32_t &widths0, uint32_t &widths1);
|
|
|
|
private:
|
|
uint32_t *signal;
|
|
uint32_t *signal2;
|
|
static void _irq_handler(void* self, uint32_t flags);
|
|
uint8_t num_timer_channels;
|
|
uint8_t enable_chan_mask;
|
|
uint8_t max_pulse_width;
|
|
const stm32_dma_stream_t* dma;
|
|
uint32_t dmamode;
|
|
ICUConfig icucfg;
|
|
ICUDriver* _icu_drv = nullptr;
|
|
ObjectBuffer<uint32_t> sigbuf{SOFTSIG_MAX_SIGNAL_TRANSITIONS};
|
|
bool need_swap;
|
|
};
|
|
|
|
#endif // HAL_USE_ICU
|
|
|