1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Removes several of the air datarate settings, and fine tunes the calculation of the max packet length from the datarate and packet time. 9600, 19200, 36400, and 57600 modes tested. Tested 19200 in one-way mode for PPM only.

This commit is contained in:
Brian Webb 2013-06-17 19:19:35 -07:00
parent f8d60e6dee
commit 61c453f6ff
3 changed files with 31 additions and 44 deletions

View File

@ -294,33 +294,33 @@ static const struct pios_rfm22b_transition rfm22b_transitions[RADIO_STATE_NUM_ST
}; };
// xtal 10 ppm, 434MHz // xtal 10 ppm, 434MHz
static const uint32_t data_rate[] = { 500, 1000, 2000, 4000, 8000, 9600, 16000, 19200, 24000, 32000, 57600, 64000, 128000, 192000, 256000 }; static const uint32_t data_rate[] = { 9600, 19200, 32000, 57600, 64000, 128000, 192000, 256000 };
static const uint8_t modulation_index[] = { 16, 8, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; static const uint8_t modulation_index[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
static const uint8_t reg_1C[] = { 0x37, 0x37, 0x37, 0x37, 0x3A, 0x01, 0x26, 0x28, 0x2E, 0x16, 0x06, 0x07, 0x83, 0x8A, 0x8C }; // rfm22_if_filter_bandwidth static const uint8_t reg_1C[] = { 0x01, 0x28, 0x16, 0x06, 0x07, 0x83, 0x8A, 0x8C }; // rfm22_if_filter_bandwidth
static const uint8_t reg_1D[] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x40, 0x44, 0x44, 0x44, 0x44, 0x40, 0x44, 0x44, 0x44, 0x44 }; // rfm22_afc_loop_gearshift_override static const uint8_t reg_1D[] = { 0x40, 0x44, 0x44, 0x40, 0x44, 0x44, 0x44, 0x44 }; // rfm22_afc_loop_gearshift_override
static const uint8_t reg_1E[] = { 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x02 }; // rfm22_afc_timing_control static const uint8_t reg_1E[] = { 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x02 }; // rfm22_afc_timing_control
static const uint8_t reg_1F[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; // rfm22_clk_recovery_gearshift_override static const uint8_t reg_1F[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; // rfm22_clk_recovery_gearshift_override
static const uint8_t reg_20[] = { 0xE8, 0xF4, 0xFA, 0x70, 0x3F, 0xA1, 0x3F, 0x34, 0x2A, 0x3F, 0x45, 0x3F, 0x5E, 0x3F, 0x2F }; // rfm22_clk_recovery_oversampling_ratio static const uint8_t reg_20[] = { 0xA1, 0x34, 0x3F, 0x45, 0x3F, 0x5E, 0x3F, 0x2F }; // rfm22_clk_recovery_oversampling_ratio
static const uint8_t reg_21[] = { 0x60, 0x20, 0x00, 0x01, 0x02, 0x20, 0x02, 0x02, 0x03, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02 }; // rfm22_clk_recovery_offset2 static const uint8_t reg_21[] = { 0x20, 0x02, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02 }; // rfm22_clk_recovery_offset2
static const uint8_t reg_22[] = { 0x20, 0x41, 0x83, 0x06, 0x0C, 0x4E, 0x0C, 0x75, 0x12, 0x0C, 0xD7, 0x0c, 0x5D, 0x0C, 0xBB }; // rfm22_clk_recovery_offset1 static const uint8_t reg_22[] = { 0x4E, 0x75, 0x0C, 0xD7, 0x0c, 0x5D, 0x0C, 0xBB }; // rfm22_clk_recovery_offset1
static const uint8_t reg_23[] = { 0xC5, 0x89, 0x12, 0x25, 0x4A, 0xA5, 0x4A, 0x25, 0x6F, 0x4A, 0xDC, 0x4A, 0x86, 0x4A, 0x0D }; // rfm22_clk_recovery_offset0 static const uint8_t reg_23[] = { 0xA5, 0x25, 0x4A, 0xDC, 0x4A, 0x86, 0x4A, 0x0D }; // rfm22_clk_recovery_offset0
static const uint8_t reg_24[] = { 0x00, 0x00, 0x00, 0x02, 0x07, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x07, 0x07 }; // rfm22_clk_recovery_timing_loop_gain1 static const uint8_t reg_24[] = { 0x00, 0x07, 0x07, 0x07, 0x07, 0x05, 0x07, 0x07 }; // rfm22_clk_recovery_timing_loop_gain1
static const uint8_t reg_25[] = { 0x0A, 0x23, 0x85, 0x0E, 0xFF, 0x34, 0xFF, 0xFF, 0xFF, 0xFF, 0x6E, 0xFF, 0x74, 0xFF, 0xFF }; // rfm22_clk_recovery_timing_loop_gain0 static const uint8_t reg_25[] = { 0x34, 0xFF, 0xFF, 0x6E, 0xFF, 0x74, 0xFF, 0xFF }; // rfm22_clk_recovery_timing_loop_gain0
static const uint8_t reg_2A[] = { 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x1E, 0x0D, 0x0E, 0x12, 0x17, 0x2D, 0x31, 0x50, 0x50, 0x50 }; // rfm22_afc_limiter .. AFC_pull_in_range = <20>AFCLimiter[7:0] x (hbsel+1) x 625 Hz static const uint8_t reg_2A[] = { 0x1E, 0x0E, 0x17, 0x2D, 0x31, 0x50, 0x50, 0x50 }; // rfm22_afc_limiter .. AFC_pull_in_range = <20>AFCLimiter[7:0] x (hbsel+1) x 625 Hz
static const uint8_t reg_58[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; // rfm22_cpcuu static const uint8_t reg_58[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; // rfm22_cpcuu
static const uint8_t reg_69[] = { 0x20, 0x20, 0x20, 0x20, 0x20, 0x60, 0x20, 0x20, 0x20, 0x20, 0x60, 0x20, 0x20, 0x20, 0x20 }; // rfm22_agc_override1 static const uint8_t reg_69[] = { 0x60, 0x20, 0x20, 0x60, 0x20, 0x20, 0x20, 0x20 }; // rfm22_agc_override1
static const uint8_t reg_6E[] = { 0x04, 0x08, 0x10, 0x20, 0x41, 0x4E, 0x83, 0x9D, 0xC4, 0x08, 0x0E, 0x10, 0x20, 0x31, 0x41 }; // rfm22_tx_data_rate1 static const uint8_t reg_6E[] = { 0x4E, 0x9D, 0x08, 0x0E, 0x10, 0x20, 0x31, 0x41 }; // rfm22_tx_data_rate1
static const uint8_t reg_6F[] = { 0x19, 0x31, 0x62, 0xC5, 0x89, 0xA5, 0x12, 0x49, 0x9C, 0x31, 0xBF, 0x62, 0xC5, 0x27, 0x89 }; // rfm22_tx_data_rate0 static const uint8_t reg_6F[] = { 0xA5, 0x49, 0x31, 0xBF, 0x62, 0xC5, 0x27, 0x89 }; // rfm22_tx_data_rate0
static const uint8_t reg_70[] = { 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2C, 0x2D, 0x2D, 0x2D, 0x0D, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D }; // rfm22_modulation_mode_control1 static const uint8_t reg_70[] = { 0x2C, 0x2D, 0x0D, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D }; // rfm22_modulation_mode_control1
static const uint8_t reg_71[] = { 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23 }; // rfm22_modulation_mode_control2 static const uint8_t reg_71[] = { 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23 }; // rfm22_modulation_mode_control2
static const uint8_t reg_72[] = { 0x06, 0x06, 0x06, 0x06, 0x06, 0x30, 0x0D, 0x0F, 0x13, 0x1A, 0x2E, 0x33, 0x66, 0x9A, 0xCD }; // rfm22_frequency_deviation static const uint8_t reg_72[] = { 0x30, 0x0F, 0x1A, 0x2E, 0x33, 0x66, 0x9A, 0xCD }; // rfm22_frequency_deviation
static struct pios_rfm22b_dev *g_rfm22b_dev = NULL; static struct pios_rfm22b_dev *g_rfm22b_dev = NULL;
@ -1446,7 +1446,7 @@ static void pios_rfm22_setDatarate(struct pios_rfm22b_dev *rfm22b_dev)
uint32_t datarate_bps = data_rate[datarate]; uint32_t datarate_bps = data_rate[datarate];
// Calculate the maximum packet length from the datarate. // Calculate the maximum packet length from the datarate.
float bytes_per_period = (float)datarate_bps * (float)(rfm22b_dev->packet_period) / 8000; float bytes_per_period = (float)datarate_bps * (float)(rfm22b_dev->packet_period) / 9000;
rfm22b_dev->max_packet_len = bytes_per_period - TX_PREAMBLE_NIBBLES / 2 - SYNC_BYTES - HEADER_BYTES - 5; rfm22b_dev->max_packet_len = bytes_per_period - TX_PREAMBLE_NIBBLES / 2 - SYNC_BYTES - HEADER_BYTES - 5;
if (rfm22b_dev->max_packet_len > RFM22B_MAX_PACKET_LEN) { if (rfm22b_dev->max_packet_len > RFM22B_MAX_PACKET_LEN) {

View File

@ -67,14 +67,8 @@ static void PIOS_RFM22B_COM_ChangeBaud(uint32_t rfm22b_id, uint32_t baud)
} }
// Set the RF data rate on the modem to ~2X the selected buad rate because the modem is half duplex. // Set the RF data rate on the modem to ~2X the selected buad rate because the modem is half duplex.
enum rfm22b_datarate datarate = RFM22_datarate_64000; enum rfm22b_datarate datarate = RFM22_datarate_64000;
if (baud <= 1024) { if (baud <= 9600) {
datarate = RFM22_datarate_500; datarate = RFM22_datarate_19200;
} else if (baud <= 2048) {
datarate = RFM22_datarate_1000;
} else if (baud <= 4096) {
datarate = RFM22_datarate_8000;
} else if (baud <= 9600) {
datarate = RFM22_datarate_16000;
} else if (baud <= 19200) { } else if (baud <= 19200) {
datarate = RFM22_datarate_32000; datarate = RFM22_datarate_32000;
} else if (baud <= 38400) { } else if (baud <= 38400) {

View File

@ -58,21 +58,14 @@ enum rfm22b_tx_power {
}; };
enum rfm22b_datarate { enum rfm22b_datarate {
RFM22_datarate_500 = 0, RFM22_datarate_9600 = 0,
RFM22_datarate_1000 = 1, RFM22_datarate_19200 = 1,
RFM22_datarate_2000 = 2, RFM22_datarate_32000 = 2,
RFM22_datarate_4000 = 3, RFM22_datarate_57600 = 3,
RFM22_datarate_8000 = 4, RFM22_datarate_64000 = 4,
RFM22_datarate_9600 = 5, RFM22_datarate_128000 = 5,
RFM22_datarate_16000 = 6, RFM22_datarate_192000 = 6,
RFM22_datarate_19200 = 7, RFM22_datarate_256000 = 7,
RFM22_datarate_24000 = 8,
RFM22_datarate_32000 = 9,
RFM22_datarate_57600 = 10,
RFM22_datarate_64000 = 11,
RFM22_datarate_128000 = 12,
RFM22_datarate_192000 = 13,
RFM22_datarate_256000 = 14,
}; };
typedef enum { typedef enum {