APM:Libraries
RCInput_PRU.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4  This class implements RCInput on the BeagleBoneBlack with a PRU
5  doing the edge detection of the PPM sum input
6  */
7 
8 #include "RCInput.h"
9 
10 // we use 300 ring buffer entries to guarantee that a full 25 byte
11 // frame of 12 bits per byte
12 
13 namespace Linux {
14 
15 class RCInput_PRU : public RCInput {
16 public:
17  void init();
18  void _timer_tick(void);
19 
20  private:
21  static const unsigned int NUM_RING_ENTRIES=300;
22  // shared ring buffer with the PRU which records pin transitions
23  struct ring_buffer {
24  volatile uint16_t ring_head; // owned by ARM CPU
25  volatile uint16_t ring_tail; // owned by the PRU
26  struct {
27  uint16_t pin_value;
28  uint16_t delta_t;
30  };
31  volatile struct ring_buffer *ring_buffer;
32 
33  // time spent in the low state
34  uint16_t _s0_time;
35 };
36 
37 }
static const unsigned int NUM_RING_ENTRIES
Definition: RCInput_PRU.h:21
void _timer_tick(void)
Definition: RCInput_PRU.cpp:47
volatile uint16_t ring_head
Definition: RCInput_PRU.h:24
volatile uint16_t ring_tail
Definition: RCInput_PRU.h:25
volatile struct ring_buffer * ring_buffer
Definition: RCInput_PRU.h:31