forked from simplefoc/Arduino-FOC-drivers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTM32HWEncoder.h
More file actions
38 lines (26 loc) · 809 Bytes
/
STM32HWEncoder.h
File metadata and controls
38 lines (26 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <Arduino.h>
#if defined(_STM32_DEF_)
#include <HardwareTimer.h>
#include "common/base_classes/Sensor.h"
#include "common/foc_utils.h"
class STM32HWEncoder : public Sensor {
public:
/**
Encoder class constructor
@param ppr impulses per rotation (cpr=ppr*4)
*/
explicit STM32HWEncoder(unsigned int ppr, int pinA, int pinB, int pinI=-1);
void init() override;
int needsSearch() override;
int hasIndex(); // !< function returning 1 if encoder has index pin and 0 if not.
bool initialized = false;
uint32_t cpr; //!< encoder cpr number
PinName _pinA, _pinB, _pinI;
bool index_found;
uint32_t index_polarity = RISING;
protected:
float getSensorAngle() override;
TIM_HandleTypeDef encoder_handle;
};
#endif