Subversion Repositories FlightCtrl

Rev

Rev 1910 | Go to most recent revision | Details | Compare with Previous | 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
 */
2025 - 11
PR_GYROS_ORIENTATION_REVERSED = 0;
1910 - 12
 
13
#define AUTOZERO_PORT PORTD
14
#define AUTOZERO_DDR DDRD
15
#define AUTOZERO_BIT 5
16
 
17
void gyro_calibrate(void) {
18
        // If port not already set to output and high, do it.
19
        if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1
20
                        << AUTOZERO_BIT))) {
21
                AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
22
                AUTOZERO_DDR |= (1 << AUTOZERO_BIT);
23
                delay_ms(100);
24
        }
25
 
26
        // Make a pulse on the auto-zero output line.
27
        AUTOZERO_PORT &= ~(1 << AUTOZERO_BIT);
28
        delay_ms(1);
29
        AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
30
        // Delay_ms(10);
31
        delay_ms_Mess(100);
32
}
33
 
34
void gyro_setDefaults(void) {
2025 - 35
        staticParams.zerothOrderGyroCorrectionFactorx1000 = 1;
36
        staticParams.secondOrderGyroCorrectionDivisor = 2;
37
        staticParams.secondOrderGyroCorrectionLimit = 3;
1910 - 38
}