Rev 583 | Rev 659 | Go to most recent revision | Details | Compare with Previous | 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) |
||
583 | FredericG | 5 | @@ -80,6 +80,40 @@ |
555 | FredericG | 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; |
||
583 | FredericG | 21 | +volatile unsigned int VibTestDone; |
555 | FredericG | 22 | +int* VibTestDataP; |
23 | +uint8_t VibTestChannel; |
||
24 | + |
||
25 | + |
||
26 | +void StartVibTest(uint8_t channel) |
||
27 | +{ |
||
28 | + VibTestChannel = channel; |
||
29 | + VibTestDataP = VibTestData; |
||
30 | + VibTestCount = VIBTEST_NB_SAMPLES; |
||
31 | + ADMUX = AD_ACC_ROLL; |
||
583 | FredericG | 32 | + VibTestDone = 0; |
33 | + |
||
555 | FredericG | 34 | + ADC_Enable(); |
583 | FredericG | 35 | + |
36 | + while(!VibTestDone); |
||
37 | + |
||
38 | + if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2 |
||
39 | + else PORTC &= ~(1<<PORTC7);// Speaker at PC7 |
||
40 | + |
||
555 | FredericG | 41 | +} |
42 | + |
||
43 | /*****************************************************/ |
||
44 | /* Initialize Analog Digital Converter */ |
||
45 | /*****************************************************/ |
||
583 | FredericG | 46 | @@ -202,15 +236,8 @@ |
555 | FredericG | 47 | */ |
48 | |||
49 | |||
50 | -#define AD_GYRO_YAW 0 |
||
51 | -#define AD_GYRO_ROLL 1 |
||
52 | -#define AD_GYRO_NICK 2 |
||
53 | -#define AD_AIRPRESS 3 |
||
54 | -#define AD_UBAT 4 |
||
55 | -#define AD_ACC_TOP 5 |
||
56 | -#define AD_ACC_ROLL 6 |
||
57 | -#define AD_ACC_NICK 7 |
||
58 | |||
59 | + |
||
60 | ISR(ADC_vect) |
||
61 | { |
||
62 | static uint8_t ad_channel = AD_GYRO_NICK, state = 0; |
||
583 | FredericG | 63 | @@ -218,6 +245,24 @@ |
555 | FredericG | 64 | static int32_t filtergyronick, filtergyroroll; |
65 | static int16_t tmpAirPressure = 0; |
||
66 | |||
67 | + if (VibTestCount) |
||
68 | + { |
||
69 | + *(VibTestDataP++) = ADC; |
||
70 | + ADMUX = VibTestChannel; |
||
583 | FredericG | 71 | + ADC_Enable(); |
72 | + |
||
73 | + // set speaker port to high |
||
74 | + if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2 |
||
75 | + else PORTC |= (1<<PORTC7); // Speaker at PC7 |
||
76 | + |
||
77 | + |
||
555 | FredericG | 78 | + VibTestCount--; |
583 | FredericG | 79 | + |
555 | FredericG | 80 | + return; |
81 | + } |
||
82 | + |
||
583 | FredericG | 83 | + VibTestDone = 1; |
84 | + |
||
555 | FredericG | 85 | // state machine |
86 | switch(state++) |
||
87 | { |
||
88 | Index: analog.h |
||
89 | =================================================================== |
||
90 | --- analog.h (revision 1255) |
||
91 | +++ analog.h (working copy) |
||
92 | @@ -25,7 +25,12 @@ |
||
93 | void SearchDacGyroOffset(void); |
||
94 | void ADC_Init(void); |
||
95 | |||
96 | +#define VIBTEST_NB_SAMPLES 1000 |
||
97 | +extern int VibTestData[VIBTEST_NB_SAMPLES]; |
||
98 | +extern volatile unsigned int VibTestCount; |
||
99 | +void StartVibTest(uint8_t channel); |
||
100 | |||
101 | + |
||
102 | // clear ADC enable & ADC Start Conversion & ADC Interrupt Enable bit |
||
103 | #define ADC_Disable() (ADCSRA &= ~((1<<ADEN)|(1<<ADSC)|(1<<ADIE))) |
||
104 | // set ADC enable & ADC Start Conversion & ADC Interrupt Enable bit |
||
568 | FredericG | 105 | Index: makefile |
555 | FredericG | 106 | =================================================================== |
568 | FredericG | 107 | --- makefile (revision 1255) |
108 | +++ makefile (working copy) |
||
109 | @@ -50,63 +50,8 @@ |
||
110 | # Output format. (can be srec, ihex, binary) |
||
111 | FORMAT = ihex |
||
555 | FredericG | 112 | |
568 | FredericG | 113 | -# Target file name (without extension). |
114 | +TARGET = Flight-Ctrl_MEGA644p_VibrationTest |
||
115 | |||
116 | -ifeq ($(VERSION_PATCH), 0) |
||
117 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV) |
||
118 | -endif |
||
119 | -ifeq ($(VERSION_PATCH), 1) |
||
120 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV) |
||
121 | -endif |
||
122 | -ifeq ($(VERSION_PATCH), 2) |
||
123 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV) |
||
124 | -endif |
||
125 | -ifeq ($(VERSION_PATCH), 3) |
||
126 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d_SVN$(REV) |
||
127 | -endif |
||
128 | -ifeq ($(VERSION_PATCH), 4) |
||
129 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e_SVN$(REV) |
||
130 | -endif |
||
131 | -ifeq ($(VERSION_PATCH), 5) |
||
132 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f_SVN$(REV) |
||
133 | -endif |
||
134 | -ifeq ($(VERSION_PATCH), 6) |
||
135 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g_SVN$(REV) |
||
136 | -endif |
||
137 | -ifeq ($(VERSION_PATCH), 7) |
||
138 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h_SVN$(REV) |
||
139 | -endif |
||
140 | -ifeq ($(VERSION_PATCH), 8) |
||
141 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i_SVN$(REV) |
||
142 | -endif |
||
143 | -ifeq ($(VERSION_PATCH), 9) |
||
144 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j_SVN$(REV) |
||
145 | -endif |
||
146 | -ifeq ($(VERSION_PATCH), 10) |
||
147 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k_SVN$(REV) |
||
148 | -endif |
||
149 | -ifeq ($(VERSION_PATCH), 11) |
||
150 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)l_SVN$(REV) |
||
151 | -endif |
||
152 | -ifeq ($(VERSION_PATCH), 12) |
||
153 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)m_SVN$(REV) |
||
154 | -endif |
||
155 | -ifeq ($(VERSION_PATCH), 13) |
||
156 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)n_SVN$(REV) |
||
157 | -endif |
||
158 | -ifeq ($(VERSION_PATCH), 14) |
||
159 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)o_SVN$(REV) |
||
160 | -endif |
||
161 | -ifeq ($(VERSION_PATCH), 15) |
||
162 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)p_SVN$(REV) |
||
163 | -endif |
||
164 | -ifeq ($(VERSION_PATCH), 16) |
||
165 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)q_SVN$(REV) |
||
166 | -endif |
||
167 | -ifeq ($(VERSION_PATCH), 17) |
||
168 | -TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)r_SVN$(REV) |
||
169 | -endif |
||
170 | - |
||
171 | # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
||
172 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
||
173 | OPT = 2 |
||
555 | FredericG | 174 | Index: menu.c |
175 | =================================================================== |
||
176 | --- menu.c (revision 1255) |
||
177 | +++ menu.c (working copy) |
||
178 | @@ -139,7 +139,7 @@ |
||
179 | switch(MenuItem) |
||
180 | { |
||
181 | case 0:// Version Info Menu Item |
||
182 | - LCD_printfxy(0,0,"+ MikroKopter +"); |
||
568 | FredericG | 183 | + LCD_printfxy(0,0,"MK ==VIBR TEST=="); |
555 | FredericG | 184 | LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
185 | LCD_printfxy(0,2,"Setting: %d %s", GetActiveParamSet(), Mixer.Name); |
||
186 | if(I2CTimeout < 6) |
||
187 | Index: timer0.c |
||
188 | =================================================================== |
||
189 | --- timer0.c (revision 1255) |
||
190 | +++ timer0.c (working copy) |
||
583 | FredericG | 191 | @@ -173,18 +173,18 @@ |
555 | FredericG | 192 | } |
193 | |||
194 | // if beeper is on |
||
195 | - if(Beeper_On) |
||
583 | FredericG | 196 | - { |
197 | - // set speaker port to high |
||
198 | - if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2 |
||
199 | - else PORTC |= (1<<PORTC7); // Speaker at PC7 |
||
200 | - } |
||
201 | - else // beeper is off |
||
202 | - { |
||
203 | - // set speaker port to low |
||
204 | - if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2 |
||
205 | - else PORTC &= ~(1<<PORTC7);// Speaker at PC7 |
||
206 | - } |
||
555 | FredericG | 207 | +// if(Beeper_On) |
208 | +// { |
||
209 | +// // set speaker port to high |
||
210 | +// if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2 |
||
211 | +// else PORTC |= (1<<PORTC7); // Speaker at PC7 |
||
212 | +// } |
||
213 | +// else // beeper is off |
||
583 | FredericG | 214 | +// { |
215 | +// // set speaker port to low |
||
216 | +// if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2 |
||
217 | +// else PORTC &= ~(1<<PORTC7);// Speaker at PC7 |
||
218 | +// } |
||
219 | |||
220 | #ifndef USE_NAVICTRL |
||
221 | // update compass value if this option is enabled in the settings |
||
555 | FredericG | 222 | Index: uart0.c |
223 | =================================================================== |
||
224 | --- uart0.c (revision 1255) |
||
225 | +++ uart0.c (working copy) |
||
226 | @@ -68,8 +68,11 @@ |
||
227 | #ifdef USE_MK3MAG |
||
228 | #include "mk3mag.h" |
||
229 | #endif |
||
230 | +#include "printf_P.h" |
||
231 | |||
232 | +#include "analog.h" |
||
233 | |||
234 | + |
||
235 | #define FC_ADDRESS 1 |
||
236 | #define NC_ADDRESS 2 |
||
237 | #define MK3MAG_ADDRESS 3 |
||
238 | @@ -117,6 +120,7 @@ |
||
239 | uint16_t Data3D_Timer; |
||
240 | uint16_t DebugData_Interval = 500; // in 1ms |
||
241 | uint16_t Data3D_Interval = 0; // in 1ms |
||
242 | +int16_t requestedVibData; |
||
243 | |||
244 | #ifdef USE_MK3MAG |
||
245 | int16_t Compass_Timer; |
||
631 | FredericG | 246 | @@ -501,6 +505,28 @@ |
555 | FredericG | 247 | PcAccess = 255; |
248 | break; |
||
249 | |||
250 | + case 'f': // VibrationTest |
||
251 | + { |
||
252 | + requestedVibData = pRxData[1]; |
||
253 | + if (requestedVibData == 0) |
||
254 | + { |
||
583 | FredericG | 255 | +// while(!txd_complete); // wait for previous frame to be sent |
256 | + |
||
257 | +// printf("VibTest Start...\r"); |
||
555 | FredericG | 258 | + StartVibTest(pRxData[0] /*channel*/); |
583 | FredericG | 259 | +// printf("VibTest Done!\r"); |
260 | + |
||
261 | +// { |
||
262 | +// int i; |
||
263 | +// for (i=0;i<VIBTEST_NB_SAMPLES;i++) |
||
264 | +// VibTestData[i]=i; |
||
265 | +// } |
||
555 | FredericG | 266 | + } |
631 | FredericG | 267 | + if (MotorTest_Active) |
268 | + MotorTest_Active = 255; // Extend motor test Timeout |
||
555 | FredericG | 269 | + } |
270 | + break; |
||
271 | + |
||
272 | case 'n':// "Get Mixer Table |
||
273 | while(!txd_complete); // wait for previous frame to be sent |
||
274 | SendOutData('N', FC_ADDRESS, 1, (uint8_t *) &Mixer, sizeof(Mixer)); |
||
631 | FredericG | 275 | @@ -637,6 +663,7 @@ |
555 | FredericG | 276 | loop_until_bit_is_set(UCSR0A, UDRE0); |
277 | // send character |
||
278 | UDR0 = c; |
||
279 | + loop_until_bit_is_set(UCSR0A, UDRE0); |
||
280 | return (0); |
||
281 | } |
||
282 | |||
631 | FredericG | 283 | @@ -646,6 +673,11 @@ |
555 | FredericG | 284 | { |
285 | if(!txd_complete) return; |
||
286 | |||
287 | + if (requestedVibData>=0 && txd_complete) |
||
288 | + { |
||
289 | + SendOutData('F', FC_ADDRESS, 1, &VibTestData[requestedVibData*50], 100); |
||
290 | + requestedVibData = -1; |
||
291 | + } |
||
292 | if(Request_VerInfo && txd_complete) |
||
293 | { |
||
294 | SendOutData('V', FC_ADDRESS, 1, (uint8_t *) &UART_VersionInfo, sizeof(UART_VersionInfo)); |