-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgyro.c
54 lines (47 loc) · 1.02 KB
/
gyro.c
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
/*
* Copyright (c) 2020, Dermot Tynan / Kalopa Research. All rights
* reserved.
*
* See the LICENSE file for more info.
*
* ABSTRACT
* Functions associated with the specific gyro in use. In this case,
* an ITG-3205.
*/
#include <stdio.h>
#include <avr/io.h>
#include <libavr.h>
#include "flight.h"
#define CALIBRATION_COUNT 2500
uint_t calibrate_loop;
/*
* Initialize the gyro. Set up our operating parameters.
*/
void
gyro_init(struct control *cp)
{
cp->g_roll = cp->g_pitch = cp->g_yaw = 0;
calibrate_loop = 0;
}
/*
* Calibrate the gyro. This is done at boot-up. The point is to
* pull a few thousand readings and then average out the error. We
* then use the error to correct all future readings.
*/
void
gyro_calibrate(struct control *cp)
{
/*
* Finally, drop out of calibration after a certain number of
* passes through the loop.
*/
if (++calibrate_loop > CALIBRATION_COUNT)
set_state(cp, STATE_INFLIGHT);
}
/*
* Read the pitch, roll & yaw data from the gyro.
*/
void
gyro_read(struct control *cp)
{
}