Skip to content

Commit 450b653

Browse files
committed
drivers/sx126x add optional CONFIG_SX126X_DEFAULT_SYNC_WORD
1 parent ef76a04 commit 450b653

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/sx126x/include/sx126x_internal.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@
2727
extern "C" {
2828
#endif
2929

30+
#if defined(DOXYGEN)
31+
/**
32+
* @brief Configure the LoRa sync word
33+
*
34+
* The sync word for sx126x is 16 bits long.
35+
* Private networks should use 0x1424.
36+
* Public networks should use 0x3444.
37+
* Using the driver API you only configure 2 nibbles Y and Z to form a sync word 0xY4Z4.
38+
* The default chip value is 0x12 (0x1424).
39+
*
40+
* See https://blog.classycode.com/lora-sync-word-compatibility-between-sx127x-and-sx126x-460324d1787a
41+
* for more information and a comparison with sx127x.
42+
*/
43+
# define CONFIG_SX126X_DEFAULT_SYNC_WORD 0x12
44+
#endif
45+
3046
/**
3147
* @brief Check whether the device model is sx1261
3248
*

drivers/sx126x/sx126x.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ static void sx126x_init_default_config(sx126x_t *dev)
291291
sx126x_set_pkt_type(dev, SX126X_PKT_TYPE_LORA);
292292
sx126x_set_channel(dev, CONFIG_SX126X_CHANNEL_DEFAULT);
293293
sx126x_set_tx_power(dev, CONFIG_SX126X_TX_POWER_DEFAULT, CONFIG_SX126X_RAMP_TIME_DEFAULT);
294+
#ifdef CONFIG_SX126X_DEFAULT_SYNC_WORD
295+
sx126x_set_lora_sync_word(dev, CONFIG_SX126X_DEFAULT_SYNC_WORD);
296+
#endif
294297

295298
dev->mod_params.bw = (sx126x_lora_bw_t)(CONFIG_LORA_BW_DEFAULT + SX126X_LORA_BW_125);
296299
dev->mod_params.sf = (sx126x_lora_sf_t)CONFIG_LORA_SF_DEFAULT;

0 commit comments

Comments
 (0)