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>
|
|
|
|
|
2022-01-29 06:25:29 +08:00
|
|
|
int __sx12xx_configure_pin(const struct gpio_dt_spec *gpio, gpio_flags_t flags);
|
2020-07-10 05:01:57 +08:00
|
|
|
|
|
|
|
#define sx12xx_configure_pin(_name, _flags) \
|
|
|
|
COND_CODE_1(DT_INST_NODE_HAS_PROP(0, _name##_gpios), \
|
2022-01-29 06:25:29 +08:00
|
|
|
(__sx12xx_configure_pin(&dev_config._name, _flags)),\
|
2020-07-10 05:01:57 +08:00
|
|
|
(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
|
|
|
|
2021-06-30 10:45:37 +08:00
|
|
|
int sx12xx_lora_send_async(const struct device *dev, uint8_t *data,
|
|
|
|
uint32_t data_len, struct k_poll_signal *async);
|
|
|
|
|
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);
|
|
|
|
|
2021-08-14 15:40:28 +08:00
|
|
|
int sx12xx_lora_recv_async(const struct device *dev, lora_recv_cb cb);
|
|
|
|
|
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_ */
|