From 7bfb58ce739f6b49651fcd95ba1f751d9bfec84e Mon Sep 17 00:00:00 2001 From: pip Date: Sun, 27 Feb 2011 13:13:10 +0000 Subject: [PATCH] clean up git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2903 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/PipXtreme/main.c | 8 ++++---- flight/PipXtreme/rfm22b.c | 27 +++++++++++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/flight/PipXtreme/main.c b/flight/PipXtreme/main.c index 1b7e10ca2..53d6f9187 100644 --- a/flight/PipXtreme/main.c +++ b/flight/PipXtreme/main.c @@ -323,10 +323,10 @@ void init_RF_module(void) default: #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF("UNKNOWN BAND ERROR\r\n", i); + DEBUG_PRINTF("UNKNOWN BAND ERROR\r\n\r\n", i); #endif - for (int j = 0; j < 8; j++) + for (int j = 0; j < 16; j++) { USB_LED_ON; LINK_LED_OFF; @@ -359,10 +359,10 @@ void init_RF_module(void) { // RF module error .. flash the LED's #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF("RF ERROR res: %d\r\n", i); + DEBUG_PRINTF("RF ERROR res: %d\r\n\r\n", i); #endif - for (int j = 0; j < 6; j++) + for (int j = 0; j < 16; j++) { USB_LED_ON; LINK_LED_ON; diff --git a/flight/PipXtreme/rfm22b.c b/flight/PipXtreme/rfm22b.c index 636f95bff..9c42e1d58 100644 --- a/flight/PipXtreme/rfm22b.c +++ b/flight/PipXtreme/rfm22b.c @@ -1854,6 +1854,11 @@ int rfm22_resetModule(uint8_t mode) // set SPI port SCLK frequency .. 4.5MHz PIOS_SPI_SetClockSpeed(RFM22_PIOS_SPI, PIOS_SPI_PRESCALER_16); + // set SPI port SCLK frequency .. 2.25MHz +// PIOS_SPI_SetClockSpeed(RFM22_PIOS_SPI, PIOS_SPI_PRESCALER_32); + + // set SPI port SCLK frequency .. 285kHz .. purely for hardware fault finding +// PIOS_SPI_SetClockSpeed(RFM22_PIOS_SPI, PIOS_SPI_PRESCALER_256); // **************** // software reset the RF chip .. following procedure according to Si4x3x Errata (rev. B) @@ -1941,22 +1946,32 @@ int rfm22_resetModule(uint8_t mode) // read the RF chip ID bytes device_type = rfm22_read(RFM22_DEVICE_TYPE) & RFM22_DT_MASK; // read the device type + device_version = rfm22_read(RFM22_DEVICE_VERSION) & RFM22_DV_MASK; // read the device version + #if defined(RFM22_DEBUG) DEBUG_PRINTF("rf device type: %d\r\n", device_type); - #endif - if (device_type != 0x08) - return -1; // incorrect RF module type - - device_version = rfm22_read(RFM22_DEVICE_VERSION) & RFM22_DV_MASK; // read the device version - #if defined(RFM22_DEBUG) DEBUG_PRINTF("rf device version: %d\r\n", device_version); #endif + + if (device_type != 0x08) + { + #if defined(RFM22_DEBUG) + DEBUG_PRINTF("rf device type: INCORRECT - should be 0x08\r\n"); + #endif + return -1; // incorrect RF module type + } + // if (device_version != RFM22_DEVICE_VERSION_V2) // V2 // return -2; // incorrect RF module version // if (device_version != RFM22_DEVICE_VERSION_A0) // A0 // return -2; // incorrect RF module version if (device_version != RFM22_DEVICE_VERSION_B1) // B1 + { + #if defined(RFM22_DEBUG) + DEBUG_PRINTF("rf device version: INCORRECT\r\n"); + #endif return -2; // incorrect RF module version + } // ****************