mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
RM2/RM1: Make the firmware and bootloader support the pin mappings between these two targets
for USB and radio A side-effect of this is the pipxsettings are no longer populated into the rfm22b cfg structure as that was made constant to be consistent with other drivers.
This commit is contained in:
parent
1dae196274
commit
879dfed288
@ -62,7 +62,7 @@ void PIOS_Board_Init() {
|
||||
PIOS_USB_DESC_HID_ONLY_Init();
|
||||
|
||||
uint32_t pios_usb_id;
|
||||
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
|
||||
PIOS_USB_Init(&pios_usb_id, PIOS_BOARD_HW_DEFS_GetUsbCfg(bdinfo->board_rev));
|
||||
|
||||
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
|
||||
uint32_t pios_usb_hid_id;
|
||||
|
@ -28,6 +28,8 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <pios.h>
|
||||
#include <pios_board_info.h>
|
||||
#include <openpilot.h>
|
||||
#include <gcsreceiver.h>
|
||||
#include <hwsettings.h>
|
||||
@ -120,8 +122,11 @@ static RadioData *data = 0;
|
||||
uint32_t pios_rfm22b_id = 0;
|
||||
uint32_t pios_com_rfm22b_id = 0;
|
||||
uint32_t pios_packet_handler = 0;
|
||||
extern struct pios_rfm22b_cfg pios_rfm22b_cfg;
|
||||
const struct pios_rfm22b_cfg *pios_rfm22b_cfg;
|
||||
|
||||
// ***************
|
||||
// External functions
|
||||
extern const struct pios_rfm22b_cfg * PIOS_BOARD_HW_DEFS_GetRfm22Cfg (uint32_t board_revision);
|
||||
|
||||
/**
|
||||
* Start the module
|
||||
@ -177,62 +182,70 @@ static int32_t RadioInitialize(void)
|
||||
PipXSettingsGet(&pipxSettings);
|
||||
|
||||
/* Retrieve hardware settings. */
|
||||
pios_rfm22b_cfg.frequencyHz = pipxSettings.Frequency;
|
||||
pios_rfm22b_cfg.RFXtalCap = pipxSettings.FrequencyCalibration;
|
||||
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||
pios_rfm22b_cfg = PIOS_BOARD_HW_DEFS_GetRfm22Cfg(bdinfo->board_rev);
|
||||
|
||||
// Not appropriate for a constant struct. Is it necessary to make a local copy of the cfg?
|
||||
// We should probably be consistent with other drivers and allocate a device structure with
|
||||
// dynamical configuration in it
|
||||
#if 0
|
||||
pios_rfm22b_cfg->frequencyHz = pipxSettings.Frequency;
|
||||
pios_rfm22b_cfg->RFXtalCap = pipxSettings.FrequencyCalibration;
|
||||
switch (pipxSettings.RFSpeed)
|
||||
{
|
||||
case PIPXSETTINGS_RFSPEED_2400:
|
||||
pios_rfm22b_cfg.maxRFBandwidth = 2000;
|
||||
pios_rfm22b_cfg->maxRFBandwidth = 2000;
|
||||
break;
|
||||
case PIPXSETTINGS_RFSPEED_4800:
|
||||
pios_rfm22b_cfg.maxRFBandwidth = 4000;
|
||||
pios_rfm22b_cfg->maxRFBandwidth = 4000;
|
||||
break;
|
||||
case PIPXSETTINGS_RFSPEED_9600:
|
||||
pios_rfm22b_cfg.maxRFBandwidth = 9600;
|
||||
pios_rfm22b_cfg->maxRFBandwidth = 9600;
|
||||
break;
|
||||
case PIPXSETTINGS_RFSPEED_19200:
|
||||
pios_rfm22b_cfg.maxRFBandwidth = 19200;
|
||||
pios_rfm22b_cfg->maxRFBandwidth = 19200;
|
||||
break;
|
||||
case PIPXSETTINGS_RFSPEED_38400:
|
||||
pios_rfm22b_cfg.maxRFBandwidth = 32000;
|
||||
pios_rfm22b_cfg->maxRFBandwidth = 32000;
|
||||
break;
|
||||
case PIPXSETTINGS_RFSPEED_57600:
|
||||
pios_rfm22b_cfg.maxRFBandwidth = 64000;
|
||||
pios_rfm22b_cfg->maxRFBandwidth = 64000;
|
||||
break;
|
||||
case PIPXSETTINGS_RFSPEED_115200:
|
||||
pios_rfm22b_cfg.maxRFBandwidth = 128000;
|
||||
pios_rfm22b_cfg->maxRFBandwidth = 128000;
|
||||
break;
|
||||
}
|
||||
switch (pipxSettings.MaxRFPower)
|
||||
{
|
||||
case PIPXSETTINGS_MAXRFPOWER_125:
|
||||
pios_rfm22b_cfg.maxTxPower = RFM22_tx_pwr_txpow_0;
|
||||
pios_rfm22b_cfg->maxTxPower = RFM22_tx_pwr_txpow_0;
|
||||
break;
|
||||
case PIPXSETTINGS_MAXRFPOWER_16:
|
||||
pios_rfm22b_cfg.maxTxPower = RFM22_tx_pwr_txpow_1;
|
||||
pios_rfm22b_cfg->maxTxPower = RFM22_tx_pwr_txpow_1;
|
||||
break;
|
||||
case PIPXSETTINGS_MAXRFPOWER_316:
|
||||
pios_rfm22b_cfg.maxTxPower = RFM22_tx_pwr_txpow_2;
|
||||
pios_rfm22b_cfg->maxTxPower = RFM22_tx_pwr_txpow_2;
|
||||
break;
|
||||
case PIPXSETTINGS_MAXRFPOWER_63:
|
||||
pios_rfm22b_cfg.maxTxPower = RFM22_tx_pwr_txpow_3;
|
||||
pios_rfm22b_cfg->maxTxPower = RFM22_tx_pwr_txpow_3;
|
||||
break;
|
||||
case PIPXSETTINGS_MAXRFPOWER_126:
|
||||
pios_rfm22b_cfg.maxTxPower = RFM22_tx_pwr_txpow_4;
|
||||
pios_rfm22b_cfg->maxTxPower = RFM22_tx_pwr_txpow_4;
|
||||
break;
|
||||
case PIPXSETTINGS_MAXRFPOWER_25:
|
||||
pios_rfm22b_cfg.maxTxPower = RFM22_tx_pwr_txpow_5;
|
||||
pios_rfm22b_cfg->maxTxPower = RFM22_tx_pwr_txpow_5;
|
||||
break;
|
||||
case PIPXSETTINGS_MAXRFPOWER_50:
|
||||
pios_rfm22b_cfg.maxTxPower = RFM22_tx_pwr_txpow_6;
|
||||
pios_rfm22b_cfg->maxTxPower = RFM22_tx_pwr_txpow_6;
|
||||
break;
|
||||
case PIPXSETTINGS_MAXRFPOWER_100:
|
||||
pios_rfm22b_cfg.maxTxPower = RFM22_tx_pwr_txpow_7;
|
||||
pios_rfm22b_cfg->maxTxPower = RFM22_tx_pwr_txpow_7;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initalize the RFM22B radio COM device. */
|
||||
if (PIOS_RFM22B_Init(&pios_rfm22b_id, PIOS_RFM22_SPI_PORT, pios_rfm22b_cfg.slave_num, &pios_rfm22b_cfg))
|
||||
if (PIOS_RFM22B_Init(&pios_rfm22b_id, PIOS_RFM22_SPI_PORT, pios_rfm22b_cfg->slave_num, pios_rfm22b_cfg))
|
||||
return -1;
|
||||
|
||||
// Initialize the packet handler
|
||||
|
@ -383,7 +383,7 @@ void PIOS_Board_Init(void) {
|
||||
#endif
|
||||
|
||||
uint32_t pios_usb_id;
|
||||
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
|
||||
PIOS_USB_Init(&pios_usb_id, PIOS_BOARD_HW_DEFS_GetUsbCfg(bdinfo->board_rev));
|
||||
|
||||
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||
|
||||
|
@ -392,7 +392,20 @@ static const struct pios_exti_cfg pios_exti_rfm22b_cfg __exti_config = {
|
||||
},
|
||||
};
|
||||
|
||||
struct pios_rfm22b_cfg pios_rfm22b_cfg = {
|
||||
const struct pios_rfm22b_cfg pios_rfm22b_rm1_cfg = {
|
||||
.spi_cfg = &pios_spi_telem_flash_cfg,
|
||||
.exti_cfg = &pios_exti_rfm22b_cfg,
|
||||
.frequencyHz = 434000000,
|
||||
.minFrequencyHz = 434000000 - 2000000,
|
||||
.maxFrequencyHz = 434000000 + 2000000,
|
||||
.RFXtalCap = 0x7f,
|
||||
.maxRFBandwidth = 128000,
|
||||
.maxTxPower = RFM22_tx_pwr_txpow_7, // +20dBm .. 100mW
|
||||
.slave_num = 0,
|
||||
.gpio_direction = GPIO0_RX_GPIO1_TX,
|
||||
};
|
||||
|
||||
const struct pios_rfm22b_cfg pios_rfm22b_rm2_cfg = {
|
||||
.spi_cfg = &pios_spi_telem_flash_cfg,
|
||||
.exti_cfg = &pios_exti_rfm22b_cfg,
|
||||
.frequencyHz = 434000000,
|
||||
@ -405,6 +418,21 @@ struct pios_rfm22b_cfg pios_rfm22b_cfg = {
|
||||
.gpio_direction = GPIO0_TX_GPIO1_RX,
|
||||
};
|
||||
|
||||
const struct pios_rfm22b_cfg * PIOS_BOARD_HW_DEFS_GetRfm22Cfg (uint32_t board_revision)
|
||||
{
|
||||
switch(board_revision) {
|
||||
case 2:
|
||||
return &pios_rfm22b_rm1_cfg;
|
||||
break;
|
||||
case 3:
|
||||
return &pios_rfm22b_rm2_cfg;
|
||||
break;
|
||||
default:
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_RFM22B */
|
||||
|
||||
#endif /* PIOS_INCLUDE_SPI */
|
||||
@ -1303,7 +1331,27 @@ static const struct pios_ppm_cfg pios_ppm_cfg = {
|
||||
#if defined(PIOS_INCLUDE_USB)
|
||||
#include "pios_usb_priv.h"
|
||||
|
||||
static const struct pios_usb_cfg pios_usb_main_cfg = {
|
||||
static const struct pios_usb_cfg pios_usb_main_rm1_cfg = {
|
||||
.irq = {
|
||||
.init = {
|
||||
.NVIC_IRQChannel = OTG_FS_IRQn,
|
||||
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
|
||||
.NVIC_IRQChannelSubPriority = 3,
|
||||
.NVIC_IRQChannelCmd = ENABLE,
|
||||
},
|
||||
},
|
||||
.vsense = {
|
||||
.gpio = GPIOB,
|
||||
.init = {
|
||||
.GPIO_Pin = GPIO_Pin_13,
|
||||
.GPIO_Speed = GPIO_Speed_25MHz,
|
||||
.GPIO_Mode = GPIO_Mode_IN,
|
||||
.GPIO_OType = GPIO_OType_OD,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
static const struct pios_usb_cfg pios_usb_main_rm2_cfg = {
|
||||
.irq = {
|
||||
.init = {
|
||||
.NVIC_IRQChannel = OTG_FS_IRQn,
|
||||
@ -1323,6 +1371,21 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
|
||||
}
|
||||
};
|
||||
|
||||
const struct pios_usb_cfg * PIOS_BOARD_HW_DEFS_GetUsbCfg (uint32_t board_revision)
|
||||
{
|
||||
switch(board_revision) {
|
||||
case 2:
|
||||
return &pios_usb_main_rm1_cfg;
|
||||
break;
|
||||
case 3:
|
||||
return &pios_usb_main_rm2_cfg;
|
||||
break;
|
||||
default:
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#include "pios_usb_board_data_priv.h"
|
||||
#include "pios_usb_desc_hid_cdc_priv.h"
|
||||
#include "pios_usb_desc_hid_only_priv.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user