From 7ccdb296ac0f7e440477a465c8df3ee4ca6ae60c Mon Sep 17 00:00:00 2001 From: peabody124 Date: Tue, 28 Dec 2010 17:48:45 +0000 Subject: [PATCH] AHRS: Add interface to get old dump_raw function working for Pip git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2305 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/AHRS/ahrs.c | 22 +++++++++---------- flight/AHRS/ahrs_adc.c | 8 +++++++ flight/AHRS/inc/ahrs_adc.h | 1 + .../OpenPilotOSX.xcodeproj/project.pbxproj | 6 +++-- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/flight/AHRS/ahrs.c b/flight/AHRS/ahrs.c index 5295c0126..a735b31b2 100644 --- a/flight/AHRS/ahrs.c +++ b/flight/AHRS/ahrs.c @@ -49,7 +49,6 @@ // For debugging the raw sensors //#define DUMP_RAW -//#define DUMP_FRIENDLY //#define DUMP_EKF volatile int8_t ahrs_algorithm; @@ -418,29 +417,30 @@ void print_ekf_binary() {} */ void print_ahrs_raw() { - /*int result; + int result; static int previous_conversion = 0; - + int16_t * valid_data_buffer; + uint8_t framing[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; - while (ahrs_state != AHRS_DATA_READY) ; - ahrs_state = AHRS_PROCESSING; + get_accel_gyro_data(); + + valid_data_buffer = AHRS_ADC_GetRawBuffer(); + if (total_conversion_blocks != previous_conversion + 1) PIOS_LED_On(LED1); // not keeping up else PIOS_LED_Off(LED1); previous_conversion = total_conversion_blocks; - downsample_data(); - ahrs_state = AHRS_IDLE;; // Dump raw buffer - result = PIOS_COM_SendBuffer(PIOS_COM_AUX, &framing[0], 16); // framing header - result += PIOS_COM_SendBuffer(PIOS_COM_AUX, (uint8_t *) & total_conversion_blocks, sizeof(total_conversion_blocks)); // dump block number + result = PIOS_COM_SendBufferNonBlocking(PIOS_COM_AUX, &framing[0], 16); // framing header + result += PIOS_COM_SendBufferNonBlocking(PIOS_COM_AUX, (uint8_t *) & total_conversion_blocks, sizeof(total_conversion_blocks)); // dump block number result += - PIOS_COM_SendBuffer(PIOS_COM_AUX, + PIOS_COM_SendBufferNonBlocking(PIOS_COM_AUX, (uint8_t *) & valid_data_buffer[0], adc_oversampling * PIOS_ADC_NUM_PINS * @@ -449,7 +449,7 @@ void print_ahrs_raw() PIOS_LED_Off(LED1); else { PIOS_LED_On(LED1); - } */ + } } /** diff --git a/flight/AHRS/ahrs_adc.c b/flight/AHRS/ahrs_adc.c index b5c427a86..6834d2251 100644 --- a/flight/AHRS/ahrs_adc.c +++ b/flight/AHRS/ahrs_adc.c @@ -218,6 +218,14 @@ float * AHRS_ADC_GetBuffer() return downsampled_buffer; } +/** + * @brief Return the address of the raw data data buffer + */ +int16_t * AHRS_ADC_GetRawBuffer() +{ + return (int16_t *) adc_config.valid_data_buffer; +} + /** * @brief Set the fir coefficients. Takes as many samples as the * current filter order plus one (normalization) diff --git a/flight/AHRS/inc/ahrs_adc.h b/flight/AHRS/inc/ahrs_adc.h index c925a124d..a0b01d878 100644 --- a/flight/AHRS/inc/ahrs_adc.h +++ b/flight/AHRS/inc/ahrs_adc.h @@ -48,5 +48,6 @@ void AHRS_ADC_DMA_Handler(void); void AHRS_ADC_SetCallback(ADCCallback); void AHRS_ADC_SetFIRCoefficients(float * new_filter); float * AHRS_ADC_GetBuffer(); +int16_t * AHRS_ADC_GetRawBuffer(); #endif diff --git a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj index fa1a4a3f2..57b4b01df 100644 --- a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj +++ b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj @@ -10,6 +10,8 @@ 65003B2D1212499100C183DD /* watchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = watchdog.h; sourceTree = ""; }; 65003B2E1212499100C183DD /* watchdog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = watchdog.c; sourceTree = ""; }; 65003B31121249CA00C183DD /* pios_wdg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_wdg.c; sourceTree = ""; }; + 6502584212CA4D2600583CDF /* insgps13state.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = insgps13state.c; path = ../../AHRS/insgps13state.c; sourceTree = SOURCE_ROOT; }; + 6509C7E912CA57DC002E5DC2 /* insgps16state.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = insgps16state.c; path = ../../AHRS/insgps16state.c; sourceTree = SOURCE_ROOT; }; 651913371256C5240039C0A3 /* ahrs_comm_objects.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ahrs_comm_objects.c; sourceTree = ""; }; 651913381256C5240039C0A3 /* ahrs_spi_comm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ahrs_spi_comm.c; sourceTree = ""; }; 6519133A1256C52B0039C0A3 /* ahrs_comm_objects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ahrs_comm_objects.h; sourceTree = ""; }; @@ -36,7 +38,6 @@ 65322D77122897210046CD7C /* MagOrAccelSensorCal.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = MagOrAccelSensorCal.c; path = ../../AHRS/MagOrAccelSensorCal.c; sourceTree = SOURCE_ROOT; }; 65345C871288668B00A5E4E8 /* guidancesettings.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = guidancesettings.xml; sourceTree = ""; }; 65408AA812BB1648004DACC5 /* i2cstats.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = i2cstats.xml; sourceTree = ""; }; - 654330231218E9780063F913 /* insgps.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = insgps.c; path = ../../AHRS/insgps.c; sourceTree = SOURCE_ROOT; }; 6543304F121980300063F913 /* insgps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = insgps.h; sourceTree = ""; }; 654612D812B5E9A900B719D0 /* pios_iap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_iap.c; sourceTree = ""; }; 6549E0D21279B3C800C5476F /* fifo_buffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fifo_buffer.c; sourceTree = ""; }; @@ -6808,8 +6809,9 @@ 65B7E6AC120DF1CD000C1123 /* AHRS */ = { isa = PBXGroup; children = ( + 6509C7E912CA57DC002E5DC2 /* insgps16state.c */, + 6502584212CA4D2600583CDF /* insgps13state.c */, 65322D77122897210046CD7C /* MagOrAccelSensorCal.c */, - 654330231218E9780063F913 /* insgps.c */, 65FC65BE123F209400B04F74 /* ahrs_adc.c */, 65FC66AA123F30F100B04F74 /* ahrs_timer.c */, 65B7E6AE120DF1E2000C1123 /* ahrs.c */,