A fork of AR8000

Dependents:   Sumo_v2 Sumo_v2_Unstable Sumo_v2_RG13

AR8000.h

Committer:
BlazeX
Date:
2012-04-16
Revision:
7:0b27bef14b0e
Parent:
6:ce4f088d8111
Child:
9:c57888a66a5f

File content as of revision 7:0b27bef14b0e:

#pragma once

//Interrupt-Callback Vorlage
#define AR8000_RISE_FALL(Ch)\
void Rise##Ch()\
{\
    LastRise[Ch]= Time.read_us();\
}\
void Fall##Ch()\
{\
    int dT= Time.read_us() - LastRise[Ch];\
    if(dT > 900 && dT < 2100)\
         dTime[Ch]= dT;\
}


class AR8000
{
private:
    InterruptIn ChInt0;           //Interrupt-Handler fuer jeden Pin
    InterruptIn ChInt1;
    InterruptIn ChInt2;
    InterruptIn ChInt3;
    InterruptIn ChInt4;
    InterruptIn ChInt5;
    InterruptIn ChInt6;
    InterruptIn ChInt7;
    
    Timer Time;                     //Timer for all 8 Channels
    volatile int LastRise[8];       //Zeitpunkt der letzten steigende Flanke  
    volatile int dTime[8];          //Pulsdauer in us [1000...2000]
    
public:
    int RawChannels[8]; //Rohdaten [1000...2000]
    
    //Die Steuerbefehle
    float Throttle;     //0=Aus, 1=Vollgas
    float Aileron;      //-1=Links, 0=Nichts, +1=Rechts
    float Elevator;     //-1=Sinken, 0=Nichts, +1=Steigen
    float Rudder;       //-1=Links, 0=Nichts, +1=Rechts
    
    float Aux1;         //-1...+1 Left Trim
    float Aux2;         //-1...+1 Right Trim
    float Aux3;         //-1...+1 Knob
    
    int State1;         //0, 1 Gear
    int State2;         //0, 1, 2 F-Mode
        
    
    //Initialisieren
    AR8000();
    void Init();
    
    //Interrupt-Callbacks definieren
    AR8000_RISE_FALL(0);
    AR8000_RISE_FALL(1);
    AR8000_RISE_FALL(2);
    AR8000_RISE_FALL(3);
    AR8000_RISE_FALL(4);
    AR8000_RISE_FALL(5);
    AR8000_RISE_FALL(6);
    AR8000_RISE_FALL(7);
    
    //Update-Methode
    void Update();
};