Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial LoRa support #18998

Merged
merged 10 commits into from
Dec 21, 2019
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
/drivers/ipm/ipm_stm32_ipcc.c @arnopo
/drivers/led/ @Mani-Sadhasivam
/drivers/led_strip/ @mbolivar
/drivers/lora/ @Mani-Sadhasivam
/drivers/modem/ @mike-scott
/drivers/pcie/ @andrewboie
/drivers/pinmux/stm32/ @rsalveti @idlethread
Expand Down Expand Up @@ -241,6 +242,7 @@
/include/drivers/led_strip.h @mbolivar
/include/drivers/sensor.h @MaureenHelm
/include/drivers/spi.h @tbursztyka
/include/drivers/lora.h @Mani-Sadhasivam
/include/app_memory/ @andrewboie
/include/arch/arc/ @vonhust @ruuddw
/include/arch/arc/arch.h @andrewboie
Expand Down Expand Up @@ -305,6 +307,7 @@
/samples/display/ @vanwinkeljan
/samples/drivers/CAN/ @alexanderwachter
/samples/drivers/ht16k33/ @henrikbrixandersen
/samples/drivers/lora/ @Mani-Sadhasivam
/samples/gui/ @vanwinkeljan
/samples/net/ @jukkar @tbursztyka @pfalcon
/samples/net/dns_resolve/ @jukkar @tbursztyka @pfalcon
Expand Down
11 changes: 11 additions & 0 deletions boards/arm/96b_wistrio/96b_wistrio.dts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@

&spi1 {
status = "okay";
cs-gpios = <&gpiob 0 0>;

sx1276@0 {
compatible = "semtech,sx1276";
reg = <0>;
label = "sx1276";
reset-gpios = <&gpiob 13 0>;
dio-gpios = <&gpioa 11 0 &gpiob 1 0 &gpioa 3 0
&gpioh 0 0 &gpioc 13 0>;
spi-max-frequency = <1000000>;
};
};

&rtc {
Expand Down
49 changes: 45 additions & 4 deletions boards/arm/96b_wistrio/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <kernel.h>
#include <device.h>
#include <gpio.h>
#include <init.h>
#include <drivers/pinmux.h>
#include <kernel.h>
#include <pinmux.h>
#include <sys/sys_io.h>

#include <pinmux/stm32/pinmux_stm32.h>
Expand All @@ -25,16 +26,56 @@ static const struct pin_config pinconf[] = {
{STM32_PIN_PB8, STM32L1X_PINMUX_FUNC_PB8_I2C1_SCL},
{STM32_PIN_PB9, STM32L1X_PINMUX_FUNC_PB9_I2C1_SDA},
#endif /* CONFIG_I2C_1 */
#ifdef CONFIG_SPI_1
{STM32_PIN_PA5, STM32L1X_PINMUX_FUNC_PA5_SPI1_SCK |
STM32_OSPEEDR_VERY_HIGH_SPEED},
{STM32_PIN_PA6, STM32L1X_PINMUX_FUNC_PA6_SPI1_MISO},
{STM32_PIN_PA7, STM32L1X_PINMUX_FUNC_PA7_SPI1_MOSI},
#endif /* CONFIG_SPI_1 */
/* RF_CTX_PA */
{STM32_PIN_PA4, STM32_PUSHPULL_PULLUP},
/* RF_CRX_RX */
{STM32_PIN_PB6, STM32_PUSHPULL_PULLUP},
/* RF_CBT_HF */
{STM32_PIN_PB7, STM32_PUSHPULL_PULLUP},
};

static int pinmux_stm32_init(struct device *port)
{
ARG_UNUSED(port);
struct device *gpioa, *gpiob, *gpioh;

stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));

gpioa = device_get_binding(DT_ST_STM32_GPIO_40020000_LABEL);
if (!gpioa) {
return -ENODEV;
}

gpiob = device_get_binding(DT_ST_STM32_GPIO_40020400_LABEL);
if (!gpiob) {
return -ENODEV;
}

gpioh = device_get_binding(DT_ST_STM32_GPIO_40021400_LABEL);
if (!gpioh) {
return -ENODEV;
}

gpio_pin_configure(gpioa, 4, GPIO_DIR_OUT);
gpio_pin_write(gpioa, 4, 1);

gpio_pin_configure(gpiob, 6, GPIO_DIR_OUT);
gpio_pin_write(gpiob, 6, 1);

gpio_pin_configure(gpiob, 7, GPIO_DIR_OUT);
gpio_pin_write(gpiob, 7, 0);

gpio_pin_configure(gpioh, 1, GPIO_DIR_OUT);
gpio_pin_write(gpioh, 1, 1);

return 0;
}

SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);
/* Need to be initialised after GPIO driver */
SYS_INIT(pinmux_stm32_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
1 change: 1 addition & 0 deletions drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ add_subdirectory_if_kconfig(ps2)
add_subdirectory_if_kconfig(kscan)
add_subdirectory_if_kconfig(video)
add_subdirectory_if_kconfig(eeprom)
add_subdirectory_if_kconfig(lora)

add_subdirectory_ifdef(CONFIG_FLASH_HAS_DRIVER_ENABLED flash)
add_subdirectory_ifdef(CONFIG_SERIAL_HAS_DRIVER serial)
Expand Down
2 changes: 2 additions & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ source "drivers/bluetooth/Kconfig"

source "drivers/ieee802154/Kconfig"

source "drivers/lora/Kconfig"

source "drivers/console/Kconfig"

source "drivers/ethernet/Kconfig"
Expand Down
5 changes: 5 additions & 0 deletions drivers/lora/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

zephyr_library_named(loramac-node)
Mani-Sadhasivam marked this conversation as resolved.
Show resolved Hide resolved

zephyr_library_sources_ifdef(CONFIG_LORA_SX1276 sx1276.c)
28 changes: 28 additions & 0 deletions drivers/lora/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright (c) 2019 Manivannan Sadhasivam
#
# SPDX-License-Identifier: Apache-2.0
#

# Top-level configuration file for LORA drivers.

menuconfig LORA
bool "LoRa support"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to mark the LoRa support as [EXPERIMENTAL] here so that it is easier to tweak the API if needed.

help
Include LoRa drivers in the system configuration.

if LORA

module = LORA
module-str = lora
source "subsys/logging/Kconfig.template.log_config"

config LORA_INIT_PRIORITY
int "LoRa initialization priority"
default 90
help
System initialization priority for LoRa drivers.

source "drivers/lora/Kconfig.sx1276"

endif # LORA
37 changes: 37 additions & 0 deletions drivers/lora/Kconfig.sx1276
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Copyright (c) 2019 Manivannan Sadhasivam
#
# SPDX-License-Identifier: Apache-2.0
#

menuconfig LORA_SX1276
bool "Semtech SX1276 driver"
select HAS_SEMTECH_RADIO_DRIVERS
select HAS_SEMTECH_LORAMAC
select HAS_SEMTECH_SX1276
depends on SPI
depends on COUNTER
help
Enable LoRa driver for Semtech SX1276.

if LORA_SX1276

choice
prompt "SX1276 PA Output pin"
default PA_BOOST_PIN
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

endif # LORA_SX1276
Loading