-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathencoder.h
More file actions
30 lines (24 loc) · 774 Bytes
/
Copy pathencoder.h
File metadata and controls
30 lines (24 loc) · 774 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
/*
* encoder.h
*
* Created on: Feb 24, 2012
* Author: aah9038
*/
#ifndef ENCODER_H_
#define ENCODER_H_
#include <stdint.h>
#include <hw/inout.h>
typedef struct{
uintptr_t cnt_port; //port that encoder is hooked to
char last_read; //copy of last port read for edge detection
char read; //current port read
char debounce; //used to debounce channel A
char a_mask; //bitmask for channel A pin
char b_mask; //bitmask for channel B pin
char index_mask;
int first_index; //index that first index rising edge was found at.
int position; //current position encoder is at
}encoder_dat;
void initEncoder(encoder_dat* data, char index_pin, char chan_a_pin, char chan_b_pin, uintptr_t port );
void updateEncoder(encoder_dat* data);
#endif /* ENCODER_H_ */