Quadrature decoder

Dependents:   Telliskivi2_2014

qed.h

Committer:
Reiko
Date:
2013-07-29
Revision:
0:0e8cb3139868

File content as of revision 0:0e8cb3139868:

#ifndef QED_H
#define QED_H

#include "mbed.h"

#define PREV_MASK 0x1 //Mask for the previous state in determining direction of rotation.
#define CURR_MASK 0x2 //Mask for the current state in determining direction of rotation.
#define INVALID   0x3 //XORing two states where both bits have changed.
 
class QED {
public:
    QED(PinName channelA, PinName channelB);
 
    int read();
 
private:
    void decode();

    InterruptIn interruptA;
    InterruptIn interruptB;
    
    volatile int pulses;
    
    int prevState;
    int currState;
};

#endif