1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

Merge remote-tracking branch 'raid/Brian-PipXtreme-V2' into Brian-PipXtreme-V2

This commit is contained in:
Brian Webb 2012-04-06 17:44:18 -07:00
commit fb47537d8b
3 changed files with 85 additions and 32 deletions

View File

@ -277,10 +277,7 @@ static int32_t transmitData(uint8_t *buf, int32_t length)
*/
static int32_t transmitPacket(PHPacketHandle p)
{
static uint32_t cntr = 0;
DEBUG_PRINTF(2, "Sending: %d %d\n\r", p->header.data_size, cntr++);
int32_t ret = PIOS_COM_SendBuffer(data->radio_port, (uint8_t*)p, PH_PACKET_SIZE(p));
return ret;
return PIOS_COM_SendBuffer(data->radio_port, (uint8_t*)p, PH_PACKET_SIZE(p));
}
/**
@ -290,7 +287,6 @@ static int32_t transmitPacket(PHPacketHandle p)
*/
static void receiveData(uint8_t *buf, uint8_t len)
{
DEBUG_PRINTF(2, "Received: %d\n\r", len);
/* Send the received data to the com port */
if (PIOS_COM_SendBuffer(data->com_port, buf, len) != len)
/* Error on transmit */

View File

@ -177,6 +177,44 @@ extern uint32_t pios_com_rfm22b_id;
#endif
#define RFM22_DEBUG 1
//-------------------------
// ADC
// None
//-------------------------
//#define PIOS_ADC_OVERSAMPLING_RATE 1
#define PIOS_ADC_USE_TEMP_SENSOR 0
#define PIOS_ADC_TEMP_SENSOR_ADC ADC1
#define PIOS_ADC_TEMP_SENSOR_ADC_CHANNEL 1
#define PIOS_ADC_NUM_PINS 0
#define PIOS_ADC_PORTS { }
#define PIOS_ADC_PINS { }
#define PIOS_ADC_CHANNELS { }
#define PIOS_ADC_MAPPING { }
#define PIOS_ADC_CHANNEL_MAPPING { }
#define PIOS_ADC_NUM_CHANNELS (PIOS_ADC_NUM_PINS + PIOS_ADC_USE_TEMP_SENSOR)
#define PIOS_ADC_NUM_ADC_CHANNELS 0
#define PIOS_ADC_USE_ADC2 0
#define PIOS_ADC_CLOCK_FUNCTION RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, ENABLE)
#define PIOS_ADC_ADCCLK RCC_PCLK2_Div8
/* RCC_PCLK2_Div2: ADC clock = PCLK2/2 */
/* RCC_PCLK2_Div4: ADC clock = PCLK2/4 */
/* RCC_PCLK2_Div6: ADC clock = PCLK2/6 */
/* RCC_PCLK2_Div8: ADC clock = PCLK2/8 */
#define PIOS_ADC_SAMPLE_TIME ADC_SampleTime_239Cycles5
/* Sample time: */
/* With an ADCCLK = 14 MHz and a sampling time of 239.5 cycles: */
/* Tconv = 239.5 + 12.5 = 252 cycles = 18<31>s */
/* (1 / (ADCCLK / CYCLES)) = Sample Time (<28>S) */
#define PIOS_ADC_IRQ_PRIO PIOS_IRQ_PRIO_LOW
// Currently analog acquistion hard coded at 480 Hz
// PCKL2 = HCLK / 16
// ADCCLK = PCLK2 / 2
#define PIOS_ADC_RATE (72.0e6 / 1.0 / 8.0 / 252.0 / (PIOS_ADC_NUM_CHANNELS >> PIOS_ADC_USE_ADC2))
#define PIOS_ADC_MAX_OVERSAMPLING 36
//------------------------
// PIOS_RCVR
// See also pios_board.c

View File

@ -848,41 +848,60 @@ void rfm22_setDatarate(uint32_t datarate_bps, bool data_whitening)
uint32_t modulation_bandwidth = datarate_bps + (2 * frequency_deviation);
#endif
rfm22_write(0x1C, reg_1C[lookup_index]); // rfm22_if_filter_bandwidth
// rfm22_if_filter_bandwidth
rfm22_write(0x1C, reg_1C[lookup_index]);
rfm22_write(0x1D, reg_1D[lookup_index]); // rfm22_afc_loop_gearshift_override
rfm22_write(0x1E, reg_1E[lookup_index]); // RFM22_afc_timing_control
// rfm22_afc_loop_gearshift_override
rfm22_write(0x1D, reg_1D[lookup_index]);
// RFM22_afc_timing_control
rfm22_write(0x1E, reg_1E[lookup_index]);
rfm22_write(0x1F, reg_1F[lookup_index]); // RFM22_clk_recovery_gearshift_override
rfm22_write(0x20, reg_20[lookup_index]); // rfm22_clk_recovery_oversampling_ratio
rfm22_write(0x21, reg_21[lookup_index]); // rfm22_clk_recovery_offset2
rfm22_write(0x22, reg_22[lookup_index]); // rfm22_clk_recovery_offset1
rfm22_write(0x23, reg_23[lookup_index]); // rfm22_clk_recovery_offset0
rfm22_write(0x24, reg_24[lookup_index]); // rfm22_clk_recovery_timing_loop_gain1
rfm22_write(0x25, reg_25[lookup_index]); // rfm22_clk_recovery_timing_loop_gain0
// RFM22_clk_recovery_gearshift_override
rfm22_write(0x1F, reg_1F[lookup_index]);
// rfm22_clk_recovery_oversampling_ratio
rfm22_write(0x20, reg_20[lookup_index]);
// rfm22_clk_recovery_offset2
rfm22_write(0x21, reg_21[lookup_index]);
// rfm22_clk_recovery_offset1
rfm22_write(0x22, reg_22[lookup_index]);
// rfm22_clk_recovery_offset0
rfm22_write(0x23, reg_23[lookup_index]);
// rfm22_clk_recovery_timing_loop_gain1
rfm22_write(0x24, reg_24[lookup_index]);
// rfm22_clk_recovery_timing_loop_gain0
rfm22_write(0x25, reg_25[lookup_index]);
rfm22_write(0x2A, reg_2A[lookup_index]); // rfm22_afc_limiter
// rfm22_afc_limiter
rfm22_write(0x2A, reg_2A[lookup_index]);
if (carrier_datarate_bps < 100000)
rfm22_write(0x58, 0x80); // rfm22_chargepump_current_trimming_override
// rfm22_chargepump_current_trimming_override
rfm22_write(0x58, 0x80);
else
rfm22_write(0x58, 0xC0); // rfm22_chargepump_current_trimming_override
// rfm22_chargepump_current_trimming_override
rfm22_write(0x58, 0xC0);
rfm22_write(0x6E, reg_6E[lookup_index]); // rfm22_tx_data_rate1
rfm22_write(0x6F, reg_6F[lookup_index]); // rfm22_tx_data_rate0
// rfm22_tx_data_rate1
rfm22_write(0x6E, reg_6E[lookup_index]);
// rfm22_tx_data_rate0
rfm22_write(0x6F, reg_6F[lookup_index]);
// Enable data whitening
// uint8_t txdtrtscale_bit = rfm22_read(RFM22_modulation_mode_control1) & RFM22_mmc1_txdtrtscale;
// rfm22_write(RFM22_modulation_mode_control1, txdtrtscale_bit | RFM22_mmc1_enwhite);
if (!data_whitening)
rfm22_write(0x70, reg_70[lookup_index] & ~RFM22_mmc1_enwhite); // rfm22_modulation_mode_control1
// rfm22_modulation_mode_control1
rfm22_write(0x70, reg_70[lookup_index] & ~RFM22_mmc1_enwhite);
else
rfm22_write(0x70, reg_70[lookup_index] | RFM22_mmc1_enwhite); // rfm22_modulation_mode_control1
// rfm22_modulation_mode_control1
rfm22_write(0x70, reg_70[lookup_index] | RFM22_mmc1_enwhite);
rfm22_write(0x71, reg_71[lookup_index]); // rfm22_modulation_mode_control2
// rfm22_modulation_mode_control2
rfm22_write(0x71, reg_71[lookup_index]);
rfm22_write(0x72, reg_72[lookup_index]); // rfm22_frequency_deviation
// rfm22_frequency_deviation
rfm22_write(0x72, reg_72[lookup_index]);
rfm22_write(RFM22_ook_counter_value1, 0x00);
rfm22_write(RFM22_ook_counter_value2, 0x00);
@ -923,13 +942,17 @@ void rfm22_setDatarate(uint32_t datarate_bps, bool data_whitening)
// ********************************
// determine suitable time-out periods
timeout_sync_ms = (8000ul * 16) / carrier_datarate_bps; // milliseconds
// milliseconds
timeout_sync_ms = (8000ul * 16) / carrier_datarate_bps;
if (timeout_sync_ms < 3)
timeout_sync_ms = 3; // because out timer resolution is only 1ms
// because out timer resolution is only 1ms
timeout_sync_ms = 3;
timeout_data_ms = (8000ul * 100) / carrier_datarate_bps; // milliseconds
// milliseconds
timeout_data_ms = (8000ul * 100) / carrier_datarate_bps;
if (timeout_data_ms < 3)
timeout_data_ms = 3; // because out timer resolution is only 1ms
// because out timer resolution is only 1ms
timeout_data_ms = 3;
// ********************************
@ -1332,7 +1355,6 @@ void rfm22_processRxInt(void)
RX_LED_ON;
rfm22_setDebug("sync_det");
#ifdef NEVER
// read the 10-bit signed afc correction value
// bits 9 to 2
afc_correction = (uint16_t)rfm22_read(RFM22_afc_correction_read) << 8;
@ -1346,7 +1368,6 @@ void rfm22_processRxInt(void)
rx_packet_start_rssi_dBm = rssi_dBm;
// remember the afc value for this packet
rx_packet_start_afc_Hz = afc_correction_Hz;
#endif
}
}
@ -1554,7 +1575,6 @@ void rfm22_processInt(void)
// read device status register
device_status = rfm22_read(RFM22_device_status);
#ifdef NEVER
// read ezmac status register
ezmac_status = rfm22_read(RFM22_ezmac_status);
@ -1576,7 +1596,6 @@ void rfm22_processInt(void)
// read the tx power register
tx_pwr = rfm22_read(RFM22_tx_power);
}
#endif
// the RF module has gone and done a reset - we need to re-initialize the rf module
if (int_status2 & RFM22_is2_ipor)