Rev 2025 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2025 | Rev 2099 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | #include "invenSense.h" |
- | |
2 | #include "timer0.h" |
1 | #include "timer0.h" |
3 | #include "configuration.h" |
2 | #include "configuration.h" |
Line 4... | Line 3... | ||
4 | 3 | ||
Line 5... | Line 4... | ||
5 | #include <avr/io.h> |
4 | #include <avr/io.h> |
6 | 5 | ||
7 | /* |
6 | /* |
8 | * Configuration for my prototype board with InvenSense gyros. |
7 | * 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. |
- | |
Line -... | Line 8... | ||
- | 8 | * The FC 1.3 board is installed upside down, therefore Z acc is reversed but not roll. |
|
10 | */ |
9 | */ |
11 | PR_GYROS_ORIENTATION_REVERSED = 0; |
10 | |
12 | 11 | // The special auto-zero feature of this gyro needs a port. |
|
Line 13... | Line 12... | ||
13 | #define AUTOZERO_PORT PORTD |
12 | #define AUTOZERO_PORT PORTD |
14 | #define AUTOZERO_DDR DDRD |
13 | #define AUTOZERO_DDR DDRD |
15 | #define AUTOZERO_BIT 5 |
14 | #define AUTOZERO_BIT 5 |
16 | - | ||
17 | void gyro_calibrate(void) { |
15 | |
18 | // If port not already set to output and high, do it. |
16 | void gyro_calibrate(void) { |
19 | if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1 |
17 | // If port not already set to output and high, do it. |
20 | << AUTOZERO_BIT))) { |
18 | if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1 << AUTOZERO_BIT))) { |
Line 21... | Line 19... | ||
21 | AUTOZERO_PORT |= (1 << AUTOZERO_BIT); |
19 | AUTOZERO_PORT |= (1 << AUTOZERO_BIT); |
22 | AUTOZERO_DDR |= (1 << AUTOZERO_BIT); |
20 | AUTOZERO_DDR |= (1 << AUTOZERO_BIT); |
23 | delay_ms(100); |
21 | delay_ms(100); |
24 | } |
22 | } |
25 | 23 | ||
26 | // Make a pulse on the auto-zero output line. |
24 | // Make a pulse on the auto-zero output line. |
27 | AUTOZERO_PORT &= ~(1 << AUTOZERO_BIT); |
25 | AUTOZERO_PORT &= ~(1 << AUTOZERO_BIT); |
Line 28... | Line 26... | ||
28 | delay_ms(1); |
26 | delay_ms(1); |
- | 27 | AUTOZERO_PORT |= (1 << AUTOZERO_BIT); |
|
- | 28 | // Delay_ms(10); |
|
- | 29 | delay_ms_with_adc_measurement(100, 0); |
|
29 | AUTOZERO_PORT |= (1 << AUTOZERO_BIT); |
30 | } |
30 | // Delay_ms(10); |
31 | |
- | 32 | void gyro_init(void) { |
|
31 | delay_ms_Mess(100); |
33 | gyro_calibrate(); |
- | 34 | } |
|
32 | } |
35 |