A fork of AR8000
Dependents: Sumo_v2 Sumo_v2_Unstable Sumo_v2_RG13
AR8000.h@2:5bb207fd97c5, 2012-04-14 (annotated)
- Committer:
- BlazeX
- Date:
- Sat Apr 14 10:08:55 2012 +0000
- Revision:
- 2:5bb207fd97c5
- Parent:
- 1:a5bfae540999
- Child:
- 6:ce4f088d8111
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 | 0:b08668430838 | 12 | if(dT > 900 && dT < 2200)\ |
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 | 2:5bb207fd97c5 | 34 | //Die Steuerbefehle |
BlazeX | 2:5bb207fd97c5 | 35 | float Throttle; //0=Aus, 1=Vollgas |
BlazeX | 2:5bb207fd97c5 | 36 | float Aileron; //-1=Links, 0=Nichts, +1=Rechts |
BlazeX | 2:5bb207fd97c5 | 37 | float Elevator; //-1=Sinken, 0=Nichts, +1=Steigen |
BlazeX | 2:5bb207fd97c5 | 38 | float Rudder; //-1=Links, 0=Nichts, +1=Rechts |
BlazeX | 2:5bb207fd97c5 | 39 | |
BlazeX | 2:5bb207fd97c5 | 40 | float TrimL; //-1...+1 Left Trim |
BlazeX | 2:5bb207fd97c5 | 41 | float TrimR; //-1...+1 Right Trim |
BlazeX | 2:5bb207fd97c5 | 42 | float TrimK; //-1...+1 Knob |
BlazeX | 2:5bb207fd97c5 | 43 | |
BlazeX | 2:5bb207fd97c5 | 44 | int ControlActive; //0=Failsafe, 1=Empfang vorhanden |
BlazeX | 2:5bb207fd97c5 | 45 | int State; //0, 1, 2 |
BlazeX | 2:5bb207fd97c5 | 46 | |
BlazeX | 0:b08668430838 | 47 | |
BlazeX | 0:b08668430838 | 48 | //Initialisieren |
BlazeX | 1:a5bfae540999 | 49 | AR8000(); |
BlazeX | 0:b08668430838 | 50 | void Init(); |
BlazeX | 0:b08668430838 | 51 | |
BlazeX | 0:b08668430838 | 52 | //Interrupt-Callbacks definieren |
BlazeX | 0:b08668430838 | 53 | AR8000_RISE_FALL(0); |
BlazeX | 0:b08668430838 | 54 | AR8000_RISE_FALL(1); |
BlazeX | 0:b08668430838 | 55 | AR8000_RISE_FALL(2); |
BlazeX | 0:b08668430838 | 56 | AR8000_RISE_FALL(3); |
BlazeX | 0:b08668430838 | 57 | AR8000_RISE_FALL(4); |
BlazeX | 0:b08668430838 | 58 | AR8000_RISE_FALL(5); |
BlazeX | 0:b08668430838 | 59 | AR8000_RISE_FALL(6); |
BlazeX | 0:b08668430838 | 60 | AR8000_RISE_FALL(7); |
BlazeX | 0:b08668430838 | 61 | |
BlazeX | 0:b08668430838 | 62 | //Update-Methode |
BlazeX | 0:b08668430838 | 63 | void Update(); |
BlazeX | 0:b08668430838 | 64 | }; |