2016-02-17 21:25:26 -04:00
|
|
|
#pragma once
|
2014-08-19 00:37:10 -03:00
|
|
|
|
|
|
|
/*
|
|
|
|
This class implements RCInput on the BeagleBoneBlack with a PRU
|
|
|
|
doing the edge detection of the PPM sum input
|
|
|
|
*/
|
|
|
|
|
2016-07-29 16:14:02 -03:00
|
|
|
#include "RCInput.h"
|
2014-08-19 00:37:10 -03:00
|
|
|
|
2014-10-07 00:05:21 -03:00
|
|
|
// we use 300 ring buffer entries to guarantee that a full 25 byte
|
|
|
|
// frame of 12 bits per byte
|
2014-08-19 00:37:10 -03:00
|
|
|
|
2016-07-29 16:14:02 -03:00
|
|
|
namespace Linux {
|
|
|
|
|
|
|
|
class RCInput_PRU : public RCInput {
|
2014-08-19 00:37:10 -03:00
|
|
|
public:
|
2019-02-21 19:08:12 -04:00
|
|
|
void init() override;
|
|
|
|
void _timer_tick(void) override;
|
2014-08-19 00:37:10 -03:00
|
|
|
|
|
|
|
private:
|
2014-10-29 23:23:03 -03:00
|
|
|
static const unsigned int NUM_RING_ENTRIES=300;
|
2014-08-19 00:37:10 -03:00
|
|
|
// shared ring buffer with the PRU which records pin transitions
|
|
|
|
struct ring_buffer {
|
|
|
|
volatile uint16_t ring_head; // owned by ARM CPU
|
|
|
|
volatile uint16_t ring_tail; // owned by the PRU
|
|
|
|
struct {
|
|
|
|
uint16_t pin_value;
|
|
|
|
uint16_t delta_t;
|
|
|
|
} buffer[NUM_RING_ENTRIES];
|
|
|
|
};
|
|
|
|
volatile struct ring_buffer *ring_buffer;
|
|
|
|
|
|
|
|
// time spent in the low state
|
|
|
|
uint16_t _s0_time;
|
|
|
|
};
|
2016-07-29 16:14:02 -03:00
|
|
|
|
|
|
|
}
|