Subversion Repositories FlightCtrl

Rev

Rev 1821 | Rev 1887 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1612 dongfang 1
#include "invenSense.h"
2
#include "timer0.h"
3
#include "configuration.h"
4
 
5
#include <avr/io.h>
6
 
1646 - 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
 */
1821 - 11
const uint8_t GYRO_REVERSED[3] = { 0, 0, 0 };
12
const uint8_t ACC_REVERSED[3] = { 0, 0, 1 };
1646 - 13
 
1612 dongfang 14
#define AUTOZERO_PORT PORTD
15
#define AUTOZERO_DDR DDRD
16
#define AUTOZERO_BIT 5
17
 
18
void gyro_calibrate() {
1821 - 19
        // If port not already set to output and high, do it.
20
        if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1
21
                        << AUTOZERO_BIT))) {
22
                AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
23
                AUTOZERO_DDR |= (1 << AUTOZERO_BIT);
24
                Delay_ms(100);
25
        }
26
 
27
        // Make a pulse on the auto-zero output line.
28
        AUTOZERO_PORT &= ~(1 << AUTOZERO_BIT);
29
        Delay_ms(1);
30
        AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
31
        // Delay_ms(10);
32
        Delay_ms_Mess(100);
1612 dongfang 33
}
34
 
35
void gyro_setDefaults(void) {
1821 - 36
        staticParams.GyroD = 3;
37
        staticParams.GyroAccFactor = 1;
1874 - 38
        staticParams.DriftComp = 3;
39
    staticParams.GyroAccTrim = 2;
1612 dongfang 40
}