mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/lorabasics: initial import
This commit is contained in:
parent
8e86382e29
commit
1b5addd1fd
@ -38,6 +38,7 @@ rsource "libcose/Kconfig"
|
|||||||
rsource "libfixmath/Kconfig"
|
rsource "libfixmath/Kconfig"
|
||||||
rsource "libhydrogen/Kconfig"
|
rsource "libhydrogen/Kconfig"
|
||||||
rsource "littlefs2/Kconfig"
|
rsource "littlefs2/Kconfig"
|
||||||
|
rsource "lorabasics/Kconfig"
|
||||||
rsource "lora-serialization/Kconfig"
|
rsource "lora-serialization/Kconfig"
|
||||||
rsource "lua/Kconfig"
|
rsource "lua/Kconfig"
|
||||||
rsource "lv_drivers/Kconfig"
|
rsource "lv_drivers/Kconfig"
|
||||||
|
33
pkg/lorabasics/Kconfig
Normal file
33
pkg/lorabasics/Kconfig
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Copyright (c) 2022 Inria
|
||||||
|
#
|
||||||
|
# This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
# directory for more details.
|
||||||
|
|
||||||
|
config PACKAGE_LORABASICS
|
||||||
|
bool "LoRa Basics"
|
||||||
|
depends on TEST_KCONFIG
|
||||||
|
# depends on HAS_ARCH_32_BIT
|
||||||
|
select MODULE_LORABASICS_SMTC_RAL
|
||||||
|
|
||||||
|
if PACKAGE_LORABASICS
|
||||||
|
|
||||||
|
config MODULE_LORABASICS_SX1280_DRIVER
|
||||||
|
bool "LoRaBasics SX1280 driver code"
|
||||||
|
depends on HAS_PERIPH_SPI
|
||||||
|
depends on HAS_PERIPH_GPIO
|
||||||
|
depends on HAS_PERIPH_GPIO_IRQ
|
||||||
|
select MODULE_PERIPH_SPI
|
||||||
|
select MODULE_PERIPH_GPIO
|
||||||
|
select MODULE_PERIPH_GPIO_IRQ
|
||||||
|
select MODULE_ZTIMER
|
||||||
|
select MODULE_ZTIMER_MSEC
|
||||||
|
select MODULE_LORABASICS_DRIVER_SX1280_HAL
|
||||||
|
|
||||||
|
config MODULE_LORABASICS_DRIVER_SX1280_HAL
|
||||||
|
bool "LoRaBasicsModem SX1280 driver hal"
|
||||||
|
|
||||||
|
config MODULE_LORABASICS_SMTC_RAL
|
||||||
|
bool "LoRaBasicsModem Radio Abstraction Layer (RAL)"
|
||||||
|
|
||||||
|
endif # PACKAGE_LORABASICS
|
23
pkg/lorabasics/Makefile
Normal file
23
pkg/lorabasics/Makefile
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
PKG_NAME=lorabasicsmodem
|
||||||
|
PKG_URL=https://github.com/lorabasics/lorabasicsmodem.git
|
||||||
|
PKG_VERSION=04e415bcfbdc7f1f4bff918a4867fab53bc8bb8a
|
||||||
|
PKG_LICENSE=BSD
|
||||||
|
|
||||||
|
include $(RIOTBASE)/pkg/pkg.mk
|
||||||
|
|
||||||
|
CFLAGS += -Wno-error=unused-parameter
|
||||||
|
CFLAGS += -Wno-error=unused-function
|
||||||
|
|
||||||
|
IGNORE_MODULES := lorabasics_driver_sx1280_hal
|
||||||
|
#
|
||||||
|
|
||||||
|
LORABASICS_MODULES := $(filter-out $(IGNORE_MODULES),$(filter lorabasics%,$(USEMODULE)))
|
||||||
|
|
||||||
|
all: $(LORABASICS_MODULES)
|
||||||
|
@true
|
||||||
|
|
||||||
|
lorabasics_smtc_ral:
|
||||||
|
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/smtc_ral/src -f $(RIOTBASE)/Makefile.base MODULE=$@ SRC="ral.c ral_sx1280.c"
|
||||||
|
|
||||||
|
lorabasics_sx1280_driver:
|
||||||
|
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/sx1280_driver/src -f $(RIOTBASE)/Makefile.base MODULE=$@
|
11
pkg/lorabasics/Makefile.dep
Normal file
11
pkg/lorabasics/Makefile.dep
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
ifneq (,$(filter lorabasics_sx1280_driver,$(USEMODULE)))
|
||||||
|
FEATURES_REQUIRED += periph_gpio_irq
|
||||||
|
FEATURES_REQUIRED += periph_spi
|
||||||
|
|
||||||
|
USEMODULE += ztimer_msec
|
||||||
|
|
||||||
|
USEMODULE += lorabasics_driver_sx1280_hal
|
||||||
|
endif
|
||||||
|
# This package has assumptions that only work for 32-bit architectures
|
||||||
|
FEATURES_REQUIRED += arch_32bit
|
||||||
|
USEMODULE += lorabasics_smtc_ral
|
11
pkg/lorabasics/Makefile.include
Normal file
11
pkg/lorabasics/Makefile.include
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
INCLUDES += -I$(PKGDIRBASE)/lorabasicsmodem \
|
||||||
|
#
|
||||||
|
|
||||||
|
ifneq (,$(filter lorabasics_driver_sx1280_hal,$(USEMODULE)))
|
||||||
|
DIRS += $(RIOTBASE)/pkg/lorabasics/driver_sx1280_hal
|
||||||
|
|
||||||
|
# In the lorabasics package setting this define includes RAL code for the sx1280 radio
|
||||||
|
CFLAGS += -DSX1280
|
||||||
|
endif
|
||||||
|
|
||||||
|
PSEUDOMODULES += lorabasics
|
13
pkg/lorabasics/doc.txt
Normal file
13
pkg/lorabasics/doc.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* @defgroup pkg_lorabasicsmodem LoRa Basics
|
||||||
|
* @ingroup pkg
|
||||||
|
* @brief LoRa Basics Modem
|
||||||
|
*
|
||||||
|
* # HAL implementation for the SX1280 LoRa radio driver and vendor code for SX1280
|
||||||
|
*
|
||||||
|
* # License
|
||||||
|
*
|
||||||
|
* Licensed under BSD.
|
||||||
|
*
|
||||||
|
* @see git@github.com:lorabasics/lorabasicsmodem.git
|
||||||
|
*/
|
3
pkg/lorabasics/driver_sx1280_hal/Makefile
Normal file
3
pkg/lorabasics/driver_sx1280_hal/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
MODULE = lorabasics_driver_sx1280_hal
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
136
pkg/lorabasics/driver_sx1280_hal/driver_sx1280_hal.c
Normal file
136
pkg/lorabasics/driver_sx1280_hal/driver_sx1280_hal.c
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Inria
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup pkg_lorabasicsmodem
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief HAL implementation for the SX1280 LoRa radio driver
|
||||||
|
*
|
||||||
|
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||||
|
* @author Nicolas Albarel <nicolas.albarel@univ-grenoble-alpes.fr>
|
||||||
|
* @author Didier Donsez <didier.donsez@univ-grenoble-alpes.fr>
|
||||||
|
* @author Olivier Alphand <olivier.alphand@univ-grenoble-alpes.fr>
|
||||||
|
* @author Aymeric Brochier <aymeric.brochier@univ-grenoble-alpes.fr>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "irq.h"
|
||||||
|
#include "periph/spi.h"
|
||||||
|
#include "ztimer.h"
|
||||||
|
|
||||||
|
#include "sx1280.h"
|
||||||
|
#include "sx1280_constants.h"
|
||||||
|
#include "sx1280_driver/src/sx1280_hal.h"
|
||||||
|
|
||||||
|
#define ENABLE_DEBUG 0
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Wait until radio busy pin is reset to 0
|
||||||
|
*/
|
||||||
|
static void sx1280_hal_wait_on_busy(const void *context)
|
||||||
|
{
|
||||||
|
sx1280_t *dev = (sx1280_t *)context;
|
||||||
|
|
||||||
|
while (gpio_read(dev->params->dio0_pin)) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
sx1280_hal_status_t sx1280_hal_write(const void *context, const uint8_t *command,
|
||||||
|
const uint16_t command_length,
|
||||||
|
const uint8_t *data, const uint16_t data_length)
|
||||||
|
{
|
||||||
|
sx1280_t *dev = (sx1280_t *)context;
|
||||||
|
|
||||||
|
sx1280_hal_wakeup(context);
|
||||||
|
|
||||||
|
DEBUG("[sx1280_hal_write]: command_length=%d data_length=%d\n", command_length, data_length);
|
||||||
|
|
||||||
|
spi_acquire(dev->params->spi, SPI_CS_UNDEF, dev->params->spi_mode, dev->params->spi_clk);
|
||||||
|
spi_transfer_bytes(dev->params->spi, dev->params->nss_pin, data_length != 0,
|
||||||
|
command, NULL, command_length);
|
||||||
|
if (data_length) {
|
||||||
|
spi_transfer_bytes(dev->params->spi, dev->params->nss_pin, false, data,
|
||||||
|
NULL, data_length);
|
||||||
|
}
|
||||||
|
spi_release(dev->params->spi);
|
||||||
|
|
||||||
|
/* 0x84 - SX1280_SET_SLEEP opcode. In sleep mode the radio dio is stuck
|
||||||
|
to 1 => do not test it */
|
||||||
|
if (command[0] != 0x84) {
|
||||||
|
sx1280_hal_wait_on_busy(context);
|
||||||
|
}
|
||||||
|
return SX1280_HAL_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
sx1280_hal_status_t sx1280_hal_read(const void *context, const uint8_t *command,
|
||||||
|
const uint16_t command_length,
|
||||||
|
uint8_t *data, const uint16_t data_length)
|
||||||
|
{
|
||||||
|
sx1280_t *dev = (sx1280_t *)context;
|
||||||
|
|
||||||
|
sx1280_hal_wakeup(context);
|
||||||
|
|
||||||
|
spi_acquire(dev->params->spi, SPI_CS_UNDEF, dev->params->spi_mode, dev->params->spi_clk);
|
||||||
|
spi_transfer_bytes(dev->params->spi, dev->params->nss_pin, true, \
|
||||||
|
command, NULL, command_length);
|
||||||
|
spi_transfer_bytes(dev->params->spi, dev->params->nss_pin, false, \
|
||||||
|
NULL, data, data_length);
|
||||||
|
spi_release(dev->params->spi);
|
||||||
|
|
||||||
|
return SX1280_HAL_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sx1280_hal_reset( const void *context )
|
||||||
|
{
|
||||||
|
sx1280_t *dev = (sx1280_t *)context;
|
||||||
|
|
||||||
|
gpio_clear(dev->params->reset_pin);
|
||||||
|
ztimer_sleep(ZTIMER_MSEC, SX1280_RESET_MS);
|
||||||
|
gpio_set(dev->params->reset_pin);
|
||||||
|
ztimer_sleep(ZTIMER_MSEC, SX1280_WAKEUP_TIME_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
sx1280_hal_status_t sx1280_hal_wakeup(const void *context)
|
||||||
|
{
|
||||||
|
sx1280_t *dev = (sx1280_t *)context;
|
||||||
|
|
||||||
|
if (dev->mode == SX1280_HAL_OP_MODE_SLEEP) {
|
||||||
|
/* Busy is HIGH in sleep mode, wake-up the device */
|
||||||
|
gpio_clear(dev->params->nss_pin);
|
||||||
|
sx1280_hal_wait_on_busy(context);
|
||||||
|
gpio_set(dev->params->nss_pin);
|
||||||
|
|
||||||
|
/* Radio is awake in STDBY_RC mode */
|
||||||
|
dev->mode = SX1280_HAL_OP_MODE_STDBY_RC;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* if the radio is awake, just wait until busy pin get low */
|
||||||
|
sx1280_hal_wait_on_busy(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SX1280_HAL_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
sx1280_hal_operating_mode_t sx1280_hal_get_operating_mode(const void *context)
|
||||||
|
{
|
||||||
|
sx1280_t *dev = (sx1280_t *)context;
|
||||||
|
|
||||||
|
return dev->mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sx1280_hal_set_operating_mode(const void *context, const sx1280_hal_operating_mode_t op_mode)
|
||||||
|
{
|
||||||
|
sx1280_t *dev = (sx1280_t *)context;
|
||||||
|
|
||||||
|
dev->mode = op_mode;
|
||||||
|
}
|
Binary file not shown.
BIN
pkg/lorabasics/patches/0002-treewide-fix-include-paths.patch
Normal file
BIN
pkg/lorabasics/patches/0002-treewide-fix-include-paths.patch
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user