Andreas Sandberg | a36147c | 2020-05-05 09:16:32 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020 Andreas Sandberg |
Andreas Sandberg | 23e4a8b | 2020-07-09 22:01:57 +0100 | [diff] [blame] | 3 | * Copyright (c) 2020 Grinn |
Andreas Sandberg | a36147c | 2020-05-05 09:16:32 +0100 | [diff] [blame] | 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> |
Andreas Sandberg | 23e4a8b | 2020-07-09 22:01:57 +0100 | [diff] [blame] | 12 | #include <drivers/gpio.h> |
Andreas Sandberg | a36147c | 2020-05-05 09:16:32 +0100 | [diff] [blame] | 13 | #include <drivers/lora.h> |
| 14 | #include <device.h> |
| 15 | |
Tomasz Bursztyka | e18fcbb | 2020-04-30 20:33:38 +0200 | [diff] [blame] | 16 | int __sx12xx_configure_pin(const struct device * *dev, const char *controller, |
Andreas Sandberg | 23e4a8b | 2020-07-09 22:01:57 +0100 | [diff] [blame] | 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 | |
Tomasz Bursztyka | e18fcbb | 2020-04-30 20:33:38 +0200 | [diff] [blame] | 28 | int sx12xx_lora_send(const struct device *dev, uint8_t *data, |
| 29 | uint32_t data_len); |
Andreas Sandberg | a36147c | 2020-05-05 09:16:32 +0100 | [diff] [blame] | 30 | |
Tomasz Bursztyka | e18fcbb | 2020-04-30 20:33:38 +0200 | [diff] [blame] | 31 | int sx12xx_lora_recv(const struct device *dev, uint8_t *data, uint8_t size, |
Andreas Sandberg | a36147c | 2020-05-05 09:16:32 +0100 | [diff] [blame] | 32 | k_timeout_t timeout, int16_t *rssi, int8_t *snr); |
| 33 | |
Tomasz Bursztyka | e18fcbb | 2020-04-30 20:33:38 +0200 | [diff] [blame] | 34 | int sx12xx_lora_config(const struct device *dev, |
| 35 | struct lora_modem_config *config); |
Andreas Sandberg | a36147c | 2020-05-05 09:16:32 +0100 | [diff] [blame] | 36 | |
Tomasz Bursztyka | e18fcbb | 2020-04-30 20:33:38 +0200 | [diff] [blame] | 37 | int sx12xx_lora_test_cw(const struct device *dev, uint32_t frequency, |
| 38 | int8_t tx_power, |
Andreas Sandberg | a36147c | 2020-05-05 09:16:32 +0100 | [diff] [blame] | 39 | uint16_t duration); |
| 40 | |
Tomasz Bursztyka | e18fcbb | 2020-04-30 20:33:38 +0200 | [diff] [blame] | 41 | int sx12xx_init(const struct device *dev); |
Andreas Sandberg | a36147c | 2020-05-05 09:16:32 +0100 | [diff] [blame] | 42 | |
| 43 | #endif /* ZEPHYR_DRIVERS_SX12XX_COMMON_H_ */ |