mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:52:44 +01:00
Merge pull request #17138 from fjmolinas/pr_sx126x_fixes
drivers/sx126x: fix sync word and TX PA configuration
This commit is contained in:
commit
b609646961
@ -18,6 +18,7 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include "kernel_defines.h"
|
||||
#include "cpu.h"
|
||||
#include "board.h"
|
||||
@ -72,6 +73,8 @@ void lora_e5_dev_sx126x_set_rf_mode(sx126x_t *dev, sx126x_rf_mode_t rf_mode)
|
||||
gpio_set(FE_CTRL2);
|
||||
break;
|
||||
default:
|
||||
/* SX126X_RF_MODE_TX_LPA is not supported */
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
#define SX126X_PARAM_SPI (SPI_DEV(0))
|
||||
#define SX126X_PARAM_TX_PA_MODE SX126X_RF_MODE_TX_HPA
|
||||
#if IS_USED(MODULE_SX126X_STM32WL)
|
||||
extern void lora_e5_dev_sx126x_set_rf_mode(sx126x_t *dev, sx126x_rf_mode_t rf_mode);
|
||||
#define SX126X_PARAM_SET_RF_MODE_CB lora_e5_dev_sx126x_set_rf_mode
|
||||
|
3
dist/tools/doccheck/exclude_patterns
vendored
3
dist/tools/doccheck/exclude_patterns
vendored
@ -14564,3 +14564,6 @@ boards/stm32g0316\-disco/include/periph_conf\.h:[0-9]+: warning: Member timer_co
|
||||
boards/stm32g0316\-disco/include/periph_conf\.h:[0-9]+: warning: Member UART_0_ISR \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32g0316\-disco/include/periph_conf\.h:[0-9]+: warning: Member UART_NUMOF \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32g0316\-disco/include/periph_conf\.h:[0-9]+: warning: Member uart_config\[\] \(variable\) of file periph_conf\.h is not documented\.
|
||||
boards/lora\-e5\-dev/include/board\.h:[0-9]+: warning: Member SX126X_PARAM_TX_PA_MODE \(macro definition\) of file board\.h is not documented\.
|
||||
drivers/sx126x/include/sx126x_params\.h:[0-9]+: warning: Member SX126X_PARAM_TX_PA_MODE \(macro definition\) of file sx126x_params\.h is not documented\.
|
||||
drivers/sx126x/include/sx126x_params\.h:[0-9]+: warning: Member SX126X_TX_PA_MODE \(macro definition\) of file sx126x_params\.h is not documented\.
|
||||
|
@ -95,6 +95,7 @@ typedef struct {
|
||||
* @ brief Interface to set RF switch parameters
|
||||
*/
|
||||
void(*set_rf_mode)(sx126x_t *dev, sx126x_rf_mode_t rf_mode);
|
||||
sx126x_rf_mode_t tx_pa_mode; /**< Power amplifier TX operating mode*/
|
||||
#endif
|
||||
} sx126x_params_t;
|
||||
|
||||
|
@ -61,6 +61,10 @@ extern "C" {
|
||||
#define SX126X_PARAM_SET_RF_MODE_CB NULL
|
||||
#endif
|
||||
|
||||
#ifndef SX126X_PARAM_TX_PA_MODE
|
||||
#define SX126X_PARAM_TX_PA_MODE SX126X_RF_MODE_TX_LPA
|
||||
#endif
|
||||
|
||||
#ifndef SX126X_PARAM_TYPE
|
||||
# if IS_USED(MODULE_SX1261)
|
||||
# define SX126X_PARAM_TYPE SX126X_TYPE_SX1261
|
||||
@ -78,9 +82,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if IS_USED(MODULE_SX126X_RF_SWITCH)
|
||||
#define SX126X_SET_RF_MODE .set_rf_mode = SX126X_PARAM_SET_RF_MODE_CB
|
||||
#define SX126X_SET_RF_MODE .set_rf_mode = SX126X_PARAM_SET_RF_MODE_CB,
|
||||
#define SX126X_TX_PA_MODE .tx_pa_mode = SX126X_PARAM_TX_PA_MODE
|
||||
#else
|
||||
#define SX126X_SET_RF_MODE
|
||||
#define SX126X_TX_PA_MODE
|
||||
#endif
|
||||
|
||||
#define SX126X_PARAMS { .spi = SX126X_PARAM_SPI, \
|
||||
@ -90,7 +96,8 @@ extern "C" {
|
||||
.dio1_pin = SX126X_PARAM_DIO1, \
|
||||
.type = SX126X_PARAM_TYPE, \
|
||||
.regulator = SX126X_PARAM_REGULATOR, \
|
||||
SX126X_SET_RF_MODE }
|
||||
SX126X_SET_RF_MODE \
|
||||
SX126X_TX_PA_MODE}
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
@ -49,13 +49,6 @@
|
||||
#define CONFIG_SX126X_RAMP_TIME_DEFAULT (SX126X_RAMP_10_US)
|
||||
#endif
|
||||
|
||||
const sx126x_pa_cfg_params_t sx1262_pa_cfg = {
|
||||
.pa_duty_cycle = 0x02,
|
||||
.hp_max = 0x02,
|
||||
.device_sel = 0x00,
|
||||
.pa_lut = 0x01
|
||||
};
|
||||
|
||||
const sx126x_pa_cfg_params_t sx1268_pa_cfg = {
|
||||
.pa_duty_cycle = 0x04,
|
||||
.hp_max = 0x06,
|
||||
@ -63,13 +56,20 @@ const sx126x_pa_cfg_params_t sx1268_pa_cfg = {
|
||||
.pa_lut = 0x01
|
||||
};
|
||||
|
||||
const sx126x_pa_cfg_params_t sx1261_pa_cfg = {
|
||||
const sx126x_pa_cfg_params_t lpa_cfg = {
|
||||
.pa_duty_cycle = 0x04,
|
||||
.hp_max = 0x00,
|
||||
.device_sel = 0x01,
|
||||
.pa_lut = 0x01
|
||||
};
|
||||
|
||||
const sx126x_pa_cfg_params_t hpa_cfg = {
|
||||
.pa_duty_cycle = 0x02,
|
||||
.hp_max = 0x02,
|
||||
.device_sel = 0x00,
|
||||
.pa_lut = 0x01
|
||||
};
|
||||
|
||||
void sx126x_setup(sx126x_t *dev, const sx126x_params_t *params, uint8_t index)
|
||||
{
|
||||
netdev_t *netdev = &dev->netdev;
|
||||
@ -108,14 +108,21 @@ static void sx126x_init_default_config(sx126x_t *dev)
|
||||
* and are optimal for a TX output power of 14dBm.
|
||||
*/
|
||||
if (sx126x_is_llcc68(dev) || sx126x_is_sx1262(dev)) {
|
||||
sx126x_set_pa_cfg(dev, &sx1262_pa_cfg);
|
||||
sx126x_set_pa_cfg(dev, &hpa_cfg);
|
||||
}
|
||||
else if (sx126x_is_sx1268(dev)) {
|
||||
sx126x_set_pa_cfg(dev, &sx1268_pa_cfg);
|
||||
}
|
||||
else { /* sx126x_is_sx1261(dev) or sx126x_is_stm32wl(dev) */
|
||||
sx126x_set_pa_cfg(dev, &sx1261_pa_cfg);
|
||||
else if (sx126x_is_sx1261(dev)) {
|
||||
sx126x_set_pa_cfg(dev, &lpa_cfg);
|
||||
}
|
||||
#if IS_USED(MODULE_SX126X_RF_SWITCH)
|
||||
if (dev->params->tx_pa_mode == SX126X_RF_MODE_TX_LPA){
|
||||
sx126x_set_pa_cfg(dev, &lpa_cfg);
|
||||
} else {
|
||||
sx126x_set_pa_cfg(dev, &hpa_cfg);
|
||||
}
|
||||
#endif
|
||||
sx126x_set_tx_params(dev, CONFIG_SX126X_TX_POWER_DEFAULT, CONFIG_SX126X_RAMP_TIME_DEFAULT);
|
||||
|
||||
dev->mod_params.bw = (sx126x_lora_bw_t)(CONFIG_LORA_BW_DEFAULT + SX126X_LORA_BW_125);
|
||||
|
@ -333,7 +333,7 @@ static int _set_state(sx126x_t *dev, netopt_state_t state)
|
||||
DEBUG("[sx126x] netdev: set NETOPT_STATE_TX state\n");
|
||||
#if IS_USED(MODULE_SX126X_RF_SWITCH)
|
||||
if (dev->params->set_rf_mode) {
|
||||
dev->params->set_rf_mode(dev, SX126X_RF_MODE_TX_LPA);
|
||||
dev->params->set_rf_mode(dev, dev->params->tx_pa_mode);
|
||||
}
|
||||
#endif
|
||||
sx126x_set_tx(dev, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user