drivers: lora: sx1276: select PA output by dts property
PA selection mainly depends on board design. So it looks like device-tree is a better mechanism than Kconfig in this case. Use string property with two possible values: "rfo" and "pa-boost". Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This commit is contained in:
parent
d1ba1ca5a5
commit
f08ef736a0
5 changed files with 24 additions and 22 deletions
|
@ -73,6 +73,7 @@
|
||||||
<&gpioh 0 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
|
<&gpioh 0 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
|
||||||
<&gpioc 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
|
<&gpioc 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
|
||||||
spi-max-frequency = <1000000>;
|
spi-max-frequency = <1000000>;
|
||||||
|
power-amplifier-output = "pa-boost";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
|
||||||
menuconfig LORA_SX1276
|
config LORA_SX1276
|
||||||
bool "Semtech SX1276 driver"
|
bool "Semtech SX1276 driver"
|
||||||
select HAS_SEMTECH_RADIO_DRIVERS
|
select HAS_SEMTECH_RADIO_DRIVERS
|
||||||
select HAS_SEMTECH_LORAMAC
|
select HAS_SEMTECH_LORAMAC
|
||||||
|
@ -12,22 +12,3 @@ menuconfig LORA_SX1276
|
||||||
depends on SPI
|
depends on SPI
|
||||||
help
|
help
|
||||||
Enable LoRa driver for Semtech SX1276.
|
Enable LoRa driver for Semtech SX1276.
|
||||||
|
|
||||||
choice
|
|
||||||
prompt "SX1276 PA Output pin"
|
|
||||||
default PA_BOOST_PIN
|
|
||||||
depends on LORA_SX1276
|
|
||||||
help
|
|
||||||
Antenna connection type.
|
|
||||||
|
|
||||||
config PA_RFO_PIN
|
|
||||||
bool "PA_RFO_PIN"
|
|
||||||
help
|
|
||||||
Antenna connected to PA_RFO pin.
|
|
||||||
|
|
||||||
config PA_BOOST_PIN
|
|
||||||
bool "PA_BOOST_PIN"
|
|
||||||
help
|
|
||||||
Antenna connected to PA_BOOST pin.
|
|
||||||
|
|
||||||
endchoice
|
|
||||||
|
|
|
@ -23,6 +23,15 @@ LOG_MODULE_REGISTER(sx1276);
|
||||||
#define GPIO_RESET_FLAGS DT_INST_GPIO_FLAGS(0, reset_gpios)
|
#define GPIO_RESET_FLAGS DT_INST_GPIO_FLAGS(0, reset_gpios)
|
||||||
#define GPIO_CS_PIN DT_INST_SPI_DEV_CS_GPIOS_PIN(0)
|
#define GPIO_CS_PIN DT_INST_SPI_DEV_CS_GPIOS_PIN(0)
|
||||||
|
|
||||||
|
#define PA_PIN DT_ENUM_IDX(DT_DRV_INST(0), \
|
||||||
|
power_amplifier_output)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Those macros must be in sync with 'power-amplifier-output' dts property.
|
||||||
|
*/
|
||||||
|
#define SX1276_PA_RFO 0
|
||||||
|
#define SX1276_PA_BOOST 1
|
||||||
|
|
||||||
#define SX1276_REG_PA_CONFIG 0x09
|
#define SX1276_REG_PA_CONFIG 0x09
|
||||||
#define SX1276_REG_PA_DAC 0x4d
|
#define SX1276_REG_PA_DAC 0x4d
|
||||||
#define SX1276_REG_VERSION 0x42
|
#define SX1276_REG_VERSION 0x42
|
||||||
|
@ -239,7 +248,7 @@ void SX1276SetRfTxPower(int8_t power)
|
||||||
|
|
||||||
pa_dac &= RF_PADAC_20DBM_MASK;
|
pa_dac &= RF_PADAC_20DBM_MASK;
|
||||||
|
|
||||||
#if defined CONFIG_PA_BOOST_PIN
|
#if PA_PIN == SX1276_PA_BOOST
|
||||||
power = clamp_int8(power, 2, 20);
|
power = clamp_int8(power, 2, 20);
|
||||||
|
|
||||||
pa_config |= RF_PACONFIG_PASELECT_PABOOST;
|
pa_config |= RF_PACONFIG_PASELECT_PABOOST;
|
||||||
|
@ -250,7 +259,7 @@ void SX1276SetRfTxPower(int8_t power)
|
||||||
pa_dac |= RF_PADAC_20DBM_OFF;
|
pa_dac |= RF_PADAC_20DBM_OFF;
|
||||||
pa_config |= (power - 2) & 0x0F;
|
pa_config |= (power - 2) & 0x0F;
|
||||||
}
|
}
|
||||||
#elif CONFIG_PA_RFO_PIN
|
#elif PA_PIN == SX1276_PA_RFO
|
||||||
power = clamp_int8(power, -4, 15);
|
power = clamp_int8(power, -4, 15);
|
||||||
|
|
||||||
pa_dac |= RF_PADAC_20DBM_OFF;
|
pa_dac |= RF_PADAC_20DBM_OFF;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# Copyright (c) 2019, Manivannan Sadhasivam
|
# Copyright (c) 2019, Manivannan Sadhasivam
|
||||||
|
# Copyright (c) 2020, Grinn
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
description: Semtech SX1276 LoRa Modem
|
description: Semtech SX1276 LoRa Modem
|
||||||
|
@ -24,3 +25,12 @@ properties:
|
||||||
Up to six pins that produce service interrupts from the modem.
|
Up to six pins that produce service interrupts from the modem.
|
||||||
|
|
||||||
These signals are normally active-high.
|
These signals are normally active-high.
|
||||||
|
|
||||||
|
power-amplifier-output:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
description: |
|
||||||
|
Selects power amplifier output pin.
|
||||||
|
enum:
|
||||||
|
- "rfo"
|
||||||
|
- "pa-boost"
|
||||||
|
|
|
@ -208,6 +208,7 @@ test_spi_sx1276: sx1276@13 {
|
||||||
spi-max-frequency = <0>;
|
spi-max-frequency = <0>;
|
||||||
reset-gpios = <&test_gpio 0 0>;
|
reset-gpios = <&test_gpio 0 0>;
|
||||||
dio-gpios = <&test_gpio 0 0>;
|
dio-gpios = <&test_gpio 0 0>;
|
||||||
|
power-amplifier-output = "rfo";
|
||||||
};
|
};
|
||||||
|
|
||||||
test_spi_st7789v: st7789v@14 {
|
test_spi_st7789v: st7789v@14 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue