libpropeller
Making PropellerGCC Easier
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
pulse_width_reader.h
Go to the documentation of this file.
1 #ifndef libpropeller_readpulsewidths_h__
2 #define libpropeller_readpulsewidths_h__
3 #include <propeller.h>
4 
6 
46 public:
47 
49  Cog = 0;
50  }
51 
56  void Start(unsigned int Inputmask) {
57  volatile void * asm_reference = NULL;
58  __asm__ volatile ("mov %[asm_reference], #PulseWidthReader_Entry \n\t"
59  : [asm_reference] "+r" (asm_reference));
60  Stop();
61 
62  pinTimes[0] = Inputmask;
63  Cog = cognew(_load_start_pulsewidthreader_cog, pinTimes) + 1;
64  }
65 
68  void Stop(void) {
69  if (Cog != 0) {
70  cogstop(Cog - 1);
71  Cog = 0;
72  }
73  }
74 
81  int getHighTime(int index){
82  return pinTimes[index * 2];
83  }
84 
91  int getLowTime(int index){
92  return pinTimes[index * 2 + 1];
93  }
94 
95 private:
96  int Cog;
97  volatile int pinTimes[64];
98 
99 
100 };
101 
102 #endif // libpropeller_readpulsewidths_h__