forked from sim-/kk
-
Notifications
You must be signed in to change notification settings - Fork 17
/
gyros.h
48 lines (38 loc) · 1.11 KB
/
gyros.h
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
#ifndef GYROS_H
#define GYROS_H
#include "config.h"
/*** BEGIN DEFINES ***/
//#define GAIN_POT_REVERSE
// Gyro gain shift-right (after 32-bit multiplication of GainInADC[] value).
#define GYRO_GAIN_SHIFT 5
// Skip yaw gyro calculations if using external yaw gyro
//#define EXTERNAL_YAW_GYRO
#define ADC_MAX 1023
/*** END DEFINES ***/
/*** BEGIN HELPER MACROS ***/
#ifdef GAIN_POT_REVERSE
#undef GAIN_POT_REVERSE
#define GAIN_POT_REVERSE ADC_MAX -
#else
#define GAIN_POT_REVERSE
#endif
/*** END HELPER MACROS ***/
/*** BEGIN TYPES ***/
enum GyroDirection { GYRO_NORMAL = 0, GYRO_REVERSED };
enum GyroArrayIndex { ROLL = 0, PITCH, YAW };
/*** END TYPES ***/
/*** BEGIN VARIABLES ***/
extern uint16_t GainInADC[3]; // ADC result
extern int16_t gyroADC[3]; // Holds Gyro ADC's
extern int16_t gyroZero[3]; // used for calibrating Gyros on ground
/*** END VARIABLES ***/
/*** BEGIN PROTOTYPES ***/
void init_adc(void);
void read_adc(uint8_t channel);
void ReadGainPots(void);
void ReadGyros(void);
void CalibrateGyros(void);
void gyrosSetup(void);
void gyrosReverse(void);
/*** END PROTOTYPES ***/
#endif