Subversion Repositories FlightCtrl

Rev

Rev 2025 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1910 - 1
#include "invenSense.h"
2
#include "timer0.h"
3
#include "configuration.h"
4
 
5
#include <avr/io.h>
6
 
7
/*
8
 * Configuration for my prototype board with InvenSense gyros.
9
 * The FC 1.3 board is installed upside down, therefore Z acc is reversed but not roll.
10
 */
11
const uint8_t GYRO_REVERSED[3] = { 0, 0, 0 };
12
const uint8_t ACC_REVERSED[3] = { 0, 0, 1 };
13
const uint8_t AXIS_TRANSFORM = 0;
14
 
15
#define AUTOZERO_PORT PORTD
16
#define AUTOZERO_DDR DDRD
17
#define AUTOZERO_BIT 5
18
 
19
void gyro_calibrate(void) {
20
        // If port not already set to output and high, do it.
21
        if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1
22
                        << AUTOZERO_BIT))) {
23
                AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
24
                AUTOZERO_DDR |= (1 << AUTOZERO_BIT);
25
                delay_ms(100);
26
        }
27
 
28
        // Make a pulse on the auto-zero output line.
29
        AUTOZERO_PORT &= ~(1 << AUTOZERO_BIT);
30
        delay_ms(1);
31
        AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
32
        // Delay_ms(10);
33
        delay_ms_Mess(100);
34
}
35
 
36
void gyro_setDefaults(void) {
37
        staticParams.GyroAccFactor = 1;
38
        staticParams.DriftComp = 3;
39
    staticParams.GyroAccTrim = 2;
40
}