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) |
||
659 | FredericG | 178 | @@ -139,9 +139,10 @@ |
555 | FredericG | 179 | switch(MenuItem) |
180 | { |
||
181 | case 0:// Version Info Menu Item |
||
182 | - LCD_printfxy(0,0,"+ MikroKopter +"); |
||
659 | FredericG | 183 | - LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
184 | - LCD_printfxy(0,2,"Setting: %d %s", GetActiveParamSet(), Mixer.Name); |
||
568 | FredericG | 185 | + LCD_printfxy(0,0,"MK ==VIBR TEST=="); |
666 | FredericG | 186 | + LCD_printfxy(0,1," v1.0 "); |
659 | FredericG | 187 | + LCD_printfxy(0,2,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
188 | + //LCD_printfxy(0,2,"Setting: %d %s", GetActiveParamSet(), Mixer.Name); |
||
555 | FredericG | 189 | if(I2CTimeout < 6) |
659 | FredericG | 190 | { |
191 | LCD_printfxy(0,3,"I2C Error!!!"); |
||
555 | FredericG | 192 | Index: timer0.c |
193 | =================================================================== |
||
194 | --- timer0.c (revision 1255) |
||
195 | +++ timer0.c (working copy) |
||
583 | FredericG | 196 | @@ -173,18 +173,18 @@ |
555 | FredericG | 197 | } |
198 | |||
199 | // if beeper is on |
||
200 | - if(Beeper_On) |
||
583 | FredericG | 201 | - { |
202 | - // set speaker port to high |
||
203 | - if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2 |
||
204 | - else PORTC |= (1<<PORTC7); // Speaker at PC7 |
||
205 | - } |
||
206 | - else // beeper is off |
||
207 | - { |
||
208 | - // set speaker port to low |
||
209 | - if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2 |
||
210 | - else PORTC &= ~(1<<PORTC7);// Speaker at PC7 |
||
211 | - } |
||
555 | FredericG | 212 | +// if(Beeper_On) |
213 | +// { |
||
214 | +// // set speaker port to high |
||
215 | +// if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2 |
||
216 | +// else PORTC |= (1<<PORTC7); // Speaker at PC7 |
||
217 | +// } |
||
218 | +// else // beeper is off |
||
583 | FredericG | 219 | +// { |
220 | +// // set speaker port to low |
||
221 | +// if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2 |
||
222 | +// else PORTC &= ~(1<<PORTC7);// Speaker at PC7 |
||
223 | +// } |
||
224 | |||
225 | #ifndef USE_NAVICTRL |
||
226 | // update compass value if this option is enabled in the settings |
||
659 | FredericG | 227 | Index: twimaster.c |
228 | =================================================================== |
||
229 | --- twimaster.c (revision 1255) |
||
230 | +++ twimaster.c (working copy) |
||
231 | @@ -211,7 +211,7 @@ |
||
232 | // Master Transmit |
||
233 | case 0: // TWI_STATE_MOTOR_TX |
||
234 | // skip motor if not used in mixer |
||
235 | - while((Mixer.Motor[motor_write][MIX_GAS] <= 0) && (motor_write < MAX_MOTORS)) motor_write++; |
||
236 | + //while((Mixer.Motor[motor_write][MIX_GAS] <= 0) && (motor_write < MAX_MOTORS)) motor_write++; |
||
237 | if(motor_write >= MAX_MOTORS) // writing finished, read now |
||
238 | { |
||
239 | motor_write = 0; |
||
555 | FredericG | 240 | Index: uart0.c |
241 | =================================================================== |
||
242 | --- uart0.c (revision 1255) |
||
243 | +++ uart0.c (working copy) |
||
244 | @@ -68,8 +68,11 @@ |
||
245 | #ifdef USE_MK3MAG |
||
246 | #include "mk3mag.h" |
||
247 | #endif |
||
248 | +#include "printf_P.h" |
||
249 | |||
250 | +#include "analog.h" |
||
251 | |||
252 | + |
||
253 | #define FC_ADDRESS 1 |
||
254 | #define NC_ADDRESS 2 |
||
255 | #define MK3MAG_ADDRESS 3 |
||
256 | @@ -117,6 +120,7 @@ |
||
257 | uint16_t Data3D_Timer; |
||
258 | uint16_t DebugData_Interval = 500; // in 1ms |
||
259 | uint16_t Data3D_Interval = 0; // in 1ms |
||
260 | +int16_t requestedVibData; |
||
261 | |||
262 | #ifdef USE_MK3MAG |
||
263 | int16_t Compass_Timer; |
||
659 | FredericG | 264 | @@ -491,6 +495,7 @@ |
265 | if(RxDataLen > 20) // |
||
266 | { |
||
267 | memcpy(&MotorTest[0], (uint8_t*)pRxData, sizeof(MotorTest)); |
||
268 | + //MotorTest[0] = MotorTest[4]; |
||
269 | } |
||
270 | else |
||
271 | { |
||
272 | @@ -501,6 +506,28 @@ |
||
555 | FredericG | 273 | PcAccess = 255; |
274 | break; |
||
275 | |||
276 | + case 'f': // VibrationTest |
||
277 | + { |
||
278 | + requestedVibData = pRxData[1]; |
||
279 | + if (requestedVibData == 0) |
||
280 | + { |
||
583 | FredericG | 281 | +// while(!txd_complete); // wait for previous frame to be sent |
282 | + |
||
283 | +// printf("VibTest Start...\r"); |
||
555 | FredericG | 284 | + StartVibTest(pRxData[0] /*channel*/); |
583 | FredericG | 285 | +// printf("VibTest Done!\r"); |
286 | + |
||
287 | +// { |
||
288 | +// int i; |
||
289 | +// for (i=0;i<VIBTEST_NB_SAMPLES;i++) |
||
290 | +// VibTestData[i]=i; |
||
291 | +// } |
||
555 | FredericG | 292 | + } |
631 | FredericG | 293 | + if (MotorTest_Active) |
294 | + MotorTest_Active = 255; // Extend motor test Timeout |
||
555 | FredericG | 295 | + } |
296 | + break; |
||
297 | + |
||
298 | case 'n':// "Get Mixer Table |
||
299 | while(!txd_complete); // wait for previous frame to be sent |
||
300 | SendOutData('N', FC_ADDRESS, 1, (uint8_t *) &Mixer, sizeof(Mixer)); |
||
659 | FredericG | 301 | @@ -637,6 +664,7 @@ |
555 | FredericG | 302 | loop_until_bit_is_set(UCSR0A, UDRE0); |
303 | // send character |
||
304 | UDR0 = c; |
||
305 | + loop_until_bit_is_set(UCSR0A, UDRE0); |
||
306 | return (0); |
||
307 | } |
||
308 | |||
659 | FredericG | 309 | @@ -646,6 +674,11 @@ |
555 | FredericG | 310 | { |
311 | if(!txd_complete) return; |
||
312 | |||
313 | + if (requestedVibData>=0 && txd_complete) |
||
314 | + { |
||
315 | + SendOutData('F', FC_ADDRESS, 1, &VibTestData[requestedVibData*50], 100); |
||
316 | + requestedVibData = -1; |
||
317 | + } |
||
318 | if(Request_VerInfo && txd_complete) |
||
319 | { |
||
320 | SendOutData('V', FC_ADDRESS, 1, (uint8_t *) &UART_VersionInfo, sizeof(UART_VersionInfo)); |