Rev 1612 | Rev 1646 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1612 | Rev 1645 | ||
---|---|---|---|
1 | #include "invenSense.h" |
1 | #include "invenSense.h" |
2 | #include "timer0.h" |
2 | #include "timer0.h" |
3 | #include "configuration.h" |
3 | #include "configuration.h" |
4 | 4 | ||
5 | #include <avr/io.h> |
5 | #include <avr/io.h> |
6 | 6 | ||
7 | #define AUTOZERO_PORT PORTD |
7 | #define AUTOZERO_PORT PORTD |
8 | #define AUTOZERO_DDR DDRD |
8 | #define AUTOZERO_DDR DDRD |
9 | #define AUTOZERO_BIT 5 |
9 | #define AUTOZERO_BIT 5 |
- | 10 | ||
- | 11 | const uint8_t GYROS_REVERSE[2] = {0,0}; |
|
10 | 12 | ||
11 | void gyro_calibrate() { |
13 | void gyro_calibrate() { |
12 | // If port not already set to output and high, do it. |
14 | // If port not already set to output and high, do it. |
13 | if (!(AUTOZERO_DDR & (1<<AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1<<AUTOZERO_BIT))) { |
15 | if (!(AUTOZERO_DDR & (1<<AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1<<AUTOZERO_BIT))) { |
14 | AUTOZERO_PORT |= (1<<AUTOZERO_BIT); |
16 | AUTOZERO_PORT |= (1<<AUTOZERO_BIT); |
15 | AUTOZERO_DDR |= (1<<AUTOZERO_BIT); |
17 | AUTOZERO_DDR |= (1<<AUTOZERO_BIT); |
16 | Delay_ms(100); |
18 | Delay_ms(100); |
17 | } |
19 | } |
18 | 20 | ||
19 | // Make a pulse on the auto-zero output line. |
21 | // Make a pulse on the auto-zero output line. |
20 | AUTOZERO_PORT &= ~(1<<AUTOZERO_BIT); |
22 | AUTOZERO_PORT &= ~(1<<AUTOZERO_BIT); |
21 | Delay_ms(1); |
23 | Delay_ms(1); |
22 | AUTOZERO_PORT |= (1<<AUTOZERO_BIT); |
24 | AUTOZERO_PORT |= (1<<AUTOZERO_BIT); |
23 | // Delay_ms(10); |
25 | // Delay_ms(10); |
24 | Delay_ms_Mess(100); |
26 | Delay_ms_Mess(100); |
25 | } |
27 | } |
26 | 28 | ||
27 | void gyro_setDefaults(void) { |
29 | void gyro_setDefaults(void) { |
28 | staticParams.GyroD = 3; |
30 | staticParams.GyroD = 3; |
29 | staticParams.GyroAccFactor = 1; |
31 | staticParams.GyroAccFactor = 1; |
30 | staticParams.DriftComp = 1; |
32 | staticParams.DriftComp = 1; |
31 | 33 | ||
32 | // Not used. |
34 | // Not used. |
33 | staticParams.AngleTurnOverPitch = 85; |
35 | staticParams.AngleTurnOverPitch = 85; |
34 | staticParams.AngleTurnOverRoll = 85; |
36 | staticParams.AngleTurnOverRoll = 85; |
35 | } |
37 | } |
36 | 38 |