A fork of AR8000
Dependents: Sumo_v2 Sumo_v2_Unstable Sumo_v2_RG13
AR8000.h@7:0b27bef14b0e, 2012-04-16 (annotated)
- Committer:
- BlazeX
- Date:
- Mon Apr 16 17:02:47 2012 +0000
- Revision:
- 7:0b27bef14b0e
- Parent:
- 6:ce4f088d8111
- Child:
- 9:c57888a66a5f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
BlazeX | 0:b08668430838 | 1 | #pragma once |
BlazeX | 0:b08668430838 | 2 | |
BlazeX | 0:b08668430838 | 3 | //Interrupt-Callback Vorlage |
BlazeX | 0:b08668430838 | 4 | #define AR8000_RISE_FALL(Ch)\ |
BlazeX | 0:b08668430838 | 5 | void Rise##Ch()\ |
BlazeX | 0:b08668430838 | 6 | {\ |
BlazeX | 0:b08668430838 | 7 | LastRise[Ch]= Time.read_us();\ |
BlazeX | 0:b08668430838 | 8 | }\ |
BlazeX | 0:b08668430838 | 9 | void Fall##Ch()\ |
BlazeX | 0:b08668430838 | 10 | {\ |
BlazeX | 0:b08668430838 | 11 | int dT= Time.read_us() - LastRise[Ch];\ |
BlazeX | 6:ce4f088d8111 | 12 | if(dT > 900 && dT < 2100)\ |
BlazeX | 0:b08668430838 | 13 | dTime[Ch]= dT;\ |
BlazeX | 0:b08668430838 | 14 | } |
BlazeX | 0:b08668430838 | 15 | |
BlazeX | 0:b08668430838 | 16 | |
BlazeX | 0:b08668430838 | 17 | class AR8000 |
BlazeX | 0:b08668430838 | 18 | { |
BlazeX | 0:b08668430838 | 19 | private: |
BlazeX | 1:a5bfae540999 | 20 | InterruptIn ChInt0; //Interrupt-Handler fuer jeden Pin |
BlazeX | 1:a5bfae540999 | 21 | InterruptIn ChInt1; |
BlazeX | 1:a5bfae540999 | 22 | InterruptIn ChInt2; |
BlazeX | 1:a5bfae540999 | 23 | InterruptIn ChInt3; |
BlazeX | 1:a5bfae540999 | 24 | InterruptIn ChInt4; |
BlazeX | 1:a5bfae540999 | 25 | InterruptIn ChInt5; |
BlazeX | 1:a5bfae540999 | 26 | InterruptIn ChInt6; |
BlazeX | 1:a5bfae540999 | 27 | InterruptIn ChInt7; |
BlazeX | 0:b08668430838 | 28 | |
BlazeX | 0:b08668430838 | 29 | Timer Time; //Timer for all 8 Channels |
BlazeX | 0:b08668430838 | 30 | volatile int LastRise[8]; //Zeitpunkt der letzten steigende Flanke |
BlazeX | 0:b08668430838 | 31 | volatile int dTime[8]; //Pulsdauer in us [1000...2000] |
BlazeX | 0:b08668430838 | 32 | |
BlazeX | 0:b08668430838 | 33 | public: |
BlazeX | 6:ce4f088d8111 | 34 | int RawChannels[8]; //Rohdaten [1000...2000] |
BlazeX | 6:ce4f088d8111 | 35 | |
BlazeX | 2:5bb207fd97c5 | 36 | //Die Steuerbefehle |
BlazeX | 2:5bb207fd97c5 | 37 | float Throttle; //0=Aus, 1=Vollgas |
BlazeX | 2:5bb207fd97c5 | 38 | float Aileron; //-1=Links, 0=Nichts, +1=Rechts |
BlazeX | 2:5bb207fd97c5 | 39 | float Elevator; //-1=Sinken, 0=Nichts, +1=Steigen |
BlazeX | 2:5bb207fd97c5 | 40 | float Rudder; //-1=Links, 0=Nichts, +1=Rechts |
BlazeX | 2:5bb207fd97c5 | 41 | |
BlazeX | 7:0b27bef14b0e | 42 | float Aux1; //-1...+1 Left Trim |
BlazeX | 7:0b27bef14b0e | 43 | float Aux2; //-1...+1 Right Trim |
BlazeX | 7:0b27bef14b0e | 44 | float Aux3; //-1...+1 Knob |
BlazeX | 2:5bb207fd97c5 | 45 | |
BlazeX | 7:0b27bef14b0e | 46 | int State1; //0, 1 Gear |
BlazeX | 7:0b27bef14b0e | 47 | int State2; //0, 1, 2 F-Mode |
BlazeX | 2:5bb207fd97c5 | 48 | |
BlazeX | 0:b08668430838 | 49 | |
BlazeX | 0:b08668430838 | 50 | //Initialisieren |
BlazeX | 1:a5bfae540999 | 51 | AR8000(); |
BlazeX | 0:b08668430838 | 52 | void Init(); |
BlazeX | 0:b08668430838 | 53 | |
BlazeX | 0:b08668430838 | 54 | //Interrupt-Callbacks definieren |
BlazeX | 0:b08668430838 | 55 | AR8000_RISE_FALL(0); |
BlazeX | 0:b08668430838 | 56 | AR8000_RISE_FALL(1); |
BlazeX | 0:b08668430838 | 57 | AR8000_RISE_FALL(2); |
BlazeX | 0:b08668430838 | 58 | AR8000_RISE_FALL(3); |
BlazeX | 0:b08668430838 | 59 | AR8000_RISE_FALL(4); |
BlazeX | 0:b08668430838 | 60 | AR8000_RISE_FALL(5); |
BlazeX | 0:b08668430838 | 61 | AR8000_RISE_FALL(6); |
BlazeX | 0:b08668430838 | 62 | AR8000_RISE_FALL(7); |
BlazeX | 0:b08668430838 | 63 | |
BlazeX | 0:b08668430838 | 64 | //Update-Methode |
BlazeX | 0:b08668430838 | 65 | void Update(); |
BlazeX | 0:b08668430838 | 66 | }; |