Telescope Control Library
SerialGrayAbsEncoder.h@19:fd854309cb4c, 2018-09-24 (annotated)
- Committer:
- caoyu@caoyuan9642-desktop.MIT.EDU
- Date:
- Mon Sep 24 19:36:48 2018 -0400
- Revision:
- 19:fd854309cb4c
- Parent:
- 0:6cb2eaf8b133
Fix bug in nudging with small speeds mentioned in the last commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
caoyuan9642 | 0:6cb2eaf8b133 | 1 | /* |
caoyuan9642 | 0:6cb2eaf8b133 | 2 | * OmronE6CPDriver.h |
caoyuan9642 | 0:6cb2eaf8b133 | 3 | * |
caoyuan9642 | 0:6cb2eaf8b133 | 4 | * Created on: 2018Äê2ÔÂ7ÈÕ |
caoyuan9642 | 0:6cb2eaf8b133 | 5 | * Author: caoyuan9642 |
caoyuan9642 | 0:6cb2eaf8b133 | 6 | */ |
caoyuan9642 | 0:6cb2eaf8b133 | 7 | |
caoyuan9642 | 0:6cb2eaf8b133 | 8 | #ifndef TELESCOPE_DRIVER_SERIALGRAYABSENCODER_H_ |
caoyuan9642 | 0:6cb2eaf8b133 | 9 | #define TELESCOPE_DRIVER_SERIALGRAYABSENCODER_H_ |
caoyuan9642 | 0:6cb2eaf8b133 | 10 | |
caoyuan9642 | 0:6cb2eaf8b133 | 11 | #include <GrayAbsEncoder.h> |
caoyuan9642 | 0:6cb2eaf8b133 | 12 | #include <SerialDigitalInput.h> |
caoyuan9642 | 0:6cb2eaf8b133 | 13 | #include "mbed.h" |
caoyuan9642 | 0:6cb2eaf8b133 | 14 | |
caoyuan9642 | 0:6cb2eaf8b133 | 15 | template<uint8_t N> |
caoyuan9642 | 0:6cb2eaf8b133 | 16 | class SerialGrayAbsEncoder: public GrayAbsEncoder<N>, SerialDigitalInput<N> |
caoyuan9642 | 0:6cb2eaf8b133 | 17 | { |
caoyuan9642 | 0:6cb2eaf8b133 | 18 | public: |
caoyuan9642 | 0:6cb2eaf8b133 | 19 | SerialGrayAbsEncoder(PinName clk, PinName load, PinName data, |
caoyuan9642 | 0:6cb2eaf8b133 | 20 | bool polarity = false) : |
caoyuan9642 | 0:6cb2eaf8b133 | 21 | GrayAbsEncoder<N>(), SerialDigitalInput<N>(clk, load, data), polarity( |
caoyuan9642 | 0:6cb2eaf8b133 | 22 | polarity) |
caoyuan9642 | 0:6cb2eaf8b133 | 23 | { |
caoyuan9642 | 0:6cb2eaf8b133 | 24 | } |
caoyuan9642 | 0:6cb2eaf8b133 | 25 | virtual ~SerialGrayAbsEncoder() |
caoyuan9642 | 0:6cb2eaf8b133 | 26 | { |
caoyuan9642 | 0:6cb2eaf8b133 | 27 | } |
caoyuan9642 | 0:6cb2eaf8b133 | 28 | |
caoyuan9642 | 0:6cb2eaf8b133 | 29 | bool polarity; /*If polarity=false, the input will be bit-negated before converted to raw Binary*/ |
caoyuan9642 | 0:6cb2eaf8b133 | 30 | uint32_t readPosGray() |
caoyuan9642 | 0:6cb2eaf8b133 | 31 | { |
caoyuan9642 | 0:6cb2eaf8b133 | 32 | uint32_t data = SerialDigitalInput<N>::read(); |
caoyuan9642 | 0:6cb2eaf8b133 | 33 | return polarity ? (((1 << N) - 1) ^ data) : data; |
caoyuan9642 | 0:6cb2eaf8b133 | 34 | } |
caoyuan9642 | 0:6cb2eaf8b133 | 35 | }; |
caoyuan9642 | 0:6cb2eaf8b133 | 36 | |
caoyuan9642 | 0:6cb2eaf8b133 | 37 | #endif /* TELESCOPE_DRIVER_SERIALGRAYABSENCODER_H_ */ |
caoyuan9642 | 0:6cb2eaf8b133 | 38 | |
caoyuan9642 | 0:6cb2eaf8b133 | 39 |