blob: c66467dfa3df75a773d490670228b9bbe98f0bb2 [file] [log] [blame]
Andreas Sandberga36147c2020-05-05 09:16:32 +01001/*
2 * Copyright (c) 2020 Andreas Sandberg
Andreas Sandberg23e4a8b2020-07-09 22:01:57 +01003 * Copyright (c) 2020 Grinn
Andreas Sandberga36147c2020-05-05 09:16:32 +01004 *
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 Sandberg23e4a8b2020-07-09 22:01:57 +010012#include <drivers/gpio.h>
Andreas Sandberga36147c2020-05-05 09:16:32 +010013#include <drivers/lora.h>
14#include <device.h>
15
Tomasz Bursztykae18fcbb2020-04-30 20:33:38 +020016int __sx12xx_configure_pin(const struct device * *dev, const char *controller,
Andreas Sandberg23e4a8b2020-07-09 22:01:57 +010017 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 Bursztykae18fcbb2020-04-30 20:33:38 +020028int sx12xx_lora_send(const struct device *dev, uint8_t *data,
29 uint32_t data_len);
Andreas Sandberga36147c2020-05-05 09:16:32 +010030
Tomasz Bursztykae18fcbb2020-04-30 20:33:38 +020031int sx12xx_lora_recv(const struct device *dev, uint8_t *data, uint8_t size,
Andreas Sandberga36147c2020-05-05 09:16:32 +010032 k_timeout_t timeout, int16_t *rssi, int8_t *snr);
33
Tomasz Bursztykae18fcbb2020-04-30 20:33:38 +020034int sx12xx_lora_config(const struct device *dev,
35 struct lora_modem_config *config);
Andreas Sandberga36147c2020-05-05 09:16:32 +010036
Tomasz Bursztykae18fcbb2020-04-30 20:33:38 +020037int sx12xx_lora_test_cw(const struct device *dev, uint32_t frequency,
38 int8_t tx_power,
Andreas Sandberga36147c2020-05-05 09:16:32 +010039 uint16_t duration);
40
Tomasz Bursztykae18fcbb2020-04-30 20:33:38 +020041int sx12xx_init(const struct device *dev);
Andreas Sandberga36147c2020-05-05 09:16:32 +010042
43#endif /* ZEPHYR_DRIVERS_SX12XX_COMMON_H_ */