-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquadEncoder.h
More file actions
56 lines (34 loc) · 1.54 KB
/
quadEncoder.h
File metadata and controls
56 lines (34 loc) · 1.54 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* quadEncoder.h
*
* Created on: 30.03.2017
* Author: david s
*/
#ifndef LIB_QUADENCODER_H_
#define LIB_QUADENCODER_H_
#define DIRECTION_CW 0
#define DIRECTION_CCW 1
#include <stdint.h>
#include <stdbool.h>
typedef struct
{
uint32_t EncoderPort_A;
uint32_t EncoderPort_B;
uint8_t Encoder_A_Pin;
uint8_t Encoder_B_Pin;
uint8_t Direction;
int32_t newVal;
int32_t diffVal;
int32_t *EncoderCounts;
} EncoderStatus_t;
#define ENCODER_VEHICLE_COUNT_UP 0
#define ENCODER_VEHICLE_COUNT_DOWN 1
#define ENCODER_SETUP_HARDWARE(Port_A, Port_B, A, B) { GPIOPinTypeGPIOInput(Port_A, A ); \
GPIOPinTypeGPIOInput(Port_B, B ); }
#define ENCODER_SETUP_HARDWARE_PULLUP_EN(Port_A, Port_B, A, B) { GPIOPinTypeGPIOInput(Port_A, A); \
GPIOPinTypeGPIOInput(Port_B, B); \
GPIOPadConfigSet(Port_A, A, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); \
GPIOPadConfigSet(Port_B, B, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); }
void setupEncoderHardware(EncoderStatus_t *EncoderStatus, uint8_t Direction, uint32_t Port_A, uint32_t Port_B, uint32_t A, uint32_t B, int32_t *EncoderCounts); // Initialize Pins for Encoder
void decodeEncoder_FromISR(EncoderStatus_t *EncoderStatus);
#endif /* LIB_QUADENCODER_H_ */