Rev 568 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
555 | FredericG | 1 | Index: analog.c |
2 | =================================================================== |
||
3 | --- analog.c (revision 1255) |
||
4 | +++ analog.c (working copy) |
||
5 | @@ -80,6 +80,31 @@ |
||
6 | int8_t ExpandBaro = 0; |
||
7 | uint8_t PressureSensorOffset; |
||
8 | |||
9 | +#define AD_GYRO_YAW 0 |
||
10 | +#define AD_GYRO_ROLL 1 |
||
11 | +#define AD_GYRO_NICK 2 |
||
12 | +#define AD_AIRPRESS 3 |
||
13 | +#define AD_UBAT 4 |
||
14 | +#define AD_ACC_TOP 5 |
||
15 | +#define AD_ACC_ROLL 6 |
||
16 | +#define AD_ACC_NICK 7 |
||
17 | + |
||
18 | + |
||
19 | +int VibTestData[VIBTEST_NB_SAMPLES]; |
||
20 | +volatile unsigned int VibTestCount; |
||
21 | +int* VibTestDataP; |
||
22 | +uint8_t VibTestChannel; |
||
23 | + |
||
24 | + |
||
25 | +void StartVibTest(uint8_t channel) |
||
26 | +{ |
||
27 | + VibTestChannel = channel; |
||
28 | + VibTestDataP = VibTestData; |
||
29 | + VibTestCount = VIBTEST_NB_SAMPLES; |
||
30 | + ADMUX = AD_ACC_ROLL; |
||
31 | + ADC_Enable(); |
||
32 | +} |
||
33 | + |
||
34 | /*****************************************************/ |
||
35 | /* Initialize Analog Digital Converter */ |
||
36 | /*****************************************************/ |
||
37 | @@ -202,15 +227,8 @@ |
||
38 | */ |
||
39 | |||
40 | |||
41 | -#define AD_GYRO_YAW 0 |
||
42 | -#define AD_GYRO_ROLL 1 |
||
43 | -#define AD_GYRO_NICK 2 |
||
44 | -#define AD_AIRPRESS 3 |
||
45 | -#define AD_UBAT 4 |
||
46 | -#define AD_ACC_TOP 5 |
||
47 | -#define AD_ACC_ROLL 6 |
||
48 | -#define AD_ACC_NICK 7 |
||
49 | |||
50 | + |
||
51 | ISR(ADC_vect) |
||
52 | { |
||
53 | static uint8_t ad_channel = AD_GYRO_NICK, state = 0; |
||
54 | @@ -218,6 +236,15 @@ |
||
55 | static int32_t filtergyronick, filtergyroroll; |
||
56 | static int16_t tmpAirPressure = 0; |
||
57 | |||
58 | + if (VibTestCount) |
||
59 | + { |
||
60 | + *(VibTestDataP++) = ADC; |
||
61 | + ADMUX = VibTestChannel; |
||
62 | + VibTestCount--; |
||
63 | + ADC_Enable(); |
||
64 | + return; |
||
65 | + } |
||
66 | + |
||
67 | // state machine |
||
68 | switch(state++) |
||
69 | { |
||
70 | Index: analog.h |
||
71 | =================================================================== |
||
72 | --- analog.h (revision 1255) |
||
73 | +++ analog.h (working copy) |
||
74 | @@ -25,7 +25,12 @@ |
||
75 | void SearchDacGyroOffset(void); |
||
76 | void ADC_Init(void); |
||
77 | |||
78 | +#define VIBTEST_NB_SAMPLES 1000 |
||
79 | +extern int VibTestData[VIBTEST_NB_SAMPLES]; |
||
80 | +extern volatile unsigned int VibTestCount; |
||
81 | +void StartVibTest(uint8_t channel); |
||
82 | |||
83 | + |
||
84 | // clear ADC enable & ADC Start Conversion & ADC Interrupt Enable bit |
||
85 | #define ADC_Disable() (ADCSRA &= ~((1<<ADEN)|(1<<ADSC)|(1<<ADIE))) |
||
86 | // set ADC enable & ADC Start Conversion & ADC Interrupt Enable bit |
||
87 | Index: main.c |
||
88 | =================================================================== |
||
89 | --- main.c (revision 1255) |
||
90 | +++ main.c (working copy) |
||
91 | @@ -175,7 +175,7 @@ |
||
92 | sei(); |
||
93 | |||
94 | printf("\n\r==================================="); |
||
95 | - printf("\n\rFlightControl"); |
||
96 | + printf("\n\rFlightControl FRED"); |
||
97 | printf("\n\rHardware: %d.%d", BoardRelease/10, BoardRelease%10); |
||
98 | if(CPUType == ATMEGA644P) |
||
99 | printf("\r\n CPU: Atmega644p"); |
||
100 | Index: menu.c |
||
101 | =================================================================== |
||
102 | --- menu.c (revision 1255) |
||
103 | +++ menu.c (working copy) |
||
104 | @@ -139,7 +139,7 @@ |
||
105 | switch(MenuItem) |
||
106 | { |
||
107 | case 0:// Version Info Menu Item |
||
108 | - LCD_printfxy(0,0,"+ MikroKopter +"); |
||
109 | + LCD_printfxy(0,0,"+ MikroKopter F"); |
||
110 | LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
||
111 | LCD_printfxy(0,2,"Setting: %d %s", GetActiveParamSet(), Mixer.Name); |
||
112 | if(I2CTimeout < 6) |
||
113 | Index: timer0.c |
||
114 | =================================================================== |
||
115 | --- timer0.c (revision 1255) |
||
116 | +++ timer0.c (working copy) |
||
117 | @@ -173,14 +173,14 @@ |
||
118 | } |
||
119 | |||
120 | // if beeper is on |
||
121 | - if(Beeper_On) |
||
122 | +// if(Beeper_On) |
||
123 | +// { |
||
124 | +// // set speaker port to high |
||
125 | +// if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2 |
||
126 | +// else PORTC |= (1<<PORTC7); // Speaker at PC7 |
||
127 | +// } |
||
128 | +// else // beeper is off |
||
129 | { |
||
130 | - // set speaker port to high |
||
131 | - if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2 |
||
132 | - else PORTC |= (1<<PORTC7); // Speaker at PC7 |
||
133 | - } |
||
134 | - else // beeper is off |
||
135 | - { |
||
136 | // set speaker port to low |
||
137 | if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2 |
||
138 | else PORTC &= ~(1<<PORTC7);// Speaker at PC7 |
||
139 | Index: uart0.c |
||
140 | =================================================================== |
||
141 | --- uart0.c (revision 1255) |
||
142 | +++ uart0.c (working copy) |
||
143 | @@ -68,8 +68,11 @@ |
||
144 | #ifdef USE_MK3MAG |
||
145 | #include "mk3mag.h" |
||
146 | #endif |
||
147 | +#include "printf_P.h" |
||
148 | |||
149 | +#include "analog.h" |
||
150 | |||
151 | + |
||
152 | #define FC_ADDRESS 1 |
||
153 | #define NC_ADDRESS 2 |
||
154 | #define MK3MAG_ADDRESS 3 |
||
155 | @@ -117,6 +120,7 @@ |
||
156 | uint16_t Data3D_Timer; |
||
157 | uint16_t DebugData_Interval = 500; // in 1ms |
||
158 | uint16_t Data3D_Interval = 0; // in 1ms |
||
159 | +int16_t requestedVibData; |
||
160 | |||
161 | #ifdef USE_MK3MAG |
||
162 | int16_t Compass_Timer; |
||
163 | @@ -501,6 +505,26 @@ |
||
164 | PcAccess = 255; |
||
165 | break; |
||
166 | |||
167 | + case 'f': // VibrationTest |
||
168 | + { |
||
169 | + requestedVibData = pRxData[1]; |
||
170 | + if (requestedVibData == 0) |
||
171 | + { |
||
172 | +// int i; |
||
173 | + while(!txd_complete); // wait for previous frame to be sent |
||
174 | + //printf("VibTest Start...\r"); |
||
175 | + StartVibTest(pRxData[0] /*channel*/); |
||
176 | + while (VibTestCount); |
||
177 | + //printf("VibTest Done!\r"); |
||
178 | +// for (i=0;i<VIBTEST_NB_SAMPLES;i++) |
||
179 | +// VibTestData[i]=i; |
||
180 | + //printf("%d %d %d\r", VibTestData[0], VibTestData[1], VibTestData[2]); |
||
181 | + } |
||
182 | + //SendOutData('F', FC_ADDRESS, 1, &VibTestData[index*25], 50); |
||
183 | + |
||
184 | + } |
||
185 | + break; |
||
186 | + |
||
187 | case 'n':// "Get Mixer Table |
||
188 | while(!txd_complete); // wait for previous frame to be sent |
||
189 | SendOutData('N', FC_ADDRESS, 1, (uint8_t *) &Mixer, sizeof(Mixer)); |
||
190 | @@ -637,6 +661,7 @@ |
||
191 | loop_until_bit_is_set(UCSR0A, UDRE0); |
||
192 | // send character |
||
193 | UDR0 = c; |
||
194 | + loop_until_bit_is_set(UCSR0A, UDRE0); |
||
195 | return (0); |
||
196 | } |
||
197 | |||
198 | @@ -646,6 +671,11 @@ |
||
199 | { |
||
200 | if(!txd_complete) return; |
||
201 | |||
202 | + if (requestedVibData>=0 && txd_complete) |
||
203 | + { |
||
204 | + SendOutData('F', FC_ADDRESS, 1, &VibTestData[requestedVibData*50], 100); |
||
205 | + requestedVibData = -1; |
||
206 | + } |
||
207 | if(Request_VerInfo && txd_complete) |
||
208 | { |
||
209 | SendOutData('V', FC_ADDRESS, 1, (uint8_t *) &UART_VersionInfo, sizeof(UART_VersionInfo)); |