drivers: lora: Move sx1276 pin helpers to sx12xx common

The new sx1276 pin configuration helpers can be used by the sx126x
driver as well. Move them to sx126xx_common.{c,h} to facilitate reuse.

Signed-off-by: Andreas Sandberg <andreas@sandberg.pp.se>
This commit is contained in:
Andreas Sandberg 2020-07-09 22:01:57 +01:00 committed by Carles Cufí
commit 23e4a8b64e
3 changed files with 45 additions and 37 deletions

View file

@ -1,9 +1,11 @@
/*
* Copyright (c) 2019 Manivannan Sadhasivam
* Copyright (c) 2020 Grinn
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <drivers/gpio.h>
#include <drivers/lora.h>
#include <logging/log.h>
#include <zephyr.h>
@ -11,6 +13,8 @@
/* LoRaMac-node specific includes */
#include <radio.h>
#include "sx12xx_common.h"
LOG_MODULE_REGISTER(sx12xx_common, CONFIG_LORA_LOG_LEVEL);
static struct sx12xx_data {
@ -22,6 +26,27 @@ static struct sx12xx_data {
int16_t rssi;
} dev_data;
int __sx12xx_configure_pin(struct device **dev, const char *controller,
gpio_pin_t pin, gpio_flags_t flags)
{
int err;
*dev = device_get_binding(controller);
if (!(*dev)) {
LOG_ERR("Cannot get pointer to %s device", controller);
return -EIO;
}
err = gpio_pin_configure(*dev, pin, flags);
if (err) {
LOG_ERR("Cannot configure gpio %s %d: %d", controller, pin,
err);
return err;
}
return 0;
}
static void sx12xx_ev_rx_done(uint8_t *payload, uint16_t size, int16_t rssi,
int8_t snr)
{