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.
SPI_Encoder.h@5:1458a8f024dc, 2019-09-26 (annotated)
- Committer:
- Kirua
- Date:
- Thu Sep 26 15:21:39 2019 +0000
- Revision:
- 5:1458a8f024dc
- Parent:
- 4:2331b7fcfe8d
fix
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Kirua | 0:21ae825df645 | 1 | #ifndef SPI_ENCODER_H |
| Kirua | 0:21ae825df645 | 2 | #define SPI_ENCODER_H |
| Kirua | 0:21ae825df645 | 3 | |
| Kirua | 0:21ae825df645 | 4 | #include "mbed.h" |
| Kirua | 0:21ae825df645 | 5 | |
| Kirua | 0:21ae825df645 | 6 | #define encoder_num 4 |
| Kirua | 5:1458a8f024dc | 7 | #define PI 3.1415f |
| Kirua | 0:21ae825df645 | 8 | |
| Kirua | 0:21ae825df645 | 9 | |
| Kirua | 1:7826ec4d9405 | 10 | /* cui amt203 */ |
| Kirua | 0:21ae825df645 | 11 | class SPI_Encoder |
| Kirua | 0:21ae825df645 | 12 | { |
| Kirua | 0:21ae825df645 | 13 | public: |
| Kirua | 1:7826ec4d9405 | 14 | SPI_Encoder(PinName mosi, PinName miso, PinName sclk, PinName _cs0, PinName _cs1, PinName _cs2, PinName _cs3, float t); |
| Kirua | 4:2331b7fcfe8d | 15 | bool getPosition(int num); |
| Kirua | 1:7826ec4d9405 | 16 | bool setZero(int num); |
| Kirua | 1:7826ec4d9405 | 17 | void inverse(int num); |
| Kirua | 0:21ae825df645 | 18 | |
| Kirua | 1:7826ec4d9405 | 19 | float angle[encoder_num]; |
| Kirua | 1:7826ec4d9405 | 20 | float velocity[encoder_num]; |
| Kirua | 0:21ae825df645 | 21 | |
| Kirua | 0:21ae825df645 | 22 | private: |
| Kirua | 0:21ae825df645 | 23 | SPI encoder; |
| Kirua | 0:21ae825df645 | 24 | DigitalOut cs0; |
| Kirua | 0:21ae825df645 | 25 | DigitalOut cs1; |
| Kirua | 0:21ae825df645 | 26 | DigitalOut cs2; |
| Kirua | 0:21ae825df645 | 27 | DigitalOut cs3; |
| Kirua | 1:7826ec4d9405 | 28 | float delta_t; |
| Kirua | 1:7826ec4d9405 | 29 | bool direction[4]; |
| Kirua | 3:d3694519bd73 | 30 | |
| Kirua | 0:21ae825df645 | 31 | uint8_t _SPI_T (int num, uint8_t SPITransmit); |
| Kirua | 0:21ae825df645 | 32 | void _switching(int num, int value); |
| Kirua | 0:21ae825df645 | 33 | }; |
| Kirua | 0:21ae825df645 | 34 | |
| Kirua | 0:21ae825df645 | 35 | #endif |