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: Stepper mbed Servo LSM9DS1_Library SDFileSystem
EncoderCounter.h@0:41afd907b7bd, 2021-03-12 (annotated)
- Committer:
- boro
- Date:
- Fri Mar 12 13:06:52 2021 +0000
- Revision:
- 0:41afd907b7bd
d
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| boro | 0:41afd907b7bd | 1 | /* |
| boro | 0:41afd907b7bd | 2 | * EncoderCounter.h |
| boro | 0:41afd907b7bd | 3 | * Copyright (c) 2018, ZHAW |
| boro | 0:41afd907b7bd | 4 | * All rights reserved. |
| boro | 0:41afd907b7bd | 5 | */ |
| boro | 0:41afd907b7bd | 6 | |
| boro | 0:41afd907b7bd | 7 | #ifndef ENCODER_COUNTER_H_ |
| boro | 0:41afd907b7bd | 8 | #define ENCODER_COUNTER_H_ |
| boro | 0:41afd907b7bd | 9 | |
| boro | 0:41afd907b7bd | 10 | #include <cstdlib> |
| boro | 0:41afd907b7bd | 11 | #include <stdint.h> |
| boro | 0:41afd907b7bd | 12 | #include <mbed.h> |
| boro | 0:41afd907b7bd | 13 | |
| boro | 0:41afd907b7bd | 14 | /** |
| boro | 0:41afd907b7bd | 15 | * This class implements a driver to read the quadrature |
| boro | 0:41afd907b7bd | 16 | * encoder counter of the STM32 microcontroller. |
| boro | 0:41afd907b7bd | 17 | */ |
| boro | 0:41afd907b7bd | 18 | class EncoderCounter { |
| boro | 0:41afd907b7bd | 19 | |
| boro | 0:41afd907b7bd | 20 | public: |
| boro | 0:41afd907b7bd | 21 | |
| boro | 0:41afd907b7bd | 22 | EncoderCounter(PinName a, PinName b); |
| boro | 0:41afd907b7bd | 23 | virtual ~EncoderCounter(); |
| boro | 0:41afd907b7bd | 24 | void reset(); |
| boro | 0:41afd907b7bd | 25 | void reset(int16_t offset); |
| boro | 0:41afd907b7bd | 26 | int16_t read(); |
| boro | 0:41afd907b7bd | 27 | operator int16_t(); |
| boro | 0:41afd907b7bd | 28 | |
| boro | 0:41afd907b7bd | 29 | private: |
| boro | 0:41afd907b7bd | 30 | |
| boro | 0:41afd907b7bd | 31 | TIM_TypeDef* TIM; |
| boro | 0:41afd907b7bd | 32 | }; |
| boro | 0:41afd907b7bd | 33 | |
| boro | 0:41afd907b7bd | 34 | #endif /* ENCODER_COUNTER_H_ */ |
| boro | 0:41afd907b7bd | 35 | |
| boro | 0:41afd907b7bd | 36 | |
| boro | 0:41afd907b7bd | 37 |