1 /*
2  * Copyright (c) 2020 Andreas Sandberg
3  * Copyright (c) 2020 Grinn
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #ifndef ZEPHYR_DRIVERS_SX12XX_COMMON_H_
9 #define ZEPHYR_DRIVERS_SX12XX_COMMON_H_
10 
11 #include <zephyr/types.h>
12 #include <zephyr/drivers/gpio.h>
13 #include <zephyr/drivers/lora.h>
14 #include <zephyr/device.h>
15 
16 int __sx12xx_configure_pin(const struct gpio_dt_spec *gpio, gpio_flags_t flags);
17 
18 #define sx12xx_configure_pin(_name, _flags)				\
19 	COND_CODE_1(DT_INST_NODE_HAS_PROP(0, _name##_gpios),		\
20 		    (__sx12xx_configure_pin(&dev_config._name, _flags)),\
21 		    (0))
22 
23 int sx12xx_lora_send(const struct device *dev, uint8_t *data,
24 		     uint32_t data_len);
25 
26 int sx12xx_lora_send_async(const struct device *dev, uint8_t *data,
27 			   uint32_t data_len, struct k_poll_signal *async);
28 
29 int sx12xx_lora_recv(const struct device *dev, uint8_t *data, uint8_t size,
30 		     k_timeout_t timeout, int16_t *rssi, int8_t *snr);
31 
32 int sx12xx_lora_recv_async(const struct device *dev, lora_recv_cb cb);
33 
34 int sx12xx_lora_config(const struct device *dev,
35 		       struct lora_modem_config *config);
36 
37 int sx12xx_lora_test_cw(const struct device *dev, uint32_t frequency,
38 			int8_t tx_power,
39 			uint16_t duration);
40 
41 int sx12xx_init(const struct device *dev);
42 
43 #endif /* ZEPHYR_DRIVERS_SX12XX_COMMON_H_ */
44