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 <drivers/gpio.h> 13 #include <drivers/lora.h> 14 #include <device.h> 15 16 int __sx12xx_configure_pin(const struct device * *dev, const char *controller, 17 gpio_pin_t pin, gpio_flags_t flags); 18 19 #define sx12xx_configure_pin(_name, _flags) \ 20 COND_CODE_1(DT_INST_NODE_HAS_PROP(0, _name##_gpios), \ 21 (__sx12xx_configure_pin(&dev_data._name, \ 22 DT_INST_GPIO_LABEL(0, _name##_gpios), \ 23 DT_INST_GPIO_PIN(0, _name##_gpios), \ 24 DT_INST_GPIO_FLAGS(0, _name##_gpios) | \ 25 _flags)), \ 26 (0)) 27 28 int sx12xx_lora_send(const struct device *dev, uint8_t *data, 29 uint32_t data_len); 30 31 int sx12xx_lora_send_async(const struct device *dev, uint8_t *data, 32 uint32_t data_len, struct k_poll_signal *async); 33 34 int sx12xx_lora_recv(const struct device *dev, uint8_t *data, uint8_t size, 35 k_timeout_t timeout, int16_t *rssi, int8_t *snr); 36 37 int sx12xx_lora_config(const struct device *dev, 38 struct lora_modem_config *config); 39 40 int sx12xx_lora_test_cw(const struct device *dev, uint32_t frequency, 41 int8_t tx_power, 42 uint16_t duration); 43 44 int sx12xx_init(const struct device *dev); 45 46 #endif /* ZEPHYR_DRIVERS_SX12XX_COMMON_H_ */ 47