Subversion Repositories FlightCtrl

Rev

Rev 1612 | Rev 1646 | 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
 
7
#define AUTOZERO_PORT PORTD
8
#define AUTOZERO_DDR DDRD
9
#define AUTOZERO_BIT 5
10
 
1645 - 11
const uint8_t GYROS_REVERSE[2] = {0,0};
12
 
1612 dongfang 13
void gyro_calibrate() {
14
  // If port not already set to output and high, do it.
15
  if (!(AUTOZERO_DDR & (1<<AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1<<AUTOZERO_BIT))) {
16
    AUTOZERO_PORT |= (1<<AUTOZERO_BIT);
17
    AUTOZERO_DDR |= (1<<AUTOZERO_BIT);
18
    Delay_ms(100);
19
  }
20
 
21
  // Make a pulse on the auto-zero output line.
22
  AUTOZERO_PORT &= ~(1<<AUTOZERO_BIT);
23
  Delay_ms(1);
24
  AUTOZERO_PORT |= (1<<AUTOZERO_BIT);
25
  // Delay_ms(10);
26
  Delay_ms_Mess(100);
27
}
28
 
29
void gyro_setDefaults(void) {
30
  staticParams.GyroD = 3;
31
  staticParams.GyroAccFactor = 1;
32
  staticParams.DriftComp = 1;
33
 
34
  // Not used.
35
  staticParams.AngleTurnOverPitch = 85;
36
  staticParams.AngleTurnOverRoll = 85;
37
}