feat: add shared LLCC68 Zephyr module

This commit is contained in:
2026-05-19 10:30:34 +08:00
commit 8d19312631
11 changed files with 3450 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
DT_COMPAT_SEMTECH_LLCC68 := "semtech,llcc68"
config LLCC68
bool "Semtech LLCC68 LoRa Radio Driver"
depends on SPI && GPIO
default $(dt_compat_enabled,$(DT_COMPAT_SEMTECH_LLCC68))
help
Enable the Semtech LLCC68 LoRa Radio Driver.
config LLCC68_INIT_PRIORITY
int "LLCC68 Initialization Priority"
default 90
help
The priority of the LLCC68 initialization. Lower numbers indicate
higher priority.
config LLCC68_ALWAYS_USE_SX1262_HIGH_PA
bool "LLCC68 Always Use SX1262 High Power Amplifier"
default y
help
When enabled, the LLCC68/SX1262/SX1261 driver always chooses high
power amplifier settings instead of selecting them from chip version.
module = LLCC68
module-str = llcc68
source "subsys/logging/Kconfig.template.log_config"
+69
View File
@@ -0,0 +1,69 @@
#include "llcc68_raw.h"
#include <errno.h>
#include <zephyr/sys/util.h>
#define DT_DRV_COMPAT semtech_llcc68
static void dio1_irq_trampoline(const struct device *port, struct gpio_callback *cb, uint32_t pins) {
ARG_UNUSED(port);
struct llcc68_data *data = CONTAINER_OF(cb, struct llcc68_data, dio1_irq_callback);
const struct llcc68_config *config = data->self->config;
if ((pins & BIT(config->dio1_gpio.pin)) != 0U && data->dio1_user_handler != NULL) {
data->dio1_user_handler(data->self, data->dio1_user_data);
}
}
int llcc68_init(const struct device *dev) {
const struct llcc68_config *config = dev->config;
struct llcc68_data *data = dev->data;
if (config->tx_enable_gpio.port != NULL) {
gpio_pin_configure_dt(&config->tx_enable_gpio, GPIO_OUTPUT_INACTIVE);
}
if (config->rx_enable_gpio.port != NULL) {
gpio_pin_configure_dt(&config->rx_enable_gpio, GPIO_OUTPUT_INACTIVE);
}
gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_INACTIVE);
gpio_pin_configure_dt(&config->busy_gpio, GPIO_INPUT);
gpio_pin_configure_dt(&config->dio1_gpio, GPIO_INPUT);
data->self = dev;
gpio_init_callback(&data->dio1_irq_callback, dio1_irq_trampoline, BIT(config->dio1_gpio.pin));
if (gpio_add_callback(config->dio1_gpio.port, &data->dio1_irq_callback) < 0) {
return -EIO;
}
gpio_pin_interrupt_configure_dt(&config->dio1_gpio, GPIO_INT_DISABLE);
return 0;
}
#define LLCC68_DEFINE(inst) \
static struct llcc68_data llcc68_data_##inst; \
static const struct llcc68_config llcc68_config_##inst = \
{ \
.spi = SPI_DT_SPEC_INST_GET(inst, SPI_WORD_SET(8) | SPI_TRANSFER_MSB, 100), \
.reset_gpio = GPIO_DT_SPEC_INST_GET(inst, reset_gpios), \
.busy_gpio = GPIO_DT_SPEC_INST_GET(inst, busy_gpios), \
.dio1_gpio = GPIO_DT_SPEC_INST_GET(inst, dio1_gpios), \
.tx_enable_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, tx_enable_gpios, {.port = NULL}), \
.rx_enable_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, rx_enable_gpios, {.port = NULL}), \
}; \
DEVICE_DT_INST_DEFINE(inst, \
llcc68_init, \
NULL, \
&llcc68_data_##inst, \
&llcc68_config_##inst, \
POST_KERNEL, \
CONFIG_LLCC68_INIT_PRIORITY, \
NULL)
BUILD_ASSERT(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT),
"No status=okay nodes for DT_DRV_COMPAT; check compatible/status");
DT_INST_FOREACH_STATUS_OKAY(LLCC68_DEFINE)