Subversion Repositories Projects

Rev

Rev 555 | Rev 583 | 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)
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
568 FredericG 87
Index: makefile
555 FredericG 88
===================================================================
568 FredericG 89
--- makefile    (revision 1255)
90
+++ makefile    (working copy)
91
@@ -50,63 +50,8 @@
92
 # Output format. (can be srec, ihex, binary)
93
 FORMAT = ihex
555 FredericG 94
 
568 FredericG 95
-# Target file name (without extension).
96
+TARGET = Flight-Ctrl_MEGA644p_VibrationTest
97
 
98
-ifeq ($(VERSION_PATCH), 0)
99
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV)
100
-endif
101
-ifeq ($(VERSION_PATCH), 1)
102
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV)
103
-endif
104
-ifeq ($(VERSION_PATCH), 2)
105
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV)
106
-endif
107
-ifeq ($(VERSION_PATCH), 3)
108
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d_SVN$(REV)
109
-endif
110
-ifeq ($(VERSION_PATCH), 4)
111
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e_SVN$(REV)
112
-endif
113
-ifeq ($(VERSION_PATCH), 5)
114
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f_SVN$(REV)
115
-endif
116
-ifeq ($(VERSION_PATCH), 6)
117
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g_SVN$(REV)
118
-endif
119
-ifeq ($(VERSION_PATCH), 7)
120
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h_SVN$(REV)
121
-endif
122
-ifeq ($(VERSION_PATCH), 8)
123
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i_SVN$(REV)
124
-endif
125
-ifeq ($(VERSION_PATCH), 9)
126
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j_SVN$(REV)
127
-endif
128
-ifeq ($(VERSION_PATCH), 10)
129
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k_SVN$(REV)
130
-endif
131
-ifeq ($(VERSION_PATCH), 11)
132
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)l_SVN$(REV)
133
-endif
134
-ifeq ($(VERSION_PATCH), 12)
135
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)m_SVN$(REV)
136
-endif
137
-ifeq ($(VERSION_PATCH), 13)
138
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)n_SVN$(REV)
139
-endif
140
-ifeq ($(VERSION_PATCH), 14)
141
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)o_SVN$(REV)
142
-endif
143
-ifeq ($(VERSION_PATCH), 15)
144
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)p_SVN$(REV)
145
-endif
146
-ifeq ($(VERSION_PATCH), 16)
147
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)q_SVN$(REV)
148
-endif
149
-ifeq ($(VERSION_PATCH), 17)
150
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)r_SVN$(REV)
151
-endif
152
-
153
 # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
154
 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
155
 OPT = 2
555 FredericG 156
Index: menu.c
157
===================================================================
158
--- menu.c      (revision 1255)
159
+++ menu.c      (working copy)
160
@@ -139,7 +139,7 @@
161
        switch(MenuItem)
162
        {
163
        case 0:// Version Info Menu Item
164
-               LCD_printfxy(0,0,"+ MikroKopter +");
568 FredericG 165
+               LCD_printfxy(0,0,"MK ==VIBR TEST==");
555 FredericG 166
                LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a');
167
                LCD_printfxy(0,2,"Setting: %d %s", GetActiveParamSet(), Mixer.Name);
168
                if(I2CTimeout < 6)
169
Index: timer0.c
170
===================================================================
171
--- timer0.c    (revision 1255)
172
+++ timer0.c    (working copy)
173
@@ -173,14 +173,14 @@
174
        }
175
 
176
        // if beeper is on
177
-       if(Beeper_On)
178
+//     if(Beeper_On)
179
+//     {
180
+//             // set speaker port to high
181
+//             if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2
182
+//             else                   PORTC |= (1<<PORTC7); // Speaker at PC7
183
+//     }
184
+//     else // beeper is off
185
        {
186
-               // set speaker port to high
187
-               if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2
188
-               else                   PORTC |= (1<<PORTC7); // Speaker at PC7
189
-       }
190
-       else // beeper is off
191
-       {
192
                // set speaker port to low
193
                if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2
194
                else                   PORTC &= ~(1<<PORTC7);// Speaker at PC7
195
Index: uart0.c
196
===================================================================
197
--- uart0.c     (revision 1255)
198
+++ uart0.c     (working copy)
199
@@ -68,8 +68,11 @@
200
 #ifdef USE_MK3MAG
201
 #include "mk3mag.h"
202
 #endif
203
+#include "printf_P.h"
204
 
205
+#include "analog.h"
206
 
207
+
208
 #define FC_ADDRESS 1
209
 #define NC_ADDRESS 2
210
 #define MK3MAG_ADDRESS 3
211
@@ -117,6 +120,7 @@
212
 uint16_t Data3D_Timer;
213
 uint16_t DebugData_Interval = 500; // in 1ms
214
 uint16_t Data3D_Interval = 0; // in 1ms
215
+int16_t requestedVibData;
216
 
217
 #ifdef USE_MK3MAG
218
 int16_t Compass_Timer;
219
@@ -501,6 +505,26 @@
220
                                PcAccess = 255;
221
                                break;
222
 
223
+                       case 'f':       // VibrationTest
224
+                               {
225
+                                       requestedVibData = pRxData[1];
226
+                                       if (requestedVibData == 0)
227
+                                       {
568 FredericG 228
+                                               int i;
555 FredericG 229
+                                               while(!txd_complete); // wait for previous frame to be sent
230
+                                               //printf("VibTest Start...\r");
231
+                                               StartVibTest(pRxData[0] /*channel*/);
232
+                                               while (VibTestCount);
233
+                                               //printf("VibTest Done!\r");
234
+//                                             for (i=0;i<VIBTEST_NB_SAMPLES;i++)
235
+//                                                     VibTestData[i]=i;
236
+                                               //printf("%d %d %d\r", VibTestData[0], VibTestData[1], VibTestData[2]);
237
+                                       }
238
+                                       //SendOutData('F', FC_ADDRESS, 1, &VibTestData[index*25], 50);
239
+
240
+                               }
241
+                               break;
242
+
243
                        case 'n':// "Get Mixer Table
244
                                while(!txd_complete); // wait for previous frame to be sent
245
                                SendOutData('N', FC_ADDRESS, 1, (uint8_t *) &Mixer, sizeof(Mixer));
246
@@ -637,6 +661,7 @@
247
        loop_until_bit_is_set(UCSR0A, UDRE0);
248
        // send character
249
        UDR0 = c;
250
+       loop_until_bit_is_set(UCSR0A, UDRE0);
251
        return (0);
252
 }
253
 
254
@@ -646,6 +671,11 @@
255
 {
256
        if(!txd_complete) return;
257
 
258
+       if (requestedVibData>=0 && txd_complete)
259
+       {
260
+               SendOutData('F', FC_ADDRESS, 1, &VibTestData[requestedVibData*50], 100);
261
+               requestedVibData = -1;
262
+       }
263
        if(Request_VerInfo && txd_complete)
264
        {
265
                SendOutData('V', FC_ADDRESS, 1, (uint8_t *) &UART_VersionInfo, sizeof(UART_VersionInfo));