lora.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
23 #include <stdint.h>
24 #include <stdlib.h>
25 
26 #include "modules.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
37 #ifndef LORA_FREQUENCY_RESOLUTION_NANOHERTZ_DEFAULT
43 #define LORA_FREQUENCY_RESOLUTION_NANOHERTZ_DEFAULT 61035156250
44 #endif
45 
57 #ifndef CONFIG_LORA_PREAMBLE_LENGTH_DEFAULT
58 #define CONFIG_LORA_PREAMBLE_LENGTH_DEFAULT (8U)
59 #endif
60 
66 #ifndef CONFIG_LORA_SYMBOL_TIMEOUT_DEFAULT
67 #define CONFIG_LORA_SYMBOL_TIMEOUT_DEFAULT (10U)
68 #endif
69 
75 #if IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_125)
76 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_125_KHZ)
77 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_250)
78 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_250_KHZ)
79 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_500)
80 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_500_KHZ)
81 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_200)
82 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_200_KHZ)
83 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_400)
84 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_400_KHZ)
85 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_800)
86 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_800_KHZ)
87 #elif IS_ACTIVE(CONFIG_LORA_BW_DEFAULT_1600)
88 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_1600_KHZ)
89 #endif
90 
91 #ifndef CONFIG_LORA_BW_DEFAULT
92 #define CONFIG_LORA_BW_DEFAULT (LORA_BW_125_KHZ)
93 #endif
94 
105 #if IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF6)
106 #define CONFIG_LORA_SF_DEFAULT (LORA_SF6)
107 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF7)
108 #define CONFIG_LORA_SF_DEFAULT (LORA_SF7)
109 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF8)
110 #define CONFIG_LORA_SF_DEFAULT (LORA_SF8)
111 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF9)
112 #define CONFIG_LORA_SF_DEFAULT (LORA_SF9)
113 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF10)
114 #define CONFIG_LORA_SF_DEFAULT (LORA_SF10)
115 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF11)
116 #define CONFIG_LORA_SF_DEFAULT (LORA_SF11)
117 #elif IS_ACTIVE(CONFIG_LORA_SF_DEFAULT_SF12)
118 #define CONFIG_LORA_SF_DEFAULT (LORA_SF12)
119 #endif
120 
121 #ifndef CONFIG_LORA_SF_DEFAULT
122 #define CONFIG_LORA_SF_DEFAULT (LORA_SF7)
123 #endif
124 
137 #if IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_4_5)
138 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_5)
139 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_4_6)
140 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_6)
141 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_4_7)
142 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_7)
143 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_4_8)
144 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_8)
145 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_LI_4_5)
146 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_LI_4_5)
147 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_LI_4_6)
148 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_LI_4_6)
149 #elif IS_ACTIVE(CONFIG_LORA_CR_DEFAULT_CR_LI_4_8)
150 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_LI_4_8)
151 #endif
152 
153 #ifndef CONFIG_LORA_CR_DEFAULT
154 #define CONFIG_LORA_CR_DEFAULT (LORA_CR_4_5)
155 #endif
156 
162 #ifdef DOXYGEN
163 #define CONFIG_LORA_IQ_INVERTED_DEFAULT
164 #endif
165 
172 #ifdef DOXYGEN
173 #define CONFIG_LORA_FREQUENCY_HOPPING_DEFAULT
174 #endif
175 
182 #ifndef CONFIG_LORA_FREQUENCY_HOPPING_PERIOD_DEFAULT
183 #define CONFIG_LORA_FREQUENCY_HOPPING_PERIOD_DEFAULT (0U)
184 #endif
185 
193 #ifdef DOXYGEN
194 #define CONFIG_LORA_FIXED_HEADER_LEN_MODE_DEFAULT
195 #endif
196 
200 #ifdef DOXYGEN
201 #define CONFIG_LORA_PAYLOAD_CRC_OFF_DEFAULT
202 #endif
203 
210 #ifndef CONFIG_LORA_PAYLOAD_LENGTH_DEFAULT
211 #define CONFIG_LORA_PAYLOAD_LENGTH_DEFAULT (0U)
212 #endif
219 #define LORA_SYNCWORD_PUBLIC (0x34)
220 #define LORA_SYNCWORD_PRIVATE (0x12)
221 /* see https://lora-developers.semtech.com/documentation/tech-papers-and-guides/physical-layer-proposal-2.4ghz */
222 #define LORA_SYNCWORD_ISM2400_PUBLIC (0x21)
231 #define LORA_ISM2400_FREQUENCY_LOW 2400000000
232 #define LORA_ISM2400_FREQUENCY_HIGH 2500000000
242 enum {
250 };
251 
255 enum {
256  LORA_SF5 = 5,
263  LORA_SF12
264 };
265 
269 enum {
277 };
280 #ifdef __cplusplus
281 }
282 #endif
283 
@ LORA_CR_LI_4_6
coding rate long interleaving 4/6
Definition: lora.h:275
@ LORA_CR_4_6
coding rate 4/6
Definition: lora.h:271
@ LORA_CR_4_7
coding rate 4/7
Definition: lora.h:272
@ LORA_CR_4_5
coding rate 4/5
Definition: lora.h:270
@ LORA_CR_LI_4_8
coding rate long interleaving 4/8
Definition: lora.h:276
@ LORA_CR_4_8
coding rate 4/8
Definition: lora.h:273
@ LORA_CR_LI_4_5
coding rate long interleaving 4/5
Definition: lora.h:274
@ LORA_SF7
spreading factor 7
Definition: lora.h:258
@ LORA_SF6
spreading factor 6
Definition: lora.h:257
@ LORA_SF10
spreading factor 10
Definition: lora.h:261
@ LORA_SF12
spreading factor 12
Definition: lora.h:263
@ LORA_SF11
spreading factor 11
Definition: lora.h:262
@ LORA_SF8
spreading factor 8
Definition: lora.h:259
@ LORA_SF5
spreading factor 5, sx126x and sx1280
Definition: lora.h:256
@ LORA_SF9
spreading factor 9
Definition: lora.h:260
@ LORA_BW_125_KHZ
125 kHz bandwidth
Definition: lora.h:243
@ LORA_BW_400_KHZ
400 kHz bandwidth, only 2.4Ghz
Definition: lora.h:247
@ LORA_BW_200_KHZ
200 kHz bandwidth, only 2.4Ghz
Definition: lora.h:246
@ LORA_BW_1600_KHZ
1600 kHz bandwidth, only 2.4Ghz
Definition: lora.h:249
@ LORA_BW_800_KHZ
800 kHz bandwidth, only 2.4Ghz
Definition: lora.h:248
@ LORA_BW_250_KHZ
250 kHz bandwidth
Definition: lora.h:244
@ LORA_BW_500_KHZ
500 kHz bandwidth
Definition: lora.h:245
Common macros and compiler attributes/pragmas configuration.