Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
EncoderCounter.h@0:55725179457f, 2020-03-09 (annotated)
- Committer:
- kuni97
- Date:
- Mon Mar 09 10:08:38 2020 +0000
- Revision:
- 0:55725179457f
V1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kuni97 | 0:55725179457f | 1 | /* |
kuni97 | 0:55725179457f | 2 | * EncoderCounter.h |
kuni97 | 0:55725179457f | 3 | * Copyright (c) 2018, ZHAW |
kuni97 | 0:55725179457f | 4 | * All rights reserved. |
kuni97 | 0:55725179457f | 5 | */ |
kuni97 | 0:55725179457f | 6 | |
kuni97 | 0:55725179457f | 7 | #ifndef ENCODER_COUNTER_H_ |
kuni97 | 0:55725179457f | 8 | #define ENCODER_COUNTER_H_ |
kuni97 | 0:55725179457f | 9 | |
kuni97 | 0:55725179457f | 10 | #include <cstdlib> |
kuni97 | 0:55725179457f | 11 | #include <stdint.h> |
kuni97 | 0:55725179457f | 12 | #include <mbed.h> |
kuni97 | 0:55725179457f | 13 | |
kuni97 | 0:55725179457f | 14 | /** |
kuni97 | 0:55725179457f | 15 | * This class implements a driver to read the quadrature |
kuni97 | 0:55725179457f | 16 | * encoder counter of the STM32 microcontroller. |
kuni97 | 0:55725179457f | 17 | */ |
kuni97 | 0:55725179457f | 18 | class EncoderCounter { |
kuni97 | 0:55725179457f | 19 | |
kuni97 | 0:55725179457f | 20 | public: |
kuni97 | 0:55725179457f | 21 | |
kuni97 | 0:55725179457f | 22 | EncoderCounter(PinName a, PinName b); |
kuni97 | 0:55725179457f | 23 | virtual ~EncoderCounter(); |
kuni97 | 0:55725179457f | 24 | void reset(); |
kuni97 | 0:55725179457f | 25 | void reset(int16_t offset); |
kuni97 | 0:55725179457f | 26 | int16_t read(); |
kuni97 | 0:55725179457f | 27 | operator int16_t(); |
kuni97 | 0:55725179457f | 28 | |
kuni97 | 0:55725179457f | 29 | private: |
kuni97 | 0:55725179457f | 30 | |
kuni97 | 0:55725179457f | 31 | TIM_TypeDef* TIM; |
kuni97 | 0:55725179457f | 32 | }; |
kuni97 | 0:55725179457f | 33 | |
kuni97 | 0:55725179457f | 34 | #endif /* ENCODER_COUNTER_H_ */ |
kuni97 | 0:55725179457f | 35 | |
kuni97 | 0:55725179457f | 36 | |
kuni97 | 0:55725179457f | 37 |