Rev 568 |
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,31 @@
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;
+int* VibTestDataP;
+uint8_t VibTestChannel;
+
+
+void StartVibTest(uint8_t channel)
+{
+ VibTestChannel = channel;
+ VibTestDataP = VibTestData;
+ VibTestCount = VIBTEST_NB_SAMPLES;
+ ADMUX = AD_ACC_ROLL;
+ ADC_Enable();
+}
+
/*****************************************************/
/* Initialize Analog Digital Converter */
/*****************************************************/
@@ -202,15 +227,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 +236,15 @@
static int32_t filtergyronick, filtergyroroll;
static int16_t tmpAirPressure = 0;
+ if (VibTestCount)
+ {
+ *(VibTestDataP++) = ADC;
+ ADMUX = VibTestChannel;
+ VibTestCount--;
+ ADC_Enable();
+ return;
+ }
+
// 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: main.c
===================================================================
--- main.c (revision 1255)
+++ main.c (working copy)
@@ -175,7 +175,7 @@
sei();
printf("\n\r===================================");
- printf("\n\rFlightControl");
+ printf("\n\rFlightControl FRED");
printf("\n\rHardware: %d.%d", BoardRelease/10, BoardRelease%10);
if(CPUType == ATMEGA644P)
printf("\r\n CPU: Atmega644p");
Index: menu.c
===================================================================
--- menu.c (revision 1255)
+++ menu.c (working copy)
@@ -139,7 +139,7 @@
switch(MenuItem)
{
case 0:// Version Info Menu Item
- LCD_printfxy(0,0,"+ MikroKopter +");
+ LCD_printfxy(0,0,"+ MikroKopter F");
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);
if(I2CTimeout < 6)
Index: timer0.c
===================================================================
--- timer0.c (revision 1255)
+++ timer0.c (working copy)
@@ -173,14 +173,14 @@
}
// if beeper is on
- if(Beeper_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 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
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;
@@ -501,6 +505,26 @@
PcAccess = 255;
break;
+ case 'f': // VibrationTest
+ {
+ requestedVibData = pRxData[1];
+ if (requestedVibData == 0)
+ {
+// int i;
+ while(!txd_complete); // wait for previous frame to be sent
+ //printf("VibTest Start...\r");
+ StartVibTest(pRxData[0] /*channel*/);
+ while (VibTestCount);
+ //printf("VibTest Done!\r");
+// for (i=0;i<VIBTEST_NB_SAMPLES;i++)
+// VibTestData[i]=i;
+ //printf("%d %d %d\r", VibTestData[0], VibTestData[1], VibTestData[2]);
+ }
+ //SendOutData('F', FC_ADDRESS, 1, &VibTestData[index*25], 50);
+
+ }
+ 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 +661,7 @@
loop_until_bit_is_set(UCSR0A, UDRE0);
// send character
UDR0 = c;
+ loop_until_bit_is_set(UCSR0A, UDRE0);
return (0);
}
@@ -646,6 +671,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));