Zap'Em Blast'Em Robots
robots that play laser tag!
Loading...
Searching...
No Matches
encoder_driver.h
Go to the documentation of this file.
1
8
9#ifndef INC_ENCODER_DRIVER_H_
10#define INC_ENCODER_DRIVER_H_
11
12#include <stdint.h> // Allows use of standard integer types
13#include "stm32f4xx_hal.h" // or your STM32 family
14
21typedef struct
22{
23 uint32_t zero;
24 int32_t ar;
25 int32_t ticks;
26 int32_t last_ticks;
27 int32_t range;
28 TIM_HandleTypeDef *htim;
29} encoder_t;
30
36void setup_encoder(encoder_t *p_enc);
37
45void read_encoder(encoder_t *p_enc);
46
47#endif /* INC_ENCODER_DRIVER_H_ */
void setup_encoder(encoder_t *p_enc)
Initializes the encoder by setting its zero reference.
Definition encoder_driver.c:27
void read_encoder(encoder_t *p_enc)
Reads encoder ticks and applies wrap-around correction.
Definition encoder_driver.c:47
Structure to hold encoder task configuration and state.
Definition encoder_driver.h:22
int32_t ticks
Definition encoder_driver.h:25
TIM_HandleTypeDef * htim
Definition encoder_driver.h:28
int32_t ar
Definition encoder_driver.h:24
uint32_t zero
Definition encoder_driver.h:23
int32_t range
Definition encoder_driver.h:27
int32_t last_ticks
Definition encoder_driver.h:26