mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-26 15:54:15 +01:00
LP-346 RFM22 tuning: Allow XtalCap value changes without reboot.
This commit is contained in:
parent
54fa56d421
commit
1e920ec67c
@ -67,9 +67,11 @@ static xTaskHandle systemTaskHandle;
|
|||||||
static bool stackOverflow;
|
static bool stackOverflow;
|
||||||
static bool mallocFailed;
|
static bool mallocFailed;
|
||||||
volatile int initTaskDone = 0;
|
volatile int initTaskDone = 0;
|
||||||
|
static OPLinkSettingsData previousOPLinkSettings;
|
||||||
|
|
||||||
// Private functions
|
// Private functions
|
||||||
static void systemTask(void *parameters);
|
static void systemTask(void *parameters);
|
||||||
|
static void checkOPLinkSettingsUpdatedCb(UAVObjEvent *ev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the module task.
|
* Create the module task.
|
||||||
@ -133,6 +135,8 @@ static void systemTask(__attribute__((unused)) void *parameters)
|
|||||||
PIOS_SYS_Reset();
|
PIOS_SYS_Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OPLinkSettingsConnectCallback(checkOPLinkSettingsUpdatedCb);
|
||||||
|
|
||||||
// Initialize vars
|
// Initialize vars
|
||||||
lastSysTime = xTaskGetTickCount();
|
lastSysTime = xTaskGetTickCount();
|
||||||
|
|
||||||
@ -242,6 +246,22 @@ void vApplicationMallocFailedHook(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called whenever OPLink settings changed
|
||||||
|
*/
|
||||||
|
static void checkOPLinkSettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
|
||||||
|
{
|
||||||
|
OPLinkSettingsData currentOPLinkSettings;
|
||||||
|
|
||||||
|
OPLinkSettingsGet(¤tOPLinkSettings);
|
||||||
|
// Check if RFXtalCap value changed
|
||||||
|
if (currentOPLinkSettings.RFXtalCap != previousOPLinkSettings.RFXtalCap) {
|
||||||
|
PIOS_RFM22B_SetXtalCap(pios_rfm22b_id, currentOPLinkSettings.RFXtalCap);
|
||||||
|
PIOS_RFM22B_Reinit(pios_rfm22b_id);
|
||||||
|
previousOPLinkSettings = currentOPLinkSettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
* @}
|
* @}
|
||||||
|
@ -129,6 +129,11 @@ static void updateWDGstats();
|
|||||||
static uint8_t i2c_error_activity[PIOS_I2C_ERROR_COUNT_NUMELEM];
|
static uint8_t i2c_error_activity[PIOS_I2C_ERROR_COUNT_NUMELEM];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_RFM22B
|
||||||
|
static OPLinkSettingsData previousOPLinkSettings;
|
||||||
|
static void checkOPLinkSettingsUpdatedCb(UAVObjEvent *ev);
|
||||||
|
#endif
|
||||||
|
|
||||||
extern uintptr_t pios_uavo_settings_fs_id;
|
extern uintptr_t pios_uavo_settings_fs_id;
|
||||||
extern uintptr_t pios_user_fs_id;
|
extern uintptr_t pios_user_fs_id;
|
||||||
|
|
||||||
@ -231,6 +236,10 @@ static void systemTask(__attribute__((unused)) void *parameters)
|
|||||||
HwSettingsConnectCallback(checkSettingsUpdatedCb);
|
HwSettingsConnectCallback(checkSettingsUpdatedCb);
|
||||||
SystemSettingsConnectCallback(checkSettingsUpdatedCb);
|
SystemSettingsConnectCallback(checkSettingsUpdatedCb);
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_RFM22B
|
||||||
|
OPLinkSettingsConnectCallback(checkOPLinkSettingsUpdatedCb);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DIAG_TASKS
|
#ifdef DIAG_TASKS
|
||||||
TaskInfoData taskInfoData;
|
TaskInfoData taskInfoData;
|
||||||
CallbackInfoData callbackInfoData;
|
CallbackInfoData callbackInfoData;
|
||||||
@ -454,6 +463,24 @@ static void checkSettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_RFM22B
|
||||||
|
/**
|
||||||
|
* Called whenever OPLink settings changed
|
||||||
|
*/
|
||||||
|
static void checkOPLinkSettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
|
||||||
|
{
|
||||||
|
OPLinkSettingsData currentOPLinkSettings;
|
||||||
|
|
||||||
|
OPLinkSettingsGet(¤tOPLinkSettings);
|
||||||
|
// Check if RFXtalCap value changed
|
||||||
|
if (currentOPLinkSettings.RFXtalCap != previousOPLinkSettings.RFXtalCap) {
|
||||||
|
PIOS_RFM22B_SetXtalCap(pios_rfm22b_id, currentOPLinkSettings.RFXtalCap);
|
||||||
|
PIOS_RFM22B_Reinit(pios_rfm22b_id);
|
||||||
|
previousOPLinkSettings = currentOPLinkSettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* ifdef PIOS_INCLUDE_RFM22B */
|
||||||
|
|
||||||
#ifdef DIAG_TASKS
|
#ifdef DIAG_TASKS
|
||||||
static void taskMonitorForEachCallback(uint16_t task_id, const struct pios_task_info *task_info, void *context)
|
static void taskMonitorForEachCallback(uint16_t task_id, const struct pios_task_info *task_info, void *context)
|
||||||
{
|
{
|
||||||
|
@ -652,6 +652,21 @@ void PIOS_RFM22B_SetChannelConfig(uint32_t rfm22b_id, enum rfm22b_datarate datar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a XtalCap
|
||||||
|
*
|
||||||
|
* @param[in] rfm22b_id The RFM22B device index.
|
||||||
|
* @param[in] XtalCap Value.
|
||||||
|
*/
|
||||||
|
void PIOS_RFM22B_SetXtalCap(uint32_t rfm22b_id, uint8_t xtal_cap)
|
||||||
|
{
|
||||||
|
struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
||||||
|
|
||||||
|
if (PIOS_RFM22B_Validate(rfm22b_dev)) {
|
||||||
|
rfm22b_dev->cfg.RFXtalCap = xtal_cap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a modem to be a coordinator or not.
|
* Set a modem to be a coordinator or not.
|
||||||
*
|
*
|
||||||
|
@ -105,6 +105,7 @@ extern int32_t PIOS_RFM22B_Init(uint32_t *rfb22b_id, uint32_t spi_id, uint32_t s
|
|||||||
extern void PIOS_RFM22B_Reinit(uint32_t rfb22b_id);
|
extern void PIOS_RFM22B_Reinit(uint32_t rfb22b_id);
|
||||||
extern void PIOS_RFM22B_SetTxPower(uint32_t rfm22b_id, enum rfm22b_tx_power tx_pwr);
|
extern void PIOS_RFM22B_SetTxPower(uint32_t rfm22b_id, enum rfm22b_tx_power tx_pwr);
|
||||||
extern void PIOS_RFM22B_SetChannelConfig(uint32_t rfm22b_id, enum rfm22b_datarate datarate, uint8_t min_chan, uint8_t max_chan, bool coordinator, bool ppm_mode, bool ppm_only);
|
extern void PIOS_RFM22B_SetChannelConfig(uint32_t rfm22b_id, enum rfm22b_datarate datarate, uint8_t min_chan, uint8_t max_chan, bool coordinator, bool ppm_mode, bool ppm_only);
|
||||||
|
extern void PIOS_RFM22B_SetXtalCap(uint32_t rfm22b_id, uint8_t xtal_cap);
|
||||||
extern void PIOS_RFM22B_SetCoordinatorID(uint32_t rfm22b_id, uint32_t coord_id);
|
extern void PIOS_RFM22B_SetCoordinatorID(uint32_t rfm22b_id, uint32_t coord_id);
|
||||||
extern void PIOS_RFM22B_SetDeviceID(uint32_t rfm22b_id, uint32_t device_id);
|
extern void PIOS_RFM22B_SetDeviceID(uint32_t rfm22b_id, uint32_t device_id);
|
||||||
extern uint32_t PIOS_RFM22B_DeviceID(uint32_t rfb22b_id);
|
extern uint32_t PIOS_RFM22B_DeviceID(uint32_t rfb22b_id);
|
||||||
|
@ -1923,7 +1923,8 @@ Leave blank to use autogenerated Device ID.</string>
|
|||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QSlider" name="RFXtalCapSlider">
|
<widget class="QSlider" name="RFXtalCapSlider">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The xtal capacitor value for fine tune frequency and get a AFC value close to zero. Default value is 127.</string>
|
<string>Adjust the xtal capacitor value to fine tune frequency and
|
||||||
|
get an AFC value close to zero. Default value is 127.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>171</number>
|
<number>171</number>
|
||||||
@ -1942,7 +1943,8 @@ Leave blank to use autogenerated Device ID.</string>
|
|||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QSpinBox" name="RFXtalCapValue">
|
<widget class="QSpinBox" name="RFXtalCapValue">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The xtal capacitor value for fine tune frequency and get a AFC value close to zero. Default value is 127.</string>
|
<string>Adjust the xtal capacitor value to fine tune frequency and
|
||||||
|
get an AFC value close to zero. Default value is 127.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>171</number>
|
<number>171</number>
|
||||||
@ -1959,7 +1961,8 @@ Leave blank to use autogenerated Device ID.</string>
|
|||||||
<item row="0" column="1" colspan="2">
|
<item row="0" column="1" colspan="2">
|
||||||
<widget class="QProgressBar" name="AFCCorrectionBar">
|
<widget class="QProgressBar" name="AFCCorrectionBar">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The Automatic Frequency Correction: How much the modem will correct a frequency misalignement between the two modems.</string>
|
<string>The Automatic Frequency Correction: How much the modem will correct
|
||||||
|
a frequency misalignement between the two modems.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>-50</number>
|
<number>-50</number>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user