A fork of AR8000

Dependents:   Sumo_v2 Sumo_v2_Unstable Sumo_v2_RG13

Committer:
BlazeX
Date:
Fri Mar 23 14:45:07 2012 +0000
Revision:
0:b08668430838
Child:
1:a5bfae540999

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BlazeX 0:b08668430838 1 //TODO:
BlazeX 0:b08668430838 2 //- Ein Timer reicht. Mit read_us() kann zu jeder Zeit die Zeit festgestellt werden
BlazeX 0:b08668430838 3
BlazeX 0:b08668430838 4 #pragma once
BlazeX 0:b08668430838 5
BlazeX 0:b08668430838 6 //Interrupt-Callback Vorlage
BlazeX 0:b08668430838 7 #define AR8000_RISE_FALL(Ch)\
BlazeX 0:b08668430838 8 void Rise##Ch()\
BlazeX 0:b08668430838 9 {\
BlazeX 0:b08668430838 10 LastRise[Ch]= Time.read_us();\
BlazeX 0:b08668430838 11 }\
BlazeX 0:b08668430838 12 void Fall##Ch()\
BlazeX 0:b08668430838 13 {\
BlazeX 0:b08668430838 14 int dT= Time.read_us() - LastRise[Ch];\
BlazeX 0:b08668430838 15 if(dT > 900 && dT < 2200)\
BlazeX 0:b08668430838 16 dTime[Ch]= dT;\
BlazeX 0:b08668430838 17 }
BlazeX 0:b08668430838 18
BlazeX 0:b08668430838 19
BlazeX 0:b08668430838 20 class AR8000
BlazeX 0:b08668430838 21 {
BlazeX 0:b08668430838 22 private:
BlazeX 0:b08668430838 23 InterruptIn & ChInt0; //Interrupt-Handler fuer jeden Pin
BlazeX 0:b08668430838 24 InterruptIn & ChInt1;
BlazeX 0:b08668430838 25 InterruptIn & ChInt2;
BlazeX 0:b08668430838 26 InterruptIn & ChInt3;
BlazeX 0:b08668430838 27 InterruptIn & ChInt4;
BlazeX 0:b08668430838 28 InterruptIn & ChInt5;
BlazeX 0:b08668430838 29 InterruptIn & ChInt6;
BlazeX 0:b08668430838 30 InterruptIn & ChInt7;
BlazeX 0:b08668430838 31
BlazeX 0:b08668430838 32 Timer Time; //Timer for all 8 Channels
BlazeX 0:b08668430838 33 volatile int LastRise[8]; //Zeitpunkt der letzten steigende Flanke
BlazeX 0:b08668430838 34 volatile int dTime[8]; //Pulsdauer in us [1000...2000]
BlazeX 0:b08668430838 35
BlazeX 0:b08668430838 36 public:
BlazeX 0:b08668430838 37 //Das Ergebnis [0...1000], kann nach dem Update "gelesen werden"
BlazeX 0:b08668430838 38 int Pos[8];
BlazeX 0:b08668430838 39
BlazeX 0:b08668430838 40 //Initialisieren
BlazeX 0:b08668430838 41 AR8000(InterruptIn & ChInt0_,
BlazeX 0:b08668430838 42 InterruptIn & ChInt1_,
BlazeX 0:b08668430838 43 InterruptIn & ChInt2_,
BlazeX 0:b08668430838 44 InterruptIn & ChInt3_,
BlazeX 0:b08668430838 45 InterruptIn & ChInt4_,
BlazeX 0:b08668430838 46 InterruptIn & ChInt5_,
BlazeX 0:b08668430838 47 InterruptIn & ChInt6_,
BlazeX 0:b08668430838 48 InterruptIn & ChInt7_);
BlazeX 0:b08668430838 49 void Init();
BlazeX 0:b08668430838 50
BlazeX 0:b08668430838 51 //Interrupt-Callbacks definieren
BlazeX 0:b08668430838 52 AR8000_RISE_FALL(0);
BlazeX 0:b08668430838 53 AR8000_RISE_FALL(1);
BlazeX 0:b08668430838 54 AR8000_RISE_FALL(2);
BlazeX 0:b08668430838 55 AR8000_RISE_FALL(3);
BlazeX 0:b08668430838 56 AR8000_RISE_FALL(4);
BlazeX 0:b08668430838 57 AR8000_RISE_FALL(5);
BlazeX 0:b08668430838 58 AR8000_RISE_FALL(6);
BlazeX 0:b08668430838 59 AR8000_RISE_FALL(7);
BlazeX 0:b08668430838 60
BlazeX 0:b08668430838 61 //Update-Methode
BlazeX 0:b08668430838 62 void Update();
BlazeX 0:b08668430838 63 };