1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #pragma once
- #include <AP_HAL/utility/RingBuffer.h>
- #include <AP_HAL/AP_HAL_Boards.h>
- #include "AP_HAL_ChibiOS.h"
- #if HAL_USE_EICU == TRUE
- #define INPUT_CAPTURE_FREQUENCY 1000000
- #ifndef SOFTSIG_MAX_SIGNAL_TRANSITIONS
- #define SOFTSIG_MAX_SIGNAL_TRANSITIONS 128
- #endif
- class ChibiOS::SoftSigReaderInt {
- public:
- SoftSigReaderInt();
-
- SoftSigReaderInt(const SoftSigReaderInt &other) = delete;
- SoftSigReaderInt &operator=(const SoftSigReaderInt&) = delete;
-
- static SoftSigReaderInt *get_singleton(void)
- {
- return _singleton;
- }
- void init(EICUDriver* icu_drv, eicuchannel_t chan);
- bool read(uint32_t &widths0, uint32_t &widths1);
- private:
-
- static SoftSigReaderInt *_singleton;
- static void _irq_handler(EICUDriver *eicup, eicuchannel_t channel);
-
- static eicuchannel_t get_pair_channel(eicuchannel_t channel);
- typedef struct PACKED {
- uint16_t w0;
- uint16_t w1;
- } pulse_t;
- ObjectBuffer<pulse_t> sigbuf{SOFTSIG_MAX_SIGNAL_TRANSITIONS};
- EICUConfig icucfg;
- EICUChannelConfig channel_config;
- EICUChannelConfig aux_channel_config;
- EICUDriver* _icu_drv = nullptr;
- uint16_t last_value;
- };
- #endif
|