2020-05-05 16:16:32 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Andreas Sandberg
|
2020-07-10 05:01:57 +08:00
|
|
|
* Copyright (c) 2020 Grinn
|
2020-05-05 16:16:32 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEPHYR_DRIVERS_SX12XX_COMMON_H_
|
|
|
|
#define ZEPHYR_DRIVERS_SX12XX_COMMON_H_
|
|
|
|
|
|
|
|
#include <zephyr/types.h>
|
2020-07-10 05:01:57 +08:00
|
|
|
#include <drivers/gpio.h>
|
2020-05-05 16:16:32 +08:00
|
|
|
#include <drivers/lora.h>
|
|
|
|
#include <device.h>
|
|
|
|
|
2020-05-01 02:33:38 +08:00
|
|
|
int __sx12xx_configure_pin(const struct device * *dev, const char *controller,
|
2020-07-10 05:01:57 +08:00
|
|
|
gpio_pin_t pin, gpio_flags_t flags);
|
|
|
|
|
|
|
|
#define sx12xx_configure_pin(_name, _flags) \
|
|
|
|
COND_CODE_1(DT_INST_NODE_HAS_PROP(0, _name##_gpios), \
|
|
|
|
(__sx12xx_configure_pin(&dev_data._name, \
|
|
|
|
DT_INST_GPIO_LABEL(0, _name##_gpios), \
|
|
|
|
DT_INST_GPIO_PIN(0, _name##_gpios), \
|
|
|
|
DT_INST_GPIO_FLAGS(0, _name##_gpios) | \
|
|
|
|
_flags)), \
|
|
|
|
(0))
|
|
|
|
|
2020-05-01 02:33:38 +08:00
|
|
|
int sx12xx_lora_send(const struct device *dev, uint8_t *data,
|
|
|
|
uint32_t data_len);
|
2020-05-05 16:16:32 +08:00
|
|
|
|
2020-05-01 02:33:38 +08:00
|
|
|
int sx12xx_lora_recv(const struct device *dev, uint8_t *data, uint8_t size,
|
2020-05-05 16:16:32 +08:00
|
|
|
k_timeout_t timeout, int16_t *rssi, int8_t *snr);
|
|
|
|
|
2020-05-01 02:33:38 +08:00
|
|
|
int sx12xx_lora_config(const struct device *dev,
|
|
|
|
struct lora_modem_config *config);
|
2020-05-05 16:16:32 +08:00
|
|
|
|
2020-05-01 02:33:38 +08:00
|
|
|
int sx12xx_lora_test_cw(const struct device *dev, uint32_t frequency,
|
|
|
|
int8_t tx_power,
|
2020-05-05 16:16:32 +08:00
|
|
|
uint16_t duration);
|
|
|
|
|
2020-05-01 02:33:38 +08:00
|
|
|
int sx12xx_init(const struct device *dev);
|
2020-05-05 16:16:32 +08:00
|
|
|
|
|
|
|
#endif /* ZEPHYR_DRIVERS_SX12XX_COMMON_H_ */
|