RCInput_PRU.h 892 B

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