Subversion Repositories Projects

Rev

Rev 631 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

Index: analog.c
===================================================================
--- analog.c    (revision 1255)
+++ analog.c    (working copy)
@@ -80,6 +80,40 @@
 int8_t ExpandBaro = 0;
 uint8_t PressureSensorOffset;
 
+#define AD_GYRO_YAW            0
+#define AD_GYRO_ROLL   1
+#define AD_GYRO_NICK   2
+#define AD_AIRPRESS            3
+#define AD_UBAT                        4
+#define AD_ACC_TOP             5
+#define AD_ACC_ROLL            6
+#define AD_ACC_NICK            7
+
+
+int VibTestData[VIBTEST_NB_SAMPLES];
+volatile unsigned int VibTestCount;
+volatile unsigned int VibTestDone;
+int* VibTestDataP;
+uint8_t VibTestChannel;
+
+
+void StartVibTest(uint8_t channel)
+{
+       VibTestChannel = channel;
+       VibTestDataP = VibTestData;
+       VibTestCount = VIBTEST_NB_SAMPLES;
+       ADMUX = AD_ACC_ROLL;
+       VibTestDone = 0;
+
+       ADC_Enable();
+
+       while(!VibTestDone);
+
+       if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2
+       else                   PORTC &= ~(1<<PORTC7);// Speaker at PC7
+
+}
+
 /*****************************************************/
 /*     Initialize Analog Digital Converter           */
 /*****************************************************/
@@ -202,15 +236,8 @@
 */
 
 
-#define AD_GYRO_YAW            0
-#define AD_GYRO_ROLL   1
-#define AD_GYRO_NICK   2
-#define AD_AIRPRESS            3
-#define AD_UBAT                        4
-#define AD_ACC_TOP             5
-#define AD_ACC_ROLL            6
-#define AD_ACC_NICK            7
 
+
 ISR(ADC_vect)
 {
     static uint8_t ad_channel = AD_GYRO_NICK, state = 0;
@@ -218,6 +245,24 @@
     static int32_t filtergyronick, filtergyroroll;
     static int16_t tmpAirPressure = 0;
 
+    if (VibTestCount)
+       {
+               *(VibTestDataP++) = ADC;
+               ADMUX = VibTestChannel;
+               ADC_Enable();
+
+               // set speaker port to high
+               if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2
+               else                   PORTC |= (1<<PORTC7); // Speaker at PC7
+
+
+               VibTestCount--;
+
+               return;
+       }
+
+    VibTestDone = 1;
+
     // state machine
        switch(state++)
        {
Index: analog.h
===================================================================
--- analog.h    (revision 1255)
+++ analog.h    (working copy)
@@ -25,7 +25,12 @@
 void SearchDacGyroOffset(void);
 void ADC_Init(void);
 
+#define VIBTEST_NB_SAMPLES 1000
+extern int VibTestData[VIBTEST_NB_SAMPLES];
+extern volatile unsigned int VibTestCount;
+void StartVibTest(uint8_t channel);
 
+
 // clear ADC enable & ADC Start Conversion & ADC Interrupt Enable bit
 #define ADC_Disable() (ADCSRA &= ~((1<<ADEN)|(1<<ADSC)|(1<<ADIE)))
 // set ADC enable & ADC Start Conversion & ADC Interrupt Enable bit
Index: makefile
===================================================================
--- makefile    (revision 1255)
+++ makefile    (working copy)
@@ -50,63 +50,8 @@
 # Output format. (can be srec, ihex, binary)
 FORMAT = ihex
 
-# Target file name (without extension).
+TARGET = Flight-Ctrl_MEGA644p_VibrationTest
 
-ifeq ($(VERSION_PATCH), 0)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 1)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 2)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 3)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 4)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 5)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 6)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 7)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 8)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 9)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 10)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 11)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)l_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 12)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)m_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 13)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)n_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 14)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)o_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 15)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)p_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 16)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)q_SVN$(REV)
-endif
-ifeq ($(VERSION_PATCH), 17)
-TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)r_SVN$(REV)
-endif
-
 # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
 OPT = 2
Index: menu.c
===================================================================
--- menu.c      (revision 1255)
+++ menu.c      (working copy)
@@ -139,9 +139,10 @@
        switch(MenuItem)
        {
        case 0:// Version Info Menu Item
-               LCD_printfxy(0,0,"+ MikroKopter +");
-               LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a');
-               LCD_printfxy(0,2,"Setting: %d %s", GetActiveParamSet(), Mixer.Name);
+               LCD_printfxy(0,0,"MK ==VIBR TEST==");
+               LCD_printfxy(0,1,"    v0.9 RC4    ");
+               LCD_printfxy(0,2,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a');
+               //LCD_printfxy(0,2,"Setting: %d %s", GetActiveParamSet(), Mixer.Name);
                if(I2CTimeout < 6)
                {
                        LCD_printfxy(0,3,"I2C Error!!!");
Index: timer0.c
===================================================================
--- timer0.c    (revision 1255)
+++ timer0.c    (working copy)
@@ -173,18 +173,18 @@
        }
 
        // if beeper is on
-       if(Beeper_On)
-       {
-               // set speaker port to high
-               if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2
-               else                   PORTC |= (1<<PORTC7); // Speaker at PC7
-       }
-       else // beeper is off
-       {
-               // set speaker port to low
-               if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2
-               else                   PORTC &= ~(1<<PORTC7);// Speaker at PC7
-       }
+//     if(Beeper_On)
+//     {
+//             // set speaker port to high
+//             if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2
+//             else                   PORTC |= (1<<PORTC7); // Speaker at PC7
+//     }
+//     else // beeper is off
+//     {
+//             // set speaker port to low
+//             if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2
+//             else                   PORTC &= ~(1<<PORTC7);// Speaker at PC7
+//     }
 
        #ifndef USE_NAVICTRL
        // update compass value if this option is enabled in the settings
Index: twimaster.c
===================================================================
--- twimaster.c (revision 1255)
+++ twimaster.c (working copy)
@@ -211,7 +211,7 @@
                // Master Transmit
         case 0: // TWI_STATE_MOTOR_TX
                        // skip motor if not used in mixer
-                       while((Mixer.Motor[motor_write][MIX_GAS] <= 0) && (motor_write < MAX_MOTORS)) motor_write++;
+                       //while((Mixer.Motor[motor_write][MIX_GAS] <= 0) && (motor_write < MAX_MOTORS)) motor_write++;
                        if(motor_write >= MAX_MOTORS) // writing finished, read now
                        {
                                        motor_write = 0;
Index: uart0.c
===================================================================
--- uart0.c     (revision 1255)
+++ uart0.c     (working copy)
@@ -68,8 +68,11 @@
 #ifdef USE_MK3MAG
 #include "mk3mag.h"
 #endif
+#include "printf_P.h"
 
+#include "analog.h"
 
+
 #define FC_ADDRESS 1
 #define NC_ADDRESS 2
 #define MK3MAG_ADDRESS 3
@@ -117,6 +120,7 @@
 uint16_t Data3D_Timer;
 uint16_t DebugData_Interval = 500; // in 1ms
 uint16_t Data3D_Interval = 0; // in 1ms
+int16_t requestedVibData;
 
 #ifdef USE_MK3MAG
 int16_t Compass_Timer;
@@ -491,6 +495,7 @@
                                if(RxDataLen > 20) //
                                {
                                        memcpy(&MotorTest[0], (uint8_t*)pRxData, sizeof(MotorTest));
+                                       //MotorTest[0] = MotorTest[4];
                                }
                                else
                                {
@@ -501,6 +506,28 @@
                                PcAccess = 255;
                                break;
 
+                       case 'f':       // VibrationTest
+                               {
+                                       requestedVibData = pRxData[1];
+                                       if (requestedVibData == 0)
+                                       {
+//                                             while(!txd_complete); // wait for previous frame to be sent
+
+//                                             printf("VibTest Start...\r");
+                                               StartVibTest(pRxData[0] /*channel*/);
+//                                             printf("VibTest Done!\r");
+
+//                                             {
+//                                                     int i;
+//                                                     for (i=0;i<VIBTEST_NB_SAMPLES;i++)
+//                                                             VibTestData[i]=i;
+//                                             }
+                                       }
+                                       if (MotorTest_Active)
+                                               MotorTest_Active = 255; // Extend motor test Timeout
+                               }
+                               break;
+
                        case 'n':// "Get Mixer Table
                                while(!txd_complete); // wait for previous frame to be sent
                                SendOutData('N', FC_ADDRESS, 1, (uint8_t *) &Mixer, sizeof(Mixer));
@@ -637,6 +664,7 @@
        loop_until_bit_is_set(UCSR0A, UDRE0);
        // send character
        UDR0 = c;
+       loop_until_bit_is_set(UCSR0A, UDRE0);
        return (0);
 }
 
@@ -646,6 +674,11 @@
 {
        if(!txd_complete) return;
 
+       if (requestedVibData>=0 && txd_complete)
+       {
+               SendOutData('F', FC_ADDRESS, 1, &VibTestData[requestedVibData*50], 100);
+               requestedVibData = -1;
+       }
        if(Request_VerInfo && txd_complete)
        {
                SendOutData('V', FC_ADDRESS, 1, (uint8_t *) &UART_VersionInfo, sizeof(UART_VersionInfo));