Subversion Repositories Projects

Rev

Rev 659 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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